76 lines
3.4 KiB
JavaScript
76 lines
3.4 KiB
JavaScript
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
|
|
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; }
|
|
|
|
var __rest = this && this.__rest || function (s, e) {
|
|
var t = {};
|
|
|
|
for (var p in s) {
|
|
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
}
|
|
|
|
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
}
|
|
return t;
|
|
};
|
|
|
|
import * as React from 'react';
|
|
import classNames from 'classnames';
|
|
import { ConfigConsumer } from '../config-provider';
|
|
import LocaleReceiver from '../locale-provider/LocaleReceiver';
|
|
import DefaultEmptyImg from './empty';
|
|
import SimpleEmptyImg from './simple';
|
|
var defaultEmptyImg = /*#__PURE__*/React.createElement(DefaultEmptyImg, null);
|
|
var simpleEmptyImg = /*#__PURE__*/React.createElement(SimpleEmptyImg, null);
|
|
|
|
var Empty = function Empty(props) {
|
|
return /*#__PURE__*/React.createElement(ConfigConsumer, null, function (_ref) {
|
|
var getPrefixCls = _ref.getPrefixCls,
|
|
direction = _ref.direction;
|
|
|
|
var className = props.className,
|
|
customizePrefixCls = props.prefixCls,
|
|
_props$image = props.image,
|
|
image = _props$image === void 0 ? defaultEmptyImg : _props$image,
|
|
description = props.description,
|
|
children = props.children,
|
|
imageStyle = props.imageStyle,
|
|
restProps = __rest(props, ["className", "prefixCls", "image", "description", "children", "imageStyle"]);
|
|
|
|
return /*#__PURE__*/React.createElement(LocaleReceiver, {
|
|
componentName: "Empty"
|
|
}, function (locale) {
|
|
var _classNames;
|
|
|
|
var prefixCls = getPrefixCls('empty', customizePrefixCls);
|
|
var des = typeof description !== 'undefined' ? description : locale.description;
|
|
var alt = typeof des === 'string' ? des : 'empty';
|
|
var imageNode = null;
|
|
|
|
if (typeof image === 'string') {
|
|
imageNode = /*#__PURE__*/React.createElement("img", {
|
|
alt: alt,
|
|
src: image
|
|
});
|
|
} else {
|
|
imageNode = image;
|
|
}
|
|
|
|
return /*#__PURE__*/React.createElement("div", _extends({
|
|
className: classNames(prefixCls, (_classNames = {}, _defineProperty(_classNames, "".concat(prefixCls, "-normal"), image === simpleEmptyImg), _defineProperty(_classNames, "".concat(prefixCls, "-rtl"), direction === 'rtl'), _classNames), className)
|
|
}, restProps), /*#__PURE__*/React.createElement("div", {
|
|
className: "".concat(prefixCls, "-image"),
|
|
style: imageStyle
|
|
}, imageNode), des && /*#__PURE__*/React.createElement("p", {
|
|
className: "".concat(prefixCls, "-description")
|
|
}, des), children && /*#__PURE__*/React.createElement("div", {
|
|
className: "".concat(prefixCls, "-footer")
|
|
}, children));
|
|
});
|
|
});
|
|
};
|
|
|
|
Empty.PRESENTED_IMAGE_DEFAULT = defaultEmptyImg;
|
|
Empty.PRESENTED_IMAGE_SIMPLE = simpleEmptyImg;
|
|
export default Empty; |