UNPKG

choerodon-ui

Version:

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

110 lines (89 loc) 2.83 kB
import _classCallCheck from "@babel/runtime/helpers/classCallCheck"; import _createClass from "@babel/runtime/helpers/createClass"; import _inherits from "@babel/runtime/helpers/inherits"; import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn"; import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf"; function _createSuper(Derived) { function isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } return function () { var Super = _getPrototypeOf(Derived), result; if (isNativeReflectConstruct()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } 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; var icon = value && value.length > 0 ? React.createElement("a", { href: "#", className: "".concat(prefixCls, "-action"), onClick: this.handleClear }, React.createElement(Icon, { type: "cross-circle" })) : React.createElement("span", { className: "".concat(prefixCls, "-action") }, React.createElement(Icon, { type: "search" })); return React.createElement("div", null, React.createElement(Input, { placeholder: placeholder, className: prefixCls, value: value, onChange: this.handleChange }), icon); } }]); return Search; }(Component); export { Search as default }; Search.defaultProps = { placeholder: '' }; //# sourceMappingURL=search.js.map