var _excluded = ["topContent", "bottomContent", "wrapperStyle", "wrapperClassName", "allowClear", "onClear", "value", "clearButtonStyle"];
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
import React, { forwardRef, useImperativeHandle, useRef } from 'react';
import classNames from 'classnames';
import Icon from "../icon";
import BaseVirtualInput from "./BaseVirtualInput";
import "./index.less";
export { BaseVirtualInputProps, BaseVirtualInputRef } from "./BaseVirtualInput";
var VirtualInput = /*#__PURE__*/forwardRef(function (_ref, ref) {
  var topContent = _ref.topContent,
    bottomContent = _ref.bottomContent,
    wrapperStyle = _ref.wrapperStyle,
    wrapperClassName = _ref.wrapperClassName,
    _ref$allowClear = _ref.allowClear,
    allowClear = _ref$allowClear === void 0 ? false : _ref$allowClear,
    onClear = _ref.onClear,
    value = _ref.value,
    clearButtonStyle = _ref.clearButtonStyle,
    virtualInputProps = _objectWithoutProperties(_ref, _excluded);
  var baseInputRef = useRef(null);

  // 处理清除操作
  var handleClear = function handleClear() {
    // 全部清除
    onClear === null || onClear === void 0 || onClear();
  };

  // 暴露给父组件的方法
  useImperativeHandle(ref, function () {
    return {
      focus: function focus() {
        var _baseInputRef$current;
        return (_baseInputRef$current = baseInputRef.current) === null || _baseInputRef$current === void 0 ? void 0 : _baseInputRef$current.focus();
      },
      blur: function blur() {
        var _baseInputRef$current2;
        return (_baseInputRef$current2 = baseInputRef.current) === null || _baseInputRef$current2 === void 0 ? void 0 : _baseInputRef$current2.blur();
      }
    };
  });
  return /*#__PURE__*/React.createElement("div", {
    className: classNames('pisell-virtual-input-wrapper', wrapperClassName),
    style: wrapperStyle
  }, topContent, /*#__PURE__*/React.createElement("div", {
    className: "pisell-virtual-input-container"
  }, /*#__PURE__*/React.createElement(BaseVirtualInput, _extends({
    ref: baseInputRef,
    value: value
  }, virtualInputProps)), allowClear && /*#__PURE__*/React.createElement("div", {
    className: "pisell-virtual-input-clear-button",
    onClick: handleClear,
    style: clearButtonStyle
  }, /*#__PURE__*/React.createElement(Icon, {
    type: "pisell2-delete"
  }))), bottomContent);
});
VirtualInput.displayName = 'VirtualInput';
export default VirtualInput;