Sha256: 1ec51d65e9c30dc871d1c0f788307cbf03eb541dcf55ada9f5f51e27a4c11c4b

Contents?: true

Size: 1.4 KB

Versions: 17

Compression:

Stored size: 1.4 KB

Contents

/* @flow */

import React from 'react'
import Select from 'react-select'
import AsyncSelect from 'react-select/async'

import Control from './components/Control'
import IndicatorsContainer from './components/IndicatorsContainer'
import MenuList from './components/MenuList'
import MultiValue from './components/MultiValue'
import Option from './components/Option'
import Placeholder from './components/Placeholder'
import ValueContainer from './components/ValueContainer'

/**
 * @typedef {object} Props
 * @prop {boolean} async - whether Typeahead should fetch data from
 * a remote location to populate the options
 * @prop {string} label - the text for the optional typeahead input label
 */

type Props = {
  async?: boolean,
  label?: string,
}

/**
 * @constant {React.ReactComponent} Typeahead
 * @param {Props} props - props as described at https://react-select.com/props
 */

const Typeahead = (props: Props) => {
  const selectProps = {
    cacheOptions: true,
    defaultOptions: true,
    components: {
      Control,
      IndicatorsContainer,
      IndicatorSeparator: null,
      MenuList,
      MultiValue,
      Option,
      Placeholder,
      ValueContainer,
    },
    isClearable: true,
    isSearchable: true,
    ...props,
  }

  const Tag = props.async ? AsyncSelect : Select

  return (
    <div className="pb_typeahead_kit react-select">
      <Tag {...selectProps} />
    </div>
  )
}

export default Typeahead

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
playbook_ui-7.3.0.pre.alpha2 app/pb_kits/playbook/pb_typeahead/_typeahead.jsx
playbook_ui-7.0.1 app/pb_kits/playbook/pb_typeahead/_typeahead.jsx
playbook_ui-6.8.2.pre.alpha1 app/pb_kits/playbook/pb_typeahead/_typeahead.jsx
playbook_ui-7.0.0.pre.alpha15 app/pb_kits/playbook/pb_typeahead/_typeahead.jsx
playbook_ui-7.0.1.pre.alpha14 app/pb_kits/playbook/pb_typeahead/_typeahead.jsx
playbook_ui-7.0.0.pre.alpha14 app/pb_kits/playbook/pb_typeahead/_typeahead.jsx
playbook_ui-7.0.0.pre.alpha13 app/pb_kits/playbook/pb_typeahead/_typeahead.jsx
playbook_ui-7.0.0.pre.alpha12 app/pb_kits/playbook/pb_typeahead/_typeahead.jsx
playbook_ui-7.0.0 app/pb_kits/playbook/pb_typeahead/_typeahead.jsx
playbook_ui-7.0.0.pre.alpha11 app/pb_kits/playbook/pb_typeahead/_typeahead.jsx
playbook_ui-6.8.1 app/pb_kits/playbook/pb_typeahead/_typeahead.jsx
playbook_ui-6.8.0 app/pb_kits/playbook/pb_typeahead/_typeahead.jsx
playbook_ui-6.7.0.pre.alpha1 app/pb_kits/playbook/pb_typeahead/_typeahead.jsx
playbook_ui-6.7.0 app/pb_kits/playbook/pb_typeahead/_typeahead.jsx
playbook_ui-6.6.1 app/pb_kits/playbook/pb_typeahead/_typeahead.jsx
playbook_ui-7.0.0.pre.alpha10 app/pb_kits/playbook/pb_typeahead/_typeahead.jsx
playbook_ui-6.6.0 app/pb_kits/playbook/pb_typeahead/_typeahead.jsx