1 | "use client";
|
2 |
|
3 | var __rest = this && this.__rest || function (s, e) {
|
4 | var t = {};
|
5 | for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
6 | if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
7 | if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
8 | }
|
9 | return t;
|
10 | };
|
11 | import classNames from 'classnames';
|
12 | import * as React from 'react';
|
13 | import { ConfigContext } from '../config-provider';
|
14 | import { useLocale } from '../locale';
|
15 | import DefaultEmptyImg from './empty';
|
16 | import SimpleEmptyImg from './simple';
|
17 | import useStyle from './style';
|
18 | const defaultEmptyImg = React.createElement(DefaultEmptyImg, null);
|
19 | const simpleEmptyImg = React.createElement(SimpleEmptyImg, null);
|
20 | const Empty = _a => {
|
21 | var {
|
22 | className,
|
23 | rootClassName,
|
24 | prefixCls: customizePrefixCls,
|
25 | image = defaultEmptyImg,
|
26 | description,
|
27 | children,
|
28 | imageStyle,
|
29 | style
|
30 | } = _a,
|
31 | restProps = __rest(_a, ["className", "rootClassName", "prefixCls", "image", "description", "children", "imageStyle", "style"]);
|
32 | const {
|
33 | getPrefixCls,
|
34 | direction,
|
35 | empty
|
36 | } = React.useContext(ConfigContext);
|
37 | const prefixCls = getPrefixCls('empty', customizePrefixCls);
|
38 | const [wrapCSSVar, hashId, cssVarCls] = useStyle(prefixCls);
|
39 | const [locale] = useLocale('Empty');
|
40 | const des = typeof description !== 'undefined' ? description : locale === null || locale === void 0 ? void 0 : locale.description;
|
41 | const alt = typeof des === 'string' ? des : 'empty';
|
42 | let imageNode = null;
|
43 | if (typeof image === 'string') {
|
44 | imageNode = React.createElement("img", {
|
45 | alt: alt,
|
46 | src: image
|
47 | });
|
48 | } else {
|
49 | imageNode = image;
|
50 | }
|
51 | return wrapCSSVar( React.createElement("div", Object.assign({
|
52 | className: classNames(hashId, cssVarCls, prefixCls, empty === null || empty === void 0 ? void 0 : empty.className, {
|
53 | [`${prefixCls}-normal`]: image === simpleEmptyImg,
|
54 | [`${prefixCls}-rtl`]: direction === 'rtl'
|
55 | }, className, rootClassName),
|
56 | style: Object.assign(Object.assign({}, empty === null || empty === void 0 ? void 0 : empty.style), style)
|
57 | }, restProps), React.createElement("div", {
|
58 | className: `${prefixCls}-image`,
|
59 | style: imageStyle
|
60 | }, imageNode), des && React.createElement("div", {
|
61 | className: `${prefixCls}-description`
|
62 | }, des), children && React.createElement("div", {
|
63 | className: `${prefixCls}-footer`
|
64 | }, children)));
|
65 | };
|
66 | Empty.PRESENTED_IMAGE_DEFAULT = defaultEmptyImg;
|
67 | Empty.PRESENTED_IMAGE_SIMPLE = simpleEmptyImg;
|
68 | if (process.env.NODE_ENV !== 'production') {
|
69 | Empty.displayName = 'Empty';
|
70 | }
|
71 | export default Empty; |
\ | No newline at end of file |