import React, { Component } from 'react'; import List from '@material-ui/core/List'; import { DetailContextConsumer } from '../../pages/version/Version'; import { Heading, DistListItem, DistChips } from './styles'; import fileSizeSI from '../../utils/file-size'; class Dist extends Component { public render(): JSX.Element { return ( {(context: any) => { return this.renderDist(context); }} ); } private renderChips(dist: any, license: string): JSX.Element | never[] { const distDict = { 'file-count': dist.fileCount, size: dist.unpackedSize && fileSizeSI(dist.unpackedSize), license, }; const chipsList = Object.keys(distDict).reduce((componentList, title, key) => { // @ts-ignore const value = distDict[title]; if (value) { const label = ( {/* eslint-disable-next-line */} {title.split('-').join(' ')}:{value} ); // @ts-ignore is not assignable to parameter of type 'never' componentList.push(); } return componentList; }, []); return chipsList; } private renderDist = ({ packageMeta }: any) => { const { dist = {}, license } = packageMeta.latest; return ( {'Latest Distribution'}}> {this.renderChips(dist, license)} ); }; } export default Dist;