UNPKG

tinper-bee

Version:

React Components living for enterprise-class pc backend application

977 lines (780 loc) 33.5 kB
(function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(require("react"), require("prop-types")); else if(typeof define === 'function' && define.amd) define(["react", "prop-types"], factory); else { var a = typeof exports === 'object' ? factory(require("react"), require("prop-types")) : factory(root["React"], root["PropTypes"]); for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i]; } })(typeof self !== 'undefined' ? self : this, function(__WEBPACK_EXTERNAL_MODULE_0__, __WEBPACK_EXTERNAL_MODULE_1__) { return /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) { /******/ return installedModules[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ i: moduleId, /******/ l: false, /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ /******/ // Flag the module as loaded /******/ module.l = true; /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /******/ /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ /******/ // define getter function for harmony exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ if(!__webpack_require__.o(exports, name)) { /******/ Object.defineProperty(exports, name, { /******/ configurable: false, /******/ enumerable: true, /******/ get: getter /******/ }); /******/ } /******/ }; /******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? /******/ function getDefault() { return module['default']; } : /******/ function getModuleExports() { return module; }; /******/ __webpack_require__.d(getter, 'a', getter); /******/ return getter; /******/ }; /******/ /******/ // Object.prototype.hasOwnProperty.call /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; /******/ /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; /******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = 1044); /******/ }) /************************************************************************/ /******/ ({ /***/ 0: /***/ (function(module, exports) { module.exports = __WEBPACK_EXTERNAL_MODULE_0__; /***/ }), /***/ 1: /***/ (function(module, exports) { module.exports = __WEBPACK_EXTERNAL_MODULE_1__; /***/ }), /***/ 1044: /***/ (function(module, exports, __webpack_require__) { module.exports = __webpack_require__(1045); /***/ }), /***/ 1045: /***/ (function(module, exports, __webpack_require__) { __webpack_require__(1046); module.exports = __webpack_require__(1047); /***/ }), /***/ 1046: /***/ (function(module, exports) { // removed by extract-text-webpack-plugin /***/ }), /***/ 1047: /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _AutoComplete = __webpack_require__(1048); var _AutoComplete2 = _interopRequireDefault(_AutoComplete); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } exports["default"] = _AutoComplete2["default"]; module.exports = exports['default']; /***/ }), /***/ 1048: /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _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; }; var _react = __webpack_require__(0); var _react2 = _interopRequireDefault(_react); var _classnames = __webpack_require__(4); var _classnames2 = _interopRequireDefault(_classnames); var _beeFormControl = __webpack_require__(1049); var _beeFormControl2 = _interopRequireDefault(_beeFormControl); var _propTypes = __webpack_require__(1); 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); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; } function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } 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) : _defaults(subClass, superClass); } var propTypes = { value: _propTypes2["default"].any, show: _propTypes2["default"].bool, options: _propTypes2["default"].array, onChange: _propTypes2["default"].func, onSelectOption: _propTypes2["default"].func }; var defaultProps = { value: "", show: false, options: [], clsPrefix: 'u-autocomplete', onBlur: function onBlur() {}, onKeyDown: function onKeyDown() {}, onValueChange: function onValueChange() {}, onChange: function onChange() {}, onSelectOption: function onSelectOption() {} }; var AutoComplete = function (_React$Component) { _inherits(AutoComplete, _React$Component); function AutoComplete(props) { _classCallCheck(this, AutoComplete); var _this = _possibleConstructorReturn(this, _React$Component.call(this, props)); _this.state = { show: props.show, //控制自动匹配列表的显示与隐藏 displayValue: '', activeItemIndex: -1, options: props.options, value: props.value, placeholder: props.placeholder }; _this.handleKeyDown = _this.handleKeyDown.bind(_this); _this.handleLeave = _this.handleLeave.bind(_this); _this.handleEnter = _this.handleEnter.bind(_this); _this.handleChangeList = _this.handleChangeList.bind(_this); _this.moveItem = _this.moveItem.bind(_this); _this.handLeBlur = _this.handLeBlur.bind(_this); return _this; } AutoComplete.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) { if ('value' in nextProps && nextProps.value !== this.props.value) { var value = nextProps.value; this.setState({ value: value }); } if ('options' in nextProps && nextProps.options !== this.props.options) { var options = nextProps.options; this.setState({ options: options }); } if ('show' in nextProps && nextProps.show !== this.props.show) { var show = nextProps.show; this.setState({ show: show }); } }; AutoComplete.prototype.handleChange = function handleChange(value) { var arr = []; var valueArr = this.props.options; valueArr.sort(); if (value.replace(/(^\s*)|(\s*$)/g, '') == "") { this.setState({ value: "", activeItemIndex: -1, show: false }); this.props.onValueChange(value); this.props.onChange(value); return; } for (var i = 0; i < valueArr.length; i++) { if (valueArr[i].indexOf(value) != -1) { arr.push(valueArr[i]); } } this.setState({ options: arr, show: true, activeItemIndex: -1, displayValue: '', value: value }); this.props.onValueChange(value); this.props.onChange(value); }; /** * 自动匹配的列表被选中其中某一个 * @param {*} value */ AutoComplete.prototype.handleChangeList = function handleChangeList(value) { this.setState({ show: false, displayValue: '' }); this.props.onValueChange(value); this.props.onChange(value); this.props.onSelectOption(value); }; AutoComplete.prototype.handleKeyDown = function handleKeyDown(e) { var _state = this.state, displayValue = _state.displayValue, activeItemIndex = _state.activeItemIndex; var _props = this.props, options = _props.options, onValueChange = _props.onValueChange, onKeyDown = _props.onKeyDown, onChange = _props.onChange; onKeyDown(e); switch (e.keyCode) { // 13为回车键的键码(keyCode) case 13: { this.setState({ show: false }); onValueChange(displayValue, activeItemIndex); onChange(displayValue, activeItemIndex); break; } // 38为上方向键,40为下方向键 case 38: case 40: { e.preventDefault(); // 使用moveItem方法对更新或取消选中项 this.moveItem(e.keyCode === 38 ? 'up' : 'down'); break; } } }; AutoComplete.prototype.moveItem = function moveItem(direction) { var _state2 = this.state, activeItemIndex = _state2.activeItemIndex, options = _state2.options; var lastIndex = options.length - 1; var newIndex = -1; // 计算新的activeItemIndex if (direction === 'up') { if (activeItemIndex === -1) { // 如果没有选中项则选择最后一项 newIndex = lastIndex; } else { newIndex = activeItemIndex - 1; } } else { if (activeItemIndex < lastIndex) { newIndex = activeItemIndex + 1; } } // 获取新的displayValue var newDisplayValue = ''; if (newIndex >= 0) { newDisplayValue = options[newIndex]; } // 更新状态 this.setState({ displayValue: newDisplayValue, activeItemIndex: newIndex }); }; AutoComplete.prototype.handleEnter = function handleEnter(index) { var currentItem = this.props.options[index]; this.setState({ activeItemIndex: index, displayValue: currentItem }); }; AutoComplete.prototype.handleLeave = function handleLeave() { this.setState({ activeItemIndex: -1, displayValue: '' }); }; AutoComplete.prototype.handLeBlur = function handLeBlur() { var _this2 = this; this.props.onBlur(this.state.value); setTimeout(function () { _this2.setState({ show: false }); }, 300); }; AutoComplete.prototype.render = function render() { var _this3 = this; var _state3 = this.state, show = _state3.show, displayValue = _state3.displayValue, activeItemIndex = _state3.activeItemIndex, options = _state3.options; var _props2 = this.props, disabled = _props2.disabled, clsPrefix = _props2.clsPrefix, onKeyDown = _props2.onKeyDown, onBlur = _props2.onBlur, onValueChange = _props2.onValueChange, onChange = _props2.onChange, value = _props2.value, placeholder = _props2.placeholder, props = _objectWithoutProperties(_props2, ['disabled', 'clsPrefix', 'onKeyDown', 'onBlur', 'onValueChange', 'onChange', 'value', 'placeholder']); var optionList = options.map(function (item, index) { return _react2["default"].createElement( 'li', { key: index, className: index === activeItemIndex ? "active" : '', onMouseEnter: function onMouseEnter() { return _this3.handleEnter(index); }, onClick: function onClick() { return _this3.handleChangeList(item); } }, item.text || item ); }); return _react2["default"].createElement( 'div', { className: (0, _classnames2["default"])(clsPrefix, this.props.className) }, _react2["default"].createElement(_beeFormControl2["default"], _extends({}, props, { value: displayValue || this.state.value, disabled: disabled, onChange: function onChange(value) { _this3.handleChange(value); }, onKeyDown: this.handleKeyDown, placeholder: this.state.placeholder, onBlur: this.handLeBlur })), show && options.length > 0 && _react2["default"].createElement( 'ul', { className: clsPrefix + '-options', onMouseLeave: this.handleLeave }, optionList ) ); }; return AutoComplete; }(_react2["default"].Component); AutoComplete.propTypes = propTypes; AutoComplete.defaultProps = defaultProps; exports["default"] = AutoComplete; module.exports = exports['default']; /***/ }), /***/ 1049: /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _FormControl = __webpack_require__(1050); var _FormControl2 = _interopRequireDefault(_FormControl); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } exports["default"] = _FormControl2["default"]; module.exports = exports['default']; /***/ }), /***/ 1050: /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _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; }; var _react = __webpack_require__(0); var _react2 = _interopRequireDefault(_react); var _classnames = __webpack_require__(4); var _classnames2 = _interopRequireDefault(_classnames); var _beeIcon = __webpack_require__(59); var _beeIcon2 = _interopRequireDefault(_beeIcon); var _propTypes = __webpack_require__(1); var _propTypes2 = _interopRequireDefault(_propTypes); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } 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); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return 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) : _defaults(subClass, superClass); } var propTypes = { componentClass: _propTypes2["default"].oneOfType([_propTypes2["default"].element, _propTypes2["default"].string]), type: _propTypes2["default"].string, size: _propTypes2["default"].oneOf(['sm', 'md', 'lg']), onSearch: _propTypes2["default"].func, onChange: _propTypes2["default"].func, onBlur: _propTypes2["default"].func, showClose: _propTypes2["default"].bool, focusSelect: _propTypes2["default"].bool, debounceDelay: _propTypes2["default"].number }; var defaultProps = { componentClass: 'input', clsPrefix: 'u-form-control', type: 'text', size: 'md' }; function fixControlledValue(value) { if (typeof value === 'undefined' || value === null) { return ''; } return value; } var FormControl = function (_React$Component) { _inherits(FormControl, _React$Component); function FormControl(props) { _classCallCheck(this, FormControl); var _this = _possibleConstructorReturn(this, _React$Component.call(this, props)); _initialiseProps.call(_this); var value = typeof props.value === 'undefined' ? props.defaultValue : props.value; _this.state = { showSearch: !props.value, value: value }; _this.input = {}; _this.clickClearBtn = false; return _this; } FormControl.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProp) { if ("value" in nextProp) { if (nextProp.value !== this.state.value) { this.setState({ value: nextProp.value }); } } }; FormControl.prototype.render = function render() { if (this.props.type === "search") { return this.renderSearch(); } return this.renderInput(); }; return FormControl; }(_react2["default"].Component); var _initialiseProps = function _initialiseProps() { var _this2 = this; this.handleSearchChange = function (e) { var onChange = _this2.props.onChange; var value = _this2.input.value; _this2.setState({ value: value, showSearch: value == null || value === "" }); if (onChange) { onChange(value, e); } }; this.handleChange = function (e) { var _props$debounceDelay = _this2.props.debounceDelay, debounceDelay = _props$debounceDelay === undefined ? 0 : _props$debounceDelay; var now = new Date().getTime(); if (now - _this2.lastScrollCall < debounceDelay) return; _this2.lastScrollCall = now; var onChange = _this2.props.onChange; var value = _this2.input.value; if (!('value' in _this2.props)) { _this2.setState({ value: value }); } if (onChange) { onChange(value, e); } }; this.clearValue = function () { var _props = _this2.props, onChange = _props.onChange, showClose = _props.showClose; _this2.setState({ showSearch: true, value: "" }); if (_this2.e && _this2.e.target) _this2.e.target.value = ""; if (onChange) { onChange("", _this2.e); } if (showClose) { _this2.blurTime && clearTimeout(_this2.blurTime); _this2.blurTime = null; } _this2.input.focus(); }; this.handleKeyDown = function (e) { var _props2 = _this2.props, onSearch = _props2.onSearch, type = _props2.type, onKeyDown = _props2.onKeyDown; if (e.keyCode === 13 && type === "search") { if (onSearch) { onSearch(_this2.input.value); } } onKeyDown && onKeyDown(e); }; this.handleSearch = function (e) { var onSearch = _this2.props.onSearch; if (onSearch) onSearch(_this2.input.value); }; this.handleBlur = function (e) { var value = _this2.state.value; var _props3 = _this2.props, onBlur = _props3.onBlur, showClose = _props3.showClose; var _e = _extends({}, e); _this2.e = _e; if (onBlur) { if (showClose && _this2.clickClearBtn) { _this2.clickClearBtn = false; onBlur(value, _e, true); } else { onBlur(value, _e); } } }; this.handleFocus = function (e) { var value = _this2.state.value; var onFocus = _this2.props.onFocus; if (_this2.props.focusSelect) { _this2.input.select(); } if (onFocus) { onFocus(value, e); } }; this.onClearBtnMouseDown = function () { _this2.clickClearBtn = true; }; this.renderInput = function () { var _props4 = _this2.props, Component = _props4.componentClass, type = _props4.type, className = _props4.className, size = _props4.size, clsPrefix = _props4.clsPrefix, onChange = _props4.onChange, onSearch = _props4.onSearch, onBlur = _props4.onBlur, showClose = _props4.showClose, focusSelect = _props4.focusSelect, prefix = _props4.prefix, suffix = _props4.suffix, others = _objectWithoutProperties(_props4, ['componentClass', 'type', 'className', 'size', 'clsPrefix', 'onChange', 'onSearch', 'onBlur', 'showClose', 'focusSelect', 'prefix', 'suffix']); // input[type="file"] 不应该有类名 .form-control. var value = _this2.state.value; var classes = {}; if (size) { classes['' + size] = true; } var classNames = void 0; if (type !== 'file') { classNames = (0, _classnames2["default"])(clsPrefix, classes); } if (prefix || suffix) classNames += ' ' + clsPrefix + '-prefix-suffix'; if (className) classNames += ' ' + className; // 加判断,是否有 前后缀,是否加 wrapper if (showClose || suffix || prefix) { return _react2["default"].createElement( 'div', { className: (0, _classnames2["default"])(clsPrefix + '-close', clsPrefix + '-affix-wrapper ' + clsPrefix + '-affix-wrapper-' + size, className) }, prefix ? _react2["default"].createElement( 'span', { className: clsPrefix + '-simple-prefix' }, prefix ) : '', _react2["default"].createElement(Component, _extends({}, others, { type: type, ref: function ref(el) { return _this2.input = el; }, value: fixControlledValue(value), onChange: _this2.handleChange, onBlur: _this2.handleBlur, onFocus: _this2.handleFocus, className: (0, _classnames2["default"])(classNames) })), showClose && value ? _react2["default"].createElement( 'div', { className: clsPrefix + '-suffix has-close', onMouseDown: _this2.onClearBtnMouseDown, onClick: _this2.clearValue }, _react2["default"].createElement(_beeIcon2["default"], { type: 'uf-close-c' }) ) : '', suffix ? _react2["default"].createElement( 'span', { className: clsPrefix + '-simple-suffix' }, suffix ) : '' ); } else { return _react2["default"].createElement(Component, _extends({}, others, { type: type, ref: function ref(el) { return _this2.input = el; }, value: fixControlledValue(value), onChange: _this2.handleChange, onBlur: _this2.handleBlur, onFocus: _this2.handleFocus, className: (0, _classnames2["default"])(classNames) })); } }; this.renderSearch = function () { var _props5 = _this2.props, Component = _props5.componentClass, type = _props5.type, className = _props5.className, size = _props5.size, clsPrefix = _props5.clsPrefix, onChange = _props5.onChange, onSearch = _props5.onSearch, onBlur = _props5.onBlur, others = _objectWithoutProperties(_props5, ['componentClass', 'type', 'className', 'size', 'clsPrefix', 'onChange', 'onSearch', 'onBlur']); // input[type="file"] 不应该有类名 .form-control. var value = _this2.state.value; var classes = {}; if (size) { classes['' + size] = true; } classes[clsPrefix + '-search'] = true; if (type === "search") { return _react2["default"].createElement( 'div', { className: (0, _classnames2["default"])(clsPrefix + '-search', clsPrefix + '-affix-wrapper', className) }, _react2["default"].createElement(Component, _extends({}, others, { type: type, ref: function ref(el) { return _this2.input = el; }, onChange: _this2.handleSearchChange, value: fixControlledValue(value), onKeyDown: _this2.handleKeyDown, onBlur: _this2.handleBlur, onFocus: _this2.handleFocus, className: (0, _classnames2["default"])(clsPrefix, classes) })), _react2["default"].createElement( 'div', { className: clsPrefix + '-suffix' }, _react2["default"].createElement(_beeIcon2["default"], { type: 'uf-search', onClick: _this2.handleSearch }) ) ); } }; }; FormControl.propTypes = propTypes; FormControl.defaultProps = defaultProps; exports["default"] = FormControl; module.exports = exports['default']; /***/ }), /***/ 4: /***/ (function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! Copyright (c) 2017 Jed Watson. Licensed under the MIT License (MIT), see http://jedwatson.github.io/classnames */ /* global define */ (function () { 'use strict'; var hasOwn = {}.hasOwnProperty; function classNames () { var classes = []; for (var i = 0; i < arguments.length; i++) { var arg = arguments[i]; if (!arg) continue; var argType = typeof arg; if (argType === 'string' || argType === 'number') { classes.push(arg); } else if (Array.isArray(arg) && arg.length) { var inner = classNames.apply(null, arg); if (inner) { classes.push(inner); } } else if (argType === 'object') { for (var key in arg) { if (hasOwn.call(arg, key) && arg[key]) { classes.push(key); } } } } return classes.join(' '); } if (typeof module !== 'undefined' && module.exports) { classNames.default = classNames; module.exports = classNames; } else if (true) { // register as 'classnames', consistent with npm package name !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function () { return classNames; }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); } else { window.classNames = classNames; } }()); /***/ }), /***/ 59: /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _Icon = __webpack_require__(97); var _Icon2 = _interopRequireDefault(_Icon); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } exports["default"] = _Icon2["default"]; module.exports = exports['default']; /***/ }), /***/ 97: /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _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; }; var _react = __webpack_require__(0); var _react2 = _interopRequireDefault(_react); var _classnames = __webpack_require__(4); var _classnames2 = _interopRequireDefault(_classnames); var _propTypes = __webpack_require__(1); 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); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; } function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } 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) : _defaults(subClass, superClass); } var propTypes = { type: _propTypes2["default"].string }; /** * badge 默认显示内容1 */ var defaultProps = { clsPrefix: 'uf' }; var Icon = function (_Component) { _inherits(Icon, _Component); function Icon(props) { _classCallCheck(this, Icon); return _possibleConstructorReturn(this, _Component.call(this, props)); } Icon.prototype.render = function render() { var _props = this.props, type = _props.type, className = _props.className, clsPrefix = _props.clsPrefix, others = _objectWithoutProperties(_props, ['type', 'className', 'clsPrefix']); var clsObj = {}; var classNames = (0, _classnames2["default"])(clsPrefix, type); return _react2["default"].createElement('i', _extends({}, others, { className: (0, _classnames2["default"])(classNames, className) })); }; return Icon; }(_react.Component); Icon.defaultProps = defaultProps; Icon.propTypes = propTypes; exports["default"] = Icon; module.exports = exports['default']; /***/ }) /******/ }); });