UNPKG

choerodon-ui

Version:

An enterprise-class UI design language and React-based implementation

79 lines (65 loc) 2.2 kB
import _extends from "@babel/runtime/helpers/extends"; import _classCallCheck from "@babel/runtime/helpers/classCallCheck"; import _createClass from "@babel/runtime/helpers/createClass"; import _inherits from "@babel/runtime/helpers/inherits"; import _createSuper from "@babel/runtime/helpers/createSuper"; import React, { Component } from 'react'; import Icon from '../icon'; import Input from '../input'; var Search = /*#__PURE__*/function (_Component) { _inherits(Search, _Component); var _super = _createSuper(Search); function Search() { var _this; _classCallCheck(this, Search); _this = _super.apply(this, arguments); _this.handleChange = function (e) { var onChange = _this.props.onChange; if (onChange) { onChange(e); } }; _this.handleClear = function (e) { e.preventDefault(); var handleClear = _this.props.handleClear; if (handleClear) { handleClear(e); } }; return _this; } _createClass(Search, [{ key: "render", value: function render() { var _this$props = this.props, placeholder = _this$props.placeholder, value = _this$props.value, prefixCls = _this$props.prefixCls, inputProps = _this$props.inputProps; var icon = value && value.length > 0 ? /*#__PURE__*/React.createElement("a", { href: "#", className: "".concat(prefixCls, "-action"), onClick: this.handleClear }, /*#__PURE__*/React.createElement(Icon, { type: "cross-circle" })) : /*#__PURE__*/React.createElement("span", { className: "".concat(prefixCls, "-action") }, /*#__PURE__*/React.createElement(Icon, { type: "search" })); return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Input, _extends({}, inputProps, { placeholder: placeholder, className: prefixCls, value: value, onChange: this.handleChange })), icon); } }]); return Search; }(Component); export { Search as default }; Search.displayName = 'TransferSearch'; Search.defaultProps = { placeholder: '' }; //# sourceMappingURL=search.js.map