Sha256: 9e165cebe86e51c4e58c39962d0420a5541617e2f2021299de654c141c79c535

Contents?: true

Size: 1.77 KB

Versions: 1

Compression:

Stored size: 1.77 KB

Contents

import React from 'react'
import { components } from 'react-select'

import Badge from '../../pb_badge/_badge'
import FormPill from '../../pb_form_pill/_form_pill'
import { SelectValueType } from '../_typeahead'

type Props = {
  data: SelectValueType,
  multiValueTemplate: any,
  pillColor?: "neutral" | "primary" | "neutral" | "success" | "warning" | "error",
  removeProps: any,
  selectProps: any,
}

const MultiValue = (props: Props) => {
  const { removeProps } = props
  const { imageUrl, label } = props.data
  const { dark, multiKit, pillColor } = props.selectProps

  const formPillProps = {
    marginRight: 'xs',
    name: label,
    avatarUrl: '',
    dark,
  }

  if (typeof imageUrl === 'string') formPillProps.avatarUrl = imageUrl

  return (
    <components.MultiValueContainer
        className="text_input_multivalue_container"
        {...props}
    >
      {multiKit === 'badge' &&
        <Badge
            closeProps={removeProps}
            removeIcon
            text={label}
            variant="primary"
        />
      }

      {multiKit !== 'badge' && imageUrl &&
        <FormPill
            avatarUrl={imageUrl}
            closeProps={removeProps}
            color={pillColor}
            dark={dark}
            marginRight="xs"
            name={label}
            size={multiKit === 'smallPill' ? 'small' : ''}
            text=''
            {...props}
        />
      }

      {multiKit !== 'badge' && !imageUrl &&
        <FormPill
            closeProps={removeProps}
            color={pillColor}
            dark={dark}
            marginRight="xs"
            name=''
            size={multiKit === 'smallPill' ? 'small' : ''}
            text={label}
            {...props}
        />
      }
    </components.MultiValueContainer>
  )
}

export default MultiValue

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
playbook_ui-14.1.0.pre.alpha.PBNTR417addcolorsupdatedefaultcolor3608 app/pb_kits/playbook/pb_typeahead/components/MultiValue.tsx