import React, { useContext } from 'react';
import { CaretDownOutlined } from '@wii/icons';
import Space from '../space';
import ConfigProvider from '../config-provider';
import { useIntl } from '../wau-provider';
import { omitBoolean } from '../utils';
import { jsx as _jsx } from "react/jsx-runtime";
import { Fragment as _Fragment } from "react/jsx-runtime";
import { jsxs as _jsxs } from "react/jsx-runtime";
const defaultCollapseRender = (collapsed, _, intl) => {
  if (collapsed) {
    return /*#__PURE__*/_jsxs(_Fragment, {
      children: [intl.getMessage('tableForm.collapsed', '展开'), /*#__PURE__*/_jsx(CaretDownOutlined, {
        style: {
          marginLeft: '0.5em',
          transition: '0.3s all',
          transform: `rotate(${collapsed ? 0 : 0.5}turn)`
        }
      })]
    });
  }
  return /*#__PURE__*/_jsxs(_Fragment, {
    children: [intl.getMessage('tableForm.expand', '收起'), /*#__PURE__*/_jsx(CaretDownOutlined, {
      style: {
        marginLeft: '0.5em',
        transition: '0.3s all',
        transform: `rotate(${collapsed ? 0 : 0.5}turn)`
      }
    })]
  });
};

/**
 * FormFooter 的组件，可以自动进行一些配置
 *
 * @param props
 */
const Actions = props => {
  const {
    setCollapsed,
    collapsed = false,
    collapseRender = defaultCollapseRender,
    submitter,
    style
  } = props;
  const {
    getPrefixCls
  } = useContext(ConfigProvider.ConfigContext);
  const intl = useIntl();
  return /*#__PURE__*/_jsxs(Space, {
    style: style,
    size: 16,
    children: [submitter, collapseRender !== false && omitBoolean(collapseRender) && /*#__PURE__*/_jsx("a", {
      className: getPrefixCls('pro-form-collapse-button'),
      onClick: () => setCollapsed(!collapsed),
      children: collapseRender === null || collapseRender === void 0 ? void 0 : collapseRender(collapsed, props, intl)
    })]
  });
};
export default Actions;