import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
var _excluded = ["content", "hidden"];
import _regeneratorRuntime from "@babel/runtime/regenerator";
import React from 'react';
import { categories } from 'choerodon-ui-font';
import noop from 'lodash/noop';
import { LabelLayout, ShowValidation, LabelAlign, RequiredMarkAlign } from '../../pro/es/form/enum';
import { ColumnAlign, TableQueryBarType, TableColumnResizeTriggerType } from '../../pro/es/table/enum';
import { ButtonColor, FuncType } from '../../pro/es/button/enum';
import { $l } from '../../pro/es/locale-context';
import { defaultExcludeUseColonTag } from '../../pro/es/form/utils';
import { FieldType } from '../../pro/es/data-set/enum';
import { ShowHelp } from '../../pro/es/field/enum';
import getReactNodeText from '../../pro/es/_util/getReactNodeText';
import formatReactTemplate from '../../pro/es/formatter/formatReactTemplate';
import defaultFeedback from '../../pro/es/data-set/FeedBack';
import _confirm from '../../pro/es/modal/confirm';
import { FieldFocusMode, Tooltip } from '../../pro/es/core/enum';
import { Size } from '../_util/enum';
import { Action } from '../trigger/enum';
import Popover from '../popover';

var defaultTooltip = function defaultTooltip(target) {
  switch (target) {
    case 'output':
      return Tooltip.overflow;

    default:
      break;
  }
};

var defaultTooltipTheme = function defaultTooltipTheme(target) {
  return target === 'validation' ? 'light' : 'dark';
};

var defaultRenderEmpty = function defaultRenderEmpty(componentName) {
  switch (componentName) {
    case 'Attachment':
      return $l('Attachment', 'no_attachments');

    case 'Table':
      return $l('Table', 'empty_data');

    case 'Select':
      return $l('Select', 'no_matching_results');

    case 'Output':
      return '';

    default:
  }
};

var defaultFormFieldHighlightRenderer = function defaultFormFieldHighlightRenderer(_ref, element) {
  var content = _ref.content,
      hidden = _ref.hidden,
      rest = _objectWithoutProperties(_ref, _excluded);

  return content ? /*#__PURE__*/React.createElement(Popover, _extends({}, hidden ? _objectSpread(_objectSpread({}, rest), {}, {
    visible: false
  }) : rest, {
    content: content
  }), element) : element;
};

var defaultButtonProps = {
  color: ButtonColor.primary,
  funcType: FuncType.flat
};
var defaultSpinProps = {
  size: Size["default"],
  wrapperClassName: ''
};

var defaultTableColumnAlign = function defaultTableColumnAlign(_column, field, record) {
  if (field) {
    switch (field.get('type', record)) {
      case FieldType.number:
      case FieldType.currency:
      case FieldType.bigNumber:
        return ColumnAlign.right;

      case FieldType["boolean"]:
        return ColumnAlign.center;

      default:
    }
  }
};

function getComponentKey(component) {
  switch (component) {
    case 'Tabs':
      return 'tabs';

    case 'Modal':
      return 'modal';

    default:
      return 'table';
  }
}

var defaultCustomizedSave = function defaultCustomizedSave(code, customized, component) {
  return localStorage.setItem("".concat(getComponentKey(component), ".customized.").concat(code), JSON.stringify(customized));
};

var defaultCustomizedLoad = function defaultCustomizedLoad(code, component) {
  return Promise.resolve(JSON.parse(localStorage.getItem("".concat(getComponentKey(component), ".customized.").concat(code)) || 'null'));
};

var defaultLovShowSelectedInView = function defaultLovShowSelectedInView(viewMode) {
  return viewMode === 'drawer';
};

var defaults = {
  prefixCls: 'c7n',
  proPrefixCls: 'c7n-pro',
  iconfontPrefix: 'icon',
  ripple: true,
  collapseExpandIconPosition: 'left',
  collapseTrigger: 'header',
  lovTableProps: {},
  lovModalProps: {},
  lovAutoSelectSingle: false,
  lovShowSelectedInView: defaultLovShowSelectedInView,
  labelLayout: LabelLayout.horizontal,
  labelAlign: LabelAlign.right,
  queryBar: TableQueryBarType.normal,
  tableBorder: true,
  tableHighLightRow: true,
  tableSelectedHighLightRow: false,
  tableRowHeight: 30,
  tableDefaultRenderer: '',
  tableColumnResizable: true,
  tableColumnHideable: true,
  performanceTableColumnHideable: true,
  tableRowDraggable: false,
  tableColumnDraggable: false,
  tableHeightChangeable: true,
  tablePageSizeChangeable: false,
  performanceTableColumnDraggable: false,
  tableColumnAlign: defaultTableColumnAlign,
  tableSpinProps: defaultSpinProps,
  tableButtonProps: defaultButtonProps,
  tableCommandProps: defaultButtonProps,
  tableAlwaysShowRowBox: false,
  tableUseMouseBatchChoose: false,
  tableEditorNextKeyEnterDown: true,
  tableAutoFocus: false,
  tableKeyboard: false,
  tableFilterSearchText: 'params',
  tableAutoHeightDiff: 80,
  performanceTableAutoHeight: false,
  tableColumnDefaultWidth: 100,
  tableColumnDefaultMinWidth: 50,
  tableColumnResizeTrigger: TableColumnResizeTriggerType.mouseDown,
  tableAggregationColumnDefaultWidth: 250,
  tableAggregationColumnDefaultMinWidth: 50,
  customizedSave: defaultCustomizedSave,
  customizedLoad: defaultCustomizedLoad,
  tableShowRemovedRow: true,
  modalSectionBorder: true,
  drawerHeaderFooterCombined: false,
  drawerSectionBorder: true,
  drawerTransitionName: 'slide-right',
  modalOkFirst: true,
  modalAutoCenter: false,
  modalKeyboard: true,
  modalMaskClosable: false,
  modalMovable: true,
  modalClosable: false,
  buttonColor: ButtonColor["default"],
  buttonFuncType: FuncType.raised,
  autoInsertSpaceInButton: false,
  renderEmpty: defaultRenderEmpty,
  icons: categories,
  dropdownMatchSelectWidth: true,
  defaultActiveFirstOption: true,
  selectReverse: true,
  selectPagingOptionContent: '···',
  selectSearchable: false,
  selectBoxSearchable: false,
  selectReserveParam: true,
  selectTrigger: [Action.focus, Action.click],
  useColon: false,
  requiredMarkAlign: RequiredMarkAlign.left,
  excludeUseColonTagList: defaultExcludeUseColonTag,
  numberFieldNonStrictStep: false,
  showInvalidDate: true,
  highlightRenderer: defaultFormFieldHighlightRenderer,
  onPerformance: noop,
  performanceEnabled: {
    Table: false
  },
  tooltip: defaultTooltip,
  tooltipTheme: defaultTooltipTheme,
  showValidation: ShowValidation.tooltip,
  showHelp: ShowHelp.newLine,
  numberFieldKeyboard: true,
  colorPreset: false,
  feedback: defaultFeedback,
  confirm: function () {
    var _confirm2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(message) {
      return _regeneratorRuntime.wrap(function _callee$(_context) {
        while (1) {
          switch (_context.prev = _context.next) {
            case 0:
              _context.next = 2;
              return _confirm(message);

            case 2:
              _context.t0 = _context.sent;
              return _context.abrupt("return", _context.t0 !== 'cancel');

            case 4:
            case "end":
              return _context.stop();
          }
        }
      }, _callee);
    }));

    function confirm(_x) {
      return _confirm2.apply(this, arguments);
    }

    return confirm;
  }(),
  validationMessageReportFormatter: function validationMessageReportFormatter(message) {
    return getReactNodeText( /*#__PURE__*/React.createElement("span", null, message));
  },
  validationMessageFormatter: function validationMessageFormatter(message, injectOptions) {
    return message && injectOptions ? formatReactTemplate(message, injectOptions) : message;
  },
  modalResizable: false,
  tableColumnResizeTransition: true,
  fieldFocusMode: FieldFocusMode.checked,
  formAutoFocus: false,
  tabsDefaultChangeable: true
};
export default defaults;
//# sourceMappingURL=default.js.map
