All files / src/components/ll_popconfirm index.tsx

25% Statements 2/8
0% Branches 0/2
0% Functions 0/2
25% Lines 2/8

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          4x           4x                                                        
import React, {ReactNode} from 'react';
import {Popconfirm, PopconfirmProps} from 'antd';
import scopedClasses from '../../utils/scopedClasses';
import './index.less';
 
const sc = scopedClasses('ll-popconfirm');
 
export interface LLPopconfirmProps extends PopconfirmProps {
  description?: ReactNode;
}
 
const LLPopconfirm = (props: LLPopconfirmProps) => {
  const {children, title, description, ...rest} = props;
 
  const isolateTitle = (() => {
    if (typeof title === 'function') {
      return (
        <div className={sc()}>
          {title()}
          <div className={sc('description')}>{description}</div>
        </div>
      );
    }
    return (
      <div className={sc()}>
        <div className={sc('title')}>{title}</div>
        <div className={sc('description')}>{description}</div>
      </div>
    );
  })();
 
  return (
    <Popconfirm title={isolateTitle} {...rest}>
      {children}
    </Popconfirm>
  );
};
 
export default LLPopconfirm;