zent
Version:
一套前端设计语言和基于React的实现
74 lines (56 loc) • 4.05 kB
JavaScript
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);
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; } /**
* Search
*/
var Search = function (_Component) {
_inherits(Search, _Component);
function Search(props) {
_classCallCheck(this, Search);
var _this = _possibleConstructorReturn(this, (Search.__proto__ || Object.getPrototypeOf(Search)).call(this, props));
_this.changeHandler = _this.changeHandler.bind(_this);
return _this;
}
_createClass(Search, [{
key: "changeHandler",
value: function changeHandler(ev) {
this.props.onChange(ev.target.value);
}
}, {
key: "render",
value: function render() {
var _props = this.props,
prefixCls = _props.prefixCls,
placeholder = _props.placeholder,
onFocus = _props.onFocus;
return _react2["default"].createElement(
"div",
{ className: prefixCls + "-search" },
_react2["default"].createElement("input", {
type: "text",
placeholder: placeholder,
className: prefixCls + "-filter",
onChange: this.changeHandler,
onFocus: onFocus
})
);
}
}]);
return Search;
}(_react.Component);
Search.propTypes = {
prefixCls: _react.PropTypes.string,
value: _react.PropTypes.any,
placeholder: _react.PropTypes.string,
onFocus: _react.PropTypes.func
};
exports["default"] = Search;
module.exports = exports["default"];
;