UNPKG

frc-ui

Version:

React Web UI

43 lines (42 loc) 1.74 kB
var __rest = (this && this.__rest) || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; }; import React from 'react'; import classNames from 'classnames'; import Select from 'antd/es/select'; import Icon from '../icon'; class SWCSelect extends React.Component { constructor() { super(...arguments); this.saveSelect = (node) => { this.rcSelect = node; }; } focus() { this.rcSelect.focus(); } blur() { this.rcSelect.blur(); } render() { const _a = this.props, { className, showSearch, dropdownClassName, onClear } = _a, other = __rest(_a, ["className", "showSearch", "dropdownClassName", "onClear"]); const cls = classNames('swc-select', className); const dropCls = classNames('swc-select-dropdown', dropdownClassName); if (showSearch) { other.clearIcon = React.createElement(Icon, { className: 'swc-select-clear', type: 'close-square', onClick: onClear }); other.showArrow = false; other.allowClear = true; } return (React.createElement(Select, Object.assign({ ref: this.saveSelect, className: cls, showSearch: !!showSearch, dropdownClassName: dropCls }, other))); } } SWCSelect.SECRET_COMBOBOX_MODE_DO_NOT_USE = 'SECRET_COMBOBOX_MODE_DO_NOT_USE'; export default SWCSelect;