search.js 926 B

12345678910111213141516171819202122232425262728293031323334
  1. "use client";
  2. import * as React from 'react';
  3. import SearchOutlined from "@ant-design/icons/es/icons/SearchOutlined";
  4. import Input from '../input/Input';
  5. const Search = props => {
  6. const {
  7. placeholder = '',
  8. value,
  9. prefixCls,
  10. disabled,
  11. onChange,
  12. handleClear
  13. } = props;
  14. const handleChange = React.useCallback(e => {
  15. onChange === null || onChange === void 0 ? void 0 : onChange(e);
  16. if (e.target.value === '') {
  17. handleClear === null || handleClear === void 0 ? void 0 : handleClear();
  18. }
  19. }, [onChange]);
  20. return /*#__PURE__*/React.createElement(Input, {
  21. placeholder: placeholder,
  22. className: prefixCls,
  23. value: value,
  24. onChange: handleChange,
  25. disabled: disabled,
  26. allowClear: true,
  27. prefix: /*#__PURE__*/React.createElement(SearchOutlined, null)
  28. });
  29. };
  30. if (process.env.NODE_ENV !== 'production') {
  31. Search.displayName = 'Search';
  32. }
  33. export default Search;