// Copyright (C) 2021, Mindee. // This program is licensed under the Apache License version 2. // See LICENSE or go to for full license details. import React from "react"; import { Box, CircularProgress, Grid, makeStyles, Theme, Typography, } from "@material-ui/core"; import { Card } from "@mindee/web-elements.ui.card"; import { Word } from "src/common/types"; import { COLORS, FONTS } from "@mindee/web-elements.assets"; const COMPONENT_ID = "WordsList"; const useStyles = makeStyles((theme: Theme) => ({ wrapper: { height: "100%", }, list: { overflow: "hidden auto", height: "465px", width: "100%", }, item: { width: "100%", padding: 20, cursor: "pointer", borderBottom: `1px solid ${theme.palette.grey[100]}`, borderLeft: "3px solid transparent", "&:hover": { borderLeftWidth: 8, }, }, loader: { margin: "auto", }, })); interface Props { words: Word[]; extractingWords: boolean; onFieldMouseLeave: (word: Word) => void; onFieldMouseEnter: (word: Word) => void; fieldRefsObject: any[]; } export default function WordsList({ words, onFieldMouseEnter, onFieldMouseLeave, extractingWords, fieldRefsObject, }: Props): JSX.Element { const classes = useStyles(); return ( 4 - Visualize word values {words.length ? `${words.length} words identified` : ""} } contentStyle={{ paddingTop: 20, }} id={COMPONENT_ID} className={classes.wrapper} > {!extractingWords && !words.length && ( No image uploaded yet )} {extractingWords ? ( ) : ( words.map((word, key) => ( onFieldMouseEnter(word)} onMouseLeave={() => onFieldMouseLeave(word)} className={classes.item} key={key} item ref={fieldRefsObject[key]} xs={12} style={{ borderLeftColor: word.color, borderLeftWidth: word.isActive ? 8 : undefined, }} > {word.words.join(", ")} )) )} ); }