UNPKG

@aliretail/react-materials-components

Version:
62 lines (52 loc) 1.57 kB
import _Tab from "@alifd/next/es/tab"; import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose"; import * as React from 'react'; import * as PropTypes from 'prop-types'; var FormTab = /*#__PURE__*/function (_React$Component) { _inheritsLoose(FormTab, _React$Component); function FormTab() { var _this; for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this; _this.handleTabChange = function (key) { _this.props.onChange(key); }; return _this; } var _proto = FormTab.prototype; _proto.render = function render() { var _this$props = this.props, dataSource = _this$props.dataSource, value = _this$props.value, shape = _this$props.shape, size = _this$props.size; return /*#__PURE__*/React.createElement(_Tab, { activeKey: value, shape: shape, size: size, onChange: this.handleTabChange }, dataSource.length > 0 && dataSource.map(function (t) { return /*#__PURE__*/React.createElement(_Tab.Item, { title: t.label, key: t.value }); })); }; return FormTab; }(React.Component); FormTab.propTypes = { dataSource: PropTypes.array, value: PropTypes.string, shape: PropTypes.string, onChange: PropTypes.func, size: PropTypes.string }; FormTab.defaultProps = { dataSource: [], value: '', shape: 'pure', size: 'medium' }; export default FormTab;