<commit_before>import React from 'react'
import {FormattedValue} from 'tocco-ui'

const customTypeMap = {
  'document': 'document-compact',
  'binary': 'document-compact'
}

const getOptions = (type, intl) => {
  switch (type) {
    case 'document-compact':
      return {
        downloadTitle: intl.formatMessage({id: 'client.component.upload.downloadTitle'})
      }
  }

  return null
}

const formattedValueCustomTypeMapper = type => customTypeMap[type] ? customTypeMap[type] : type

export const MultiSeparator = () => ', '

export default (fieldDefinition, entity, intl) => {
  const {id} = fieldDefinition
  const contents = Array.isArray(entity[id]) ? entity[id] : [entity[id]]

  return contents.length > 0
    ? <span key={id} style={{marginRight: '2px'}}>
      {
        contents
          .map((content, idx) => {
            const {type, value} = content
            const mappedType = formattedValueCustomTypeMapper(type)
            const options = getOptions(mappedType, intl)
            return <FormattedValue key={idx} type={mappedType} value={value} {...(options ? {options} : {})}/>
          })
          .reduce((prev, curr, idx) => [prev, <MultiSeparator key={idx}/>, curr])
      }
    </span>
    : null<commit_msg>fix(entity-list): add unique key to avoid react warnings<commit_after>import React from 'react'
import {FormattedValue} from 'tocco-ui'

const customTypeMap = {
  'document': 'document-compact',
  'binary': 'document-compact'
}

const getOptions = (type, intl) => {
  switch (type) {
    case 'document-compact':
      return {
        downloadTitle: intl.formatMessage({id: 'client.component.upload.downloadTitle'})
      }
  }

  return null
}

const formattedValueCustomTypeMapper = type => customTypeMap[type] ? customTypeMap[type] : type

export const MultiSeparator = () => ', '

export default (fieldDefinition, entity, intl) => {
  const {id} = fieldDefinition
  const contents = Array.isArray(entity[id]) ? entity[id] : [entity[id]]

  return contents.length > 0
    ? <span key={id} style={{marginRight: '2px'}}>
      {
        contents
          .map((content, idx) => {
            const {type, value} = content
            const mappedType = formattedValueCustomTypeMapper(type)
            const options = getOptions(mappedType, intl)
            return <FormattedValue key={idx} type={mappedType} value={value} {...(options ? {options} : {})}/>
          })
          .reduce((prev, curr, idx) => [prev, <MultiSeparator key={`ms-${idx}`}/>, curr])
      }
    </span>
    : null
{'fraction_non_alphanumeric': 0.14899487583760346, 'fraction_numerical': 0.0015766653527788726, 'mean_word_length': 3.1335504885993486, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2009716', 'n_tokens_mistral': 776, 'n_tokens_neox': 770, 'n_words': 180}