import React, { useCallback } from 'react';
import classNames from 'classnames';
import IconFont from "../iconfont";
import { getText } from "../../locales";
import "./PisellExport.less";

/** 默认导出图标（download-cloud-01） */
var DEFAULT_ICON_TYPE = 'pisell2-download-cloud-01';

/**
 * PisellExport 导出触发器组件
 *
 * @description 仅负责 UI 展示与点击回调，不内置导出逻辑；支持 Icon/Button 两种形态与三种尺寸
 */
export function PisellExport(props) {
  var _props$variant = props.variant,
    variant = _props$variant === void 0 ? 'button' : _props$variant,
    _props$size = props.size,
    size = _props$size === void 0 ? 'medium' : _props$size,
    _props$type = props.type,
    type = _props$type === void 0 ? 'default' : _props$type,
    _props$disabled = props.disabled,
    disabled = _props$disabled === void 0 ? false : _props$disabled,
    label = props.label,
    icon = props.icon,
    onExport = props.onExport,
    className = props.className,
    style = props.style;
  var displayLabel = label !== undefined ? label : getText('pisell-export-button-label');
  var iconNode = icon !== undefined ? icon : /*#__PURE__*/React.createElement(IconFont, {
    type: DEFAULT_ICON_TYPE,
    className: "pisell-export-icon",
    style: {
      fontSize: 20,
      width: 20,
      height: 20,
      display: 'inline-flex',
      alignItems: 'center',
      justifyContent: 'center'
    }
  });
  var handleClick = useCallback(function (e) {
    if (disabled) return;
    onExport === null || onExport === void 0 || onExport(e);
  }, [disabled, onExport]);
  var rootClass = classNames('pisell-export', "pisell-export--".concat(variant), "pisell-export--".concat(size), "pisell-export--".concat(type), disabled && 'pisell-export--disabled', className);
  return /*#__PURE__*/React.createElement("button", {
    type: "button",
    className: rootClass,
    style: style,
    disabled: disabled,
    onClick: handleClick,
    "aria-label": typeof displayLabel === 'string' ? displayLabel : undefined
  }, /*#__PURE__*/React.createElement("span", {
    className: "pisell-export-icon-wrap"
  }, iconNode), variant === 'button' && /*#__PURE__*/React.createElement("span", {
    className: "pisell-export-label"
  }, displayLabel));
}