function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }

import React from 'react';
import { Box } from '@alicloudfe/components';
import ActionButton from '@teamix/pro-actions';

var QuickAction = function QuickAction(props) {
  var quickAction = props.quickAction,
      actionRef = props.actionRef; // 如果传对象的话，默认为主要文字类型的 ActionButton

  if (_typeof(quickAction) === 'object') {
    // 默认 context
    var defaultContext = {
      action: actionRef.current
    };
    return /*#__PURE__*/React.createElement("div", {
      className: "teamix-pro-table-layout-quick-action"
    }, /*#__PURE__*/React.createElement(ActionButton, _objectSpread(_objectSpread({
      type: "primary",
      text: true
    }, quickAction), {}, {
      context: _objectSpread(_objectSpread({}, defaultContext), quickAction.context)
    })));
  }

  if (Array.isArray(quickAction)) {
    return /*#__PURE__*/React.createElement("div", {
      className: "teamix-pro-table-layout-quick-action"
    }, /*#__PURE__*/React.createElement(Box, {
      direction: "row",
      spacing: 8,
      align: "center"
    }, quickAction.map(function (item, index) {
      return /*#__PURE__*/React.createElement("div", {
        key: index
      }, item);
    })));
  }

  return /*#__PURE__*/React.createElement("div", {
    className: "teamix-pro-table-layout-quick-action"
  }, quickAction);
};

export default QuickAction;