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 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | 1× 1× 1× 1× 1× 2× 5× 6× 6× 1× 1× 1× 1× 6× 6× 1× 4× 4× 4× 4× 4× 4× 4× 1× 13× 13× 13× 4× 1× 1× 1× 1× 1× 1× | 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _propTypes = require('prop-types'); var _propTypes2 = _interopRequireDefault(_propTypes); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); Iif (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; } function _classCallCheck(instance, Constructor) { Iif (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { Iif (!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) { Iif (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 } }); Eif (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); } var LinkBar = function (_React$Component) { _inherits(LinkBar, _React$Component); function LinkBar() { _classCallCheck(this, LinkBar); return _possibleConstructorReturn(this, _React$Component.apply(this, arguments)); } LinkBar.prototype.renderActionBtn = function renderActionBtn(item, index, last) { var me = this; var itemProps = { onClick: item.callback || function () {} }; var action = void 0; var cutOff = _react2['default'].createElement('div', { className: me.props.prefixCls + '-cutoff' }); Iif (!!item.render && typeof item.render === 'function') { action = _react2['default'].createElement( 'div', itemProps, item.render(item.title) ); } else { action = _react2['default'].createElement( 'a', itemProps, item.title ); } return _react2['default'].createElement( 'div', { className: me.props.prefixCls + '-item', key: index }, action, last ? null : cutOff ); }; LinkBar.prototype.render = function render() { var me = this; var _me$props = me.props, config = _me$props.config, prefixCls = _me$props.prefixCls; return _react2['default'].createElement( 'div', { className: prefixCls }, config.map(function (item, index) { return me.renderActionBtn(item, index, index === config.length - 1); }) ); }; return LinkBar; }(_react2['default'].Component); LinkBar.propTypes = { prefixCls: _propTypes2['default'].string, config: _propTypes2['default'].array }; LinkBar.defaultProps = { prefixCls: 'kuma-uxtable-linkbar', config: [] }; LinkBar.displayName = 'LinkBar'; exports['default'] = LinkBar; module.exports = exports['default']; |