All files / src/layout/SubtabLayout SubtabLayout.js

62.5% Statements 10/16
0% Branches 0/40
25% Functions 1/4
62.5% Lines 10/16

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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165                                                                                                                                                        1x 1x                                                                             1x 1x                                       1x 1x       1x 1x                         1x 1x              
import React from 'react';
import {
  SubtabHeader_propTypes,
  SubtabFooter_propTypes,
  SubtabContent_propTypes,
  SubtabLayout_propTypes
} from './props/propTypes';
import {
  SubtabHeader_defaultProps,
  SubtabFooter_defaultProps,
  SubtabContent_defaultProps,
  SubtabLayout_defaultProps
} from './props/defaultProps';
import { Container, Box } from '@zohodesk/components/lib/Layout';
import { Card, CardHeader, CardContent } from '@zohodesk/components/lib/Card';
import PlusIcon from '../../PlusIcon/PlusIcon';
import style from './SubtabLayout.module.css';
export class SubtabHeader extends React.Component {
  render() {
    let {
      onAdd,
      getLeftPlaceHolder,
      title,
      label,
      getRightPlaceHolder,
      type,
      leftClassName,
      rightClassName,
      className,
      needBorder,
      needShadow,
      needPlusIconLine,
      children,
      dataId,
      isPeekView
    } = this.props;
    return (
      <CardHeader
        customClass={`${style.tabHead} ${needShadow ? style.shadowStyle : ''} ${
          needBorder ? `${style[type]}_borderStyle` : ''
        }`}
      >
        <Container
          alignBox='row'
          className={` ${className} ${isPeekView ? `${style[type]}_peek` : style[type]}`}
          align='vertical'
        >
          {onAdd || children ? (
            <Box className={`${style.left} ${needPlusIconLine ? style.plusIconLine : ''}`}>
              {onAdd ? <PlusIcon dataId={dataId} onClick={onAdd} /> : children}
            </Box>
          ) : null}
          {title ? (
            <Box className={`${style.title} ${onAdd ? style.cursor : ''}`} onClick={onAdd ? onAdd : null}>
              {title}
            </Box>
          ) : null}
          {getLeftPlaceHolder && (
            <Box flexible shrink adjust={getRightPlaceHolder ? true : false} className={leftClassName}>
              {label ? <div className={style.label}>{label}</div> : null}
              {getLeftPlaceHolder}
            </Box>
          )}
          {getRightPlaceHolder && (
            <Box flexible shrink adjust={getLeftPlaceHolder ? true : false} className={rightClassName}>
              <Container alignBox='row' align='vertical' className={style.aside}>
                {getRightPlaceHolder}
              </Container>
            </Box>
          )}
        </Container>
      </CardHeader>
    );
  }
}
 
SubtabHeader.propTypes = SubtabHeader_propTypes;
SubtabHeader.defaultProps = SubtabHeader_defaultProps;
 
export class SubtabFooter extends React.Component {
  render() {
    let {
      isPeekView,
      getRightFooterPlaceHolder,
      dataId,
      children,
      className,
      leftClassName,
      rightClassName,
      size,
      needPadding,
      type
    } = this.props;
    return (
      <Container
        alignBox='row'
        align='vertical'
        className={` ${style.footer}  ${
          needPadding ? (isPeekView ? `${style[type]}_peekFooter` : `${style[type]}_detailFooter`) : ''
        } ${style[size]} ${className}`}
        dataId={dataId}
      >
        {children ? (
          <Box flexible shrink className={leftClassName}>
            {children}
          </Box>
        ) : null}
        {getRightFooterPlaceHolder ? (
          <Box flexible shrink className={rightClassName}>
            {getRightFooterPlaceHolder}
          </Box>
        ) : null}
      </Container>
    );
  }
}
SubtabFooter.propTypes = SubtabFooter_propTypes;
SubtabFooter.defaultProps = SubtabFooter_defaultProps;
 
export class SubtabContent extends React.Component {
  render() {
    let { children, scroll, className, eleRef, dataId, onScroll } = this.props;
    return (
      <CardContent
        scroll={scroll}
        isScrollAttribute
        onScroll={onScroll}
        customClass={className ? className : ''}
        eleRef={eleRef}
        dataId={dataId}
      >
        {children}
      </CardContent>
    );
  }
}
 
SubtabContent.propTypes = SubtabContent_propTypes;
SubtabContent.defaultProps = SubtabContent_defaultProps;
 
export default class SubtabLayout extends React.Component {
  render() {
    let { children, dataId } = this.props;
    return (
      <Card
        isScrollAttribute
        dataId={dataId}
        {...this.props}
        childTypes={{ cardHeader: SubtabHeader, cardContent: SubtabContent }}
      >
        {children}
      </Card>
    );
  }
}
 
SubtabLayout.defaultProps = SubtabLayout_defaultProps;
SubtabLayout.propTypes = SubtabLayout_propTypes;
 
// if (__DOCS__) {
//   SubtabLayout.docs = {
//     componentGroup: 'Template'
//   };
// }