All files / src/tabs TabPanel.tsx

100% Statements 2/2
0% Branches 0/1
100% Functions 1/1
100% Lines 2/2

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 33 34 35 36 37 38                                                      25x 25x                  
import React from "react";
import classNames from "classnames";
import { StyledProps } from "../_type";
import { useConfig } from "../_util/config-context";
 
export interface TabPanelProps extends StyledProps {
  /**
   * 选项卡 ID
   */
  id: string;
 
  /**
   * 选项卡内容
   */
  children?: React.ReactNode;
 
  /**
   * 未激活时是否强制渲染
   * @default false
   */
  forceRender?: boolean;
}
 
/**
 * TabPanel 应该用在 Tabs 内部,如果单独使用,会直接渲染其 children
 */
export function TabPanel({ children, className, style = {} }: TabPanelProps) {
  const { classPrefix } = useConfig();
  return (
    <div
      className={classNames(`${classPrefix}-tabs__tabpanel`, className)}
      style={{ ...style, flexShrink: 0 }}
    >
      {children}
    </div>
  );
}