"use strict";

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); }

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var React = _interopRequireWildcard(require("react"));

var _one = require("remax/one");

var _common = require("./../common");

var _utils = require("./../_utils");

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

/*
 * @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
 */
var prefixCls = (0, _common.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(_one.Image, {
      src: image,
      mode: "widthFix"
    });
  };

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

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

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

var _default = Empty;
exports.default = _default;