UNPKG

hy-checkbox

Version:

checkbox & radio ui components for react

91 lines (71 loc) 3.67 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _classnames = require('classnames'); var _classnames2 = _interopRequireDefault(_classnames); var _detailItem = require('./detailItem'); var _detailItem2 = _interopRequireDefault(_detailItem); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var DetailList = function (_React$Component) { _inherits(DetailList, _React$Component); function DetailList(props) { _classCallCheck(this, DetailList); var _this = _possibleConstructorReturn(this, (DetailList.__proto__ || Object.getPrototypeOf(DetailList)).call(this, props)); _this.state = { detailoptions: _this.props.options || [] }; return _this; } _createClass(DetailList, [{ key: 'render', value: function render() { var prefixCls = this.props.prefixCls; var detailoptions = this.state.detailoptions; // console.log('列表组---------------',options) return _react2.default.createElement( 'ul', { className: (0, _classnames2.default)(prefixCls + '-detail-list') }, detailoptions.map(function (item) { return _react2.default.createElement(_detailItem2.default, { key: item.id, name: item.name, value: item.value, id: item.id, prefixCls: prefixCls }); }) ); } }]); return DetailList; }(_react2.default.Component); DetailList.propTypes = { options: _react2.default.PropTypes.array, prefixCls: _react2.default.PropTypes.string }; DetailList.defaultProps = { options: [{ id: 0, name: '名称', value: 'provider' }, { id: 1, name: 'MTU', value: '9000' }, { id: 2, name: '状态', value: '活跃' }, { id: 3, name: '项目', value: 'admin' }, { id: 4, name: '可用域 ', value: 'nova' }], prefixCls: "ult" }; exports.default = DetailList;