import IconClear from "./IconClear";

// 渲染清除按钮
function getClearNode(_ref) {
  var clear = _ref.clear,
    allowClear = _ref.allowClear,
    disabled = _ref.disabled,
    readOnly = _ref.readOnly,
    value = _ref.value,
    onClear = _ref.onClear;
  // 禁用时不显示清空按钮
  if (disabled || readOnly) return null;
  var clearable = allowClear && (value || typeof value === 'number') ? true : false;

  // 自定义渲染清空按钮
  if (typeof clear === 'function') {
    var clearNode = clear({
      allowClear: allowClear,
      clearable: clearable,
      readOnly: readOnly,
      value: value,
      triggerClear: onClear
    });
    if (clearNode !== undefined) return clearNode;
  }

  // 默认渲染
  if (!clearable) return null;
  return /*#__PURE__*/React.createElement(IconClear, {
    onClick: onClear
  });
}
export default getClearNode;