All files / src/components/ll_tabs ll_tabs.tsx

90.91% Statements 10/11
80% Branches 4/5
100% Functions 3/3
100% Lines 10/10

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 39 40 41 42 43 44              4x     9x     9x 8x 6x 16x 16x             2x     9x                         4x      
import React from 'react';
import cls from 'classnames';
import {Radio, RadioGroupProps} from 'antd';
import './ll_tabs.less';
 
export interface LLTabsProps extends RadioGroupProps {}
 
const {Button} = Radio;
 
function LLTabs(props: LLTabsProps) {
  const {options, className, children, size = 'middle'} = props;
 
  /* 子项渲染 */
  const finalChildren = React.useMemo(() => {
    if (options) {
      return options.map(item => {
        Iif (typeof item === 'string') return null;
        return (
          <Radio.Button key={item.value as string} value={item.value} disabled={item.disabled}>
            {item.label}
          </Radio.Button>
        );
      });
    }
    return children;
  }, [options]);
 
  return (
    <Radio.Group
      {...props}
      className={cls(className, 'll-tabs', `ll-tabs-${size}`)}
      options={undefined}
      size={undefined}
      buttonStyle={undefined}
    >
      {finalChildren}
    </Radio.Group>
  );
}
 
LLTabs.Button = Button;
 
export default LLTabs;