All files / src/tips EmptyTip.tsx

100% Statements 4/4
66.67% Branches 2/3
100% Functions 1/1
100% Lines 4/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32                              1x 1x 1x 1x                          
import React from "react";
import classNames from "classnames";
import { useTranslation } from "../i18n";
import { StyledProps } from "../_type";
import { useConfig } from "../_util/config-context";
 
export interface EmptyTipProps extends StyledProps {
  /**
   * 空数据提示文案
   * @default "暂无数据"
   */
  emptyText?: React.ReactNode;
}
 
export function EmptyTip(props: EmptyTipProps) {
  const { classPrefix } = useConfig();
  const t = useTranslation();
  const { emptyText = t.emptyText, className, style } = props;
  return (
    <span
      className={classNames(`${classPrefix}-action-state`, className)}
      style={style}
    >
      {typeof emptyText === "string" ? (
        <span className={`${classPrefix}-action-state__text`}>{emptyText}</span>
      ) : (
        emptyText
      )}
    </span>
  );
}