/**
 * @title: 添加按钮,  两种状态切换
 * @description:
 * @return {*}
 * @Author: zhiwei.Wang
 * @Date: 2024-01-30 16:42
 */

import React from "react";
import ChevronRight from "@pisell/icon/es/ChevronRight";
import PlusCircle from "@pisell/icon/es/PlusCircle";
import "./index.less";
import classNames from "classnames";
import { message, Skeleton } from "antd";
import { isFunction, locales } from "@pisell/utils";
var AddButton = function AddButton(_ref) {
  var onClick = _ref.onClick,
    showSub = _ref.showSub,
    title = _ref.title,
    subTitle = _ref.subTitle,
    style = _ref.style,
    disabled = _ref.disabled,
    loading = _ref.loading,
    _ref$showDisabledMess = _ref.showDisabledMessage,
    showDisabledMessage = _ref$showDisabledMess === void 0 ? true : _ref$showDisabledMess;
  var _onClick = function _onClick() {
    // 禁止点击则 提示先创建客户
    if (disabled) {
      if (showDisabledMessage) {
        message.warning(locales.getText("pisell2.text.please-select-the-customer-first"));
      }
    } else {
      onClick === null || onClick === void 0 || onClick();
    }
  };

  // loading  显示骨架片
  if (loading) {
    return /*#__PURE__*/React.createElement(Skeleton, {
      style: {
        marginTop: 16
      },
      loading: true,
      round: true,
      active: true
    });
  }
  return /*#__PURE__*/React.createElement(React.Fragment, null, showSub ? /*#__PURE__*/React.createElement("div", {
    className: "pisell-lowcode__booking-add-button-add-row",
    onClick: _onClick,
    style: isFunction(style) ? style(showSub) : style
  }, /*#__PURE__*/React.createElement(PlusCircle, {
    className: "pisell-lowcode__booking-add-button-add-row-icon"
  }), /*#__PURE__*/React.createElement("span", {
    className: "pisell-lowcode__booking-add-button-add-row-txt"
  }, subTitle)) : /*#__PURE__*/React.createElement("div", {
    className: classNames("pisell-lowcode__booking-add-button-add", {
      "pisell-lowcode__booking-add-button-add-disabled": disabled
    }),
    onClick: _onClick,
    style: isFunction(style) ? style(showSub) : style
  }, /*#__PURE__*/React.createElement("span", {
    className: "pisell-lowcode__booking-add-button-add-label"
  }, title), /*#__PURE__*/React.createElement(ChevronRight, {
    className: "pisell-lowcode__booking-add-button-add-icon"
  })));
};
export default AddButton;