/*
 * @Author: codingfly
 * @Description:
 * @Date: 2021-08-13 15:39:29
 * @LastEditTime: 2021-10-11 16:33:25
 * @FilePath: \ui_model\src\components\empty\index.tsx
 */
import * as React from 'react';
import { View, Image, Text } from 'remax/one';
import { getPrefixCls } from './../common';
import { getSizeStyle } from './../_utils';
var prefixCls = getPrefixCls('empty');
var PRESET_IMAGES = ['error', 'search', 'default'];

var Empty = function Empty(props) {
  var imageSize = props.imageSize,
      description = props.description,
      slots = props.slots;

  var renderImage = function renderImage() {
    var _props$image = props.image,
        image = _props$image === void 0 ? 'default' : _props$image;

    if (PRESET_IMAGES.includes(image)) {
      image = "/image/empty-image-".concat(image, ".png");
    }

    return /*#__PURE__*/React.createElement(Image, {
      src: image,
      mode: "widthFix"
    });
  };

  var renderDescription = function renderDescription() {
    if (description) {
      return /*#__PURE__*/React.createElement(Text, {
        className: "".concat(prefixCls, "-description")
      }, description);
    }
  };

  var renderBottom = function renderBottom() {
    if (slots) {
      return /*#__PURE__*/React.createElement(View, {
        className: "".concat(prefixCls, "-bottom")
      }, slots);
    }
  };

  return /*#__PURE__*/React.createElement(View, {
    className: prefixCls
  }, /*#__PURE__*/React.createElement(View, {
    className: "".concat(prefixCls, "-image"),
    style: getSizeStyle(imageSize)
  }, renderImage()), renderDescription(), renderBottom());
};

export default Empty;