Sha256: 609b6b3deb86c28806190f5c59009963efbce10319a287286dd4f4ffb8f781f8

Contents?: true

Size: 1.57 KB

Versions: 29

Compression:

Stored size: 1.57 KB

Contents

import React from 'react';
import { InputGroup, Button, Icon } from 'patternfly-react';
import PropTypes from 'prop-types';
import { translate as __ } from 'foremanReact/common/I18n';

import TypeAheadInput from './TypeAheadInput';
import TypeAheadItems from './TypeAheadItems';
import keyPressHandler from '../helpers/helpers';
import commonSearchPropTypes from '../helpers/commonPropTypes';

const TypeAheadSearch = ({
  userInputValue, clearSearch, getInputProps, getItemProps, isOpen, inputValue, highlightedIndex,
  selectedItem, selectItem, openMenu, onSearch, items, activeItems, actionText, shouldShowItems,
}) => (
  <div>
    <InputGroup>
      <TypeAheadInput
        onKeyPress={e => keyPressHandler(
          e, isOpen, activeItems, highlightedIndex,
          selectItem, userInputValue, onSearch,
        )}
        onInputFocus={openMenu}
        passedProps={getInputProps()}
      />
      {userInputValue &&
        <InputGroup.Button>
          <Button onClick={clearSearch}>
            <Icon name="times" />
          </Button>
        </InputGroup.Button>
      }
      <InputGroup.Button>
        <Button aria-label="patternfly 3 search button" onClick={() => onSearch(inputValue)}>{actionText}</Button>
      </InputGroup.Button>
    </InputGroup>

    {shouldShowItems && <TypeAheadItems {...{
      items, highlightedIndex, selectedItem, getItemProps, activeItems,
    }}
    />}
  </div>
);

TypeAheadSearch.propTypes = {
  ...commonSearchPropTypes,
  actionText: PropTypes.string,
};

TypeAheadSearch.defaultProps = {
  actionText: __('Search'),
};

export default TypeAheadSearch;

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
katello-4.7.6 webpack/components/TypeAhead/pf3Search/TypeAheadSearch.js
katello-4.7.5 webpack/components/TypeAhead/pf3Search/TypeAheadSearch.js
katello-4.8.0.rc2 webpack/components/TypeAhead/pf3Search/TypeAheadSearch.js
katello-4.7.4 webpack/components/TypeAhead/pf3Search/TypeAheadSearch.js
katello-4.8.0.rc1 webpack/components/TypeAhead/pf3Search/TypeAheadSearch.js
katello-4.7.3 webpack/components/TypeAhead/pf3Search/TypeAheadSearch.js
katello-4.7.2 webpack/components/TypeAhead/pf3Search/TypeAheadSearch.js
katello-4.7.1 webpack/components/TypeAhead/pf3Search/TypeAheadSearch.js
katello-4.6.2.1 webpack/components/TypeAhead/pf3Search/TypeAheadSearch.js
katello-4.6.2 webpack/components/TypeAhead/pf3Search/TypeAheadSearch.js
katello-4.7.0 webpack/components/TypeAhead/pf3Search/TypeAheadSearch.js
katello-4.6.1 webpack/components/TypeAhead/pf3Search/TypeAheadSearch.js
katello-4.7.0.rc2 webpack/components/TypeAhead/pf3Search/TypeAheadSearch.js
katello-4.7.0.rc1 webpack/components/TypeAhead/pf3Search/TypeAheadSearch.js
katello-4.4.2.2 webpack/components/TypeAhead/pf3Search/TypeAheadSearch.js
katello-4.4.2.1 webpack/components/TypeAhead/pf3Search/TypeAheadSearch.js
katello-4.4.2 webpack/components/TypeAhead/pf3Search/TypeAheadSearch.js
katello-4.5.1 webpack/components/TypeAhead/pf3Search/TypeAheadSearch.js
katello-4.6.0 webpack/components/TypeAhead/pf3Search/TypeAheadSearch.js
katello-4.6.0.rc2 webpack/components/TypeAhead/pf3Search/TypeAheadSearch.js