"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _react = _interopRequireDefault(require("react"));

var _antd = require("antd");

var _icons = require("@ant-design/icons");

var _GlobalSearchModule = _interopRequireDefault(require("./GlobalSearch.module.less"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var GlobalSearch = function GlobalSearch(props) {
  var onChange = props.onChange,
      api = props.api;
  var intl = api.intl,
      hooks = api.hooks,
      _ = api._;
  var debounceFn = _.debounce; // compatible with prev version umi ui

  if (hooks === null || hooks === void 0 ? void 0 : hooks.useDebounceFn) {
    debounceFn = hooks.useDebounceFn;
  } // 时间太长会造成卡顿的感觉，200-300 比较合适


  var handleChange = debounceFn(function (value) {
    onChange(value);
  }, 300);
  var handleChangeDebounce = (handleChange === null || handleChange === void 0 ? void 0 : handleChange.run) || handleChange;
  return /*#__PURE__*/_react.default.createElement(_antd.Input, {
    prefix: /*#__PURE__*/_react.default.createElement(_icons.SearchOutlined, null),
    className: _GlobalSearchModule.default.search,
    allowClear: true,
    onChange: function onChange(e) {
      return handleChangeDebounce(e.target.value);
    },
    placeholder: intl({
      id: 'org.umi.ui.blocks.content.search_block'
    })
  });
};

var _default = GlobalSearch;
exports.default = _default;