Sha256: b0d84875a97400d6652664a19552135503ee5331b802440cdf4188a8054d706c

Contents?: true

Size: 898 Bytes

Versions: 25

Compression:

Stored size: 898 Bytes

Contents

/* @flow */

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

import {
  User,
} from '../../'

const Option = (props: any) => {
  const {
    imageUrl,
    label,
  } = props.data

  const handleOptionClicked = () => {
    const resultSelectedEvent = new CustomEvent('pb-typeahead-kit-result-option-select', { detail: props.data })
    document.dispatchEvent(resultSelectedEvent)
  }

  return (
    <components.Option {...props}>
      <div onClick={handleOptionClicked}>
        <Choose>
          <When condition={imageUrl}>
            <User
                align="left"
                avatarUrl={imageUrl}
                name={label}
                orientation="horizontal"
            />
          </When>
          <When condition={!imageUrl}>
            {label}
          </When>
        </Choose>
      </div>
    </components.Option>
  )
}

export default Option

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
playbook_ui-7.4.0.pre.alpha6 app/pb_kits/playbook/pb_typeahead/components/Option.jsx
playbook_ui-7.4.0.pre.test2 app/pb_kits/playbook/pb_typeahead/components/Option.jsx
playbook_ui-7.4.0.pre.alpha4 app/pb_kits/playbook/pb_typeahead/components/Option.jsx
playbook_ui-7.4.0.pre.alpha2 app/pb_kits/playbook/pb_typeahead/components/Option.jsx
playbook_ui-7.4.0.pre.alpha1 app/pb_kits/playbook/pb_typeahead/components/Option.jsx
playbook_ui-7.3.0.pre.alpha12 app/pb_kits/playbook/pb_typeahead/components/Option.jsx
playbook_ui-7.3.0 app/pb_kits/playbook/pb_typeahead/components/Option.jsx
playbook_ui-7.3.0.pre.alpha11 app/pb_kits/playbook/pb_typeahead/components/Option.jsx
playbook_ui-7.3.0.pre.alpha10 app/pb_kits/playbook/pb_typeahead/components/Option.jsx
playbook_ui-7.3.0.pre.alpha9 app/pb_kits/playbook/pb_typeahead/components/Option.jsx
playbook_ui-7.3.0.pre.alpha8 app/pb_kits/playbook/pb_typeahead/components/Option.jsx
playbook_ui-7.3.0.pre.alpha7 app/pb_kits/playbook/pb_typeahead/components/Option.jsx
playbook_ui-7.3.0.pre.alpha6 app/pb_kits/playbook/pb_typeahead/components/Option.jsx
playbook_ui-7.3.0.pre.alpha5 app/pb_kits/playbook/pb_typeahead/components/Option.jsx
playbook_ui-7.3.0.pre.alpha4 app/pb_kits/playbook/pb_typeahead/components/Option.jsx
playbook_ui-7.3.0.pre.alpha3 app/pb_kits/playbook/pb_typeahead/components/Option.jsx
playbook_ui-7.3.0.pre.alpha1 app/pb_kits/playbook/pb_typeahead/components/Option.jsx
playbook_ui-7.2.0 app/pb_kits/playbook/pb_typeahead/components/Option.jsx
playbook_ui-7.1.2 app/pb_kits/playbook/pb_typeahead/components/Option.jsx
playbook_ui-7.1.0.pre.alpha2 app/pb_kits/playbook/pb_typeahead/components/Option.jsx