UNPKG

7.28 kBJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports["default"] = void 0;
7
8var _react = _interopRequireDefault(require("react"));
9
10var _propTypes = _interopRequireDefault(require("prop-types"));
11
12var _reactLifecyclesCompat = require("react-lifecycles-compat");
13
14var _rcTabs = _interopRequireWildcard(require("rc-tabs"));
15
16var _TabContent = _interopRequireDefault(require("rc-tabs/lib/TabContent"));
17
18var _ScrollableInkTabBar = _interopRequireDefault(require("rc-tabs/lib/ScrollableInkTabBar"));
19
20var _DocumentComponents = _interopRequireDefault(require("./DocumentComponents"));
21
22var _FixedComponents = _interopRequireDefault(require("./FixedComponents"));
23
24var _SubjectComponents = _interopRequireDefault(require("./SubjectComponents"));
25
26var _AuxiliaryComponents = _interopRequireDefault(require("./AuxiliaryComponents"));
27
28var _FunctionComponents = _interopRequireDefault(require("./FunctionComponents"));
29
30function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } }
31
32function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
33
34function _extends() { _extends = Object.assign || 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); }
35
36function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
37
38function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
39
40function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
41
42function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
43
44function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
45
46function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
47
48function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
49
50function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
51
52var TabsComponents =
53/*#__PURE__*/
54function (_React$Component) {
55 _inherits(TabsComponents, _React$Component);
56
57 function TabsComponents(props) {
58 var _this;
59
60 _classCallCheck(this, TabsComponents);
61
62 _this = _possibleConstructorReturn(this, _getPrototypeOf(TabsComponents).call(this, props));
63 _this.onChange = _this.onChange.bind(_assertThisInitialized(_this));
64 _this.state = {
65 activeKey: _this.props.activeKey
66 };
67 return _this;
68 } // componentWillReceiveProps(nextProps){
69 // if(nextProps.activeKey!=this.state.activeKey){
70 // let activeKey = nextProps.activeKey
71 // this.setState({activeKey})
72 // }
73 // }
74
75
76 _createClass(TabsComponents, [{
77 key: "onChange",
78 value: function onChange(activeKey) {
79 this.setState({
80 activeKey: activeKey
81 });
82 this.props.onDesc();
83 }
84 }, {
85 key: "render",
86 value: function render() {
87 var _this2 = this;
88
89 var _this$props = this.props,
90 prefixCls = _this$props.prefixCls,
91 tabs = _this$props.tabs,
92 DocumentTreeData = _this$props.DocumentTreeData,
93 ReferDataUrl = _this$props.ReferDataUrl,
94 fixedData = _this$props.fixedData,
95 SubjectData = _this$props.SubjectData,
96 onDesc = _this$props.onDesc,
97 FunctionData = _this$props.FunctionData; // console.log(this.props)
98
99 return _react["default"].createElement(_rcTabs["default"], {
100 prefixCls: prefixCls,
101 defaultActiveKey: this.state.activeKey,
102 activeKey: this.state.activeKey,
103 onChange: this.onChange,
104 renderTabBar: function renderTabBar() {
105 return _react["default"].createElement(_ScrollableInkTabBar["default"], null);
106 },
107 renderTabContent: function renderTabContent() {
108 return _react["default"].createElement(_TabContent["default"], null);
109 }
110 }, tabs.map(function (item) {
111 var Component = item.component;
112 var props = {
113 onInsertValue: _this2.props.onInsertValue,
114 ReferDataUrl: ReferDataUrl,
115 fixedData: fixedData,
116 onDesc: onDesc,
117 DocumentTreeData: DocumentTreeData,
118 SubjectData: SubjectData,
119 FunctionData: FunctionData
120 };
121
122 if (typeof item.component === 'string') {
123 if (item.component === 'Document') {
124 Component = _DocumentComponents["default"];
125 } else if (item.component === 'Fixed') {
126 Component = _FixedComponents["default"];
127 } else if (item.component === 'Subject') {
128 Component = _SubjectComponents["default"];
129 } else if (item.component === 'Auxiliary') {
130 Component = _AuxiliaryComponents["default"];
131 } else if (item.component === 'Function') {
132 Component = _FunctionComponents["default"];
133 }
134 }
135
136 return _react["default"].createElement(_rcTabs.TabPane, {
137 key: item.id,
138 tab: item.name,
139 disabled: item.disabled
140 }, _react["default"].createElement(Component, _extends({}, props, {
141 item: item
142 })));
143 }));
144 }
145 }]);
146
147 return TabsComponents;
148}(_react["default"].Component);
149
150TabsComponents.propTypes = {
151 prefixCls: _propTypes["default"].string,
152 tabs: _propTypes["default"].array,
153 activeKey: _propTypes["default"].string,
154 ReferDataUrl: _propTypes["default"].string
155};
156TabsComponents.defaultProps = {
157 prefixCls: 'rc-tabs',
158 tabs: [],
159 activeKey: '0',
160 ReferDataUrl: ''
161};
162(0, _reactLifecyclesCompat.polyfill)(TabsComponents);
163var _default = TabsComponents;
164exports["default"] = _default;
\No newline at end of file