Sha256: 689d7233e52a417361eecc48b0f51c2e94a70d6673b0d17db9532ffc869a2652

Contents?: true

Size: 1.86 KB

Versions: 29

Compression:

Stored size: 1.86 KB

Contents

import React from 'react';
import { InputGroup, Button } from '@patternfly/react-core';
import { TimesIcon, SearchIcon } from '@patternfly/react-icons';
import PropTypes from 'prop-types';

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

const TypeAheadSearch = ({
  userInputValue, clearSearch, getInputProps, getItemProps, isOpen, inputValue, highlightedIndex,
  selectedItem, selectItem, openMenu, onSearch, items, activeItems, shouldShowItems,
  autoSearchEnabled,
}) => (
  <React.Fragment>
    <InputGroup>
      <TypeAheadInput
        onKeyPress={
          (e) => {
            keyPressHandler(
              e,
              isOpen,
              activeItems,
              highlightedIndex,
              selectItem,
              userInputValue,
              onSearch,
            );
          }
        }
        onInputFocus={openMenu}
        passedProps={getInputProps()}
        autoSearchEnabled={autoSearchEnabled}
      />
      <React.Fragment>
        {userInputValue &&
          <Button
            variant={autoSearchEnabled ? 'plain' : 'control'}
            className="foreman-pf4-search-clear"
            onClick={clearSearch}
          >
            <TimesIcon />
          </Button>}
      </React.Fragment>
      {!autoSearchEnabled &&
        <Button aria-label="search button" variant="control" onClick={() => onSearch(inputValue)}>
          <SearchIcon />
        </Button>}
    </InputGroup>
    <TypeAheadItems
      isOpen={shouldShowItems}
      {...{
      items, highlightedIndex, selectedItem, getItemProps, activeItems,
    }}
    />
  </React.Fragment>
);

TypeAheadSearch.propTypes = {
  autoSearchEnabled: PropTypes.bool.isRequired,
  ...commonSearchPropTypes,
};

export default TypeAheadSearch;

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
katello-4.2.2 webpack/components/TypeAhead/pf4Search/TypeAheadSearch.js
katello-4.2.1 webpack/components/TypeAhead/pf4Search/TypeAheadSearch.js
katello-4.2.0.1 webpack/components/TypeAhead/pf4Search/TypeAheadSearch.js
katello-4.1.4 webpack/components/TypeAhead/pf4Search/TypeAheadSearch.js
katello-4.0.3 webpack/components/TypeAhead/pf4Search/TypeAheadSearch.js
katello-4.2.0.1.rc3 webpack/components/TypeAhead/pf4Search/TypeAheadSearch.js
katello-4.2.0.1.rc2 webpack/components/TypeAhead/pf4Search/TypeAheadSearch.js
katello-4.2.0.rc2 webpack/components/TypeAhead/pf4Search/TypeAheadSearch.js
katello-4.1.3 webpack/components/TypeAhead/pf4Search/TypeAheadSearch.js
katello-4.2.0.rc1 webpack/components/TypeAhead/pf4Search/TypeAheadSearch.js
katello-4.0.2.1 webpack/components/TypeAhead/pf4Search/TypeAheadSearch.js
katello-4.1.2.1 webpack/components/TypeAhead/pf4Search/TypeAheadSearch.js
katello-4.0.2 webpack/components/TypeAhead/pf4Search/TypeAheadSearch.js
katello-4.1.2 webpack/components/TypeAhead/pf4Search/TypeAheadSearch.js
katello-4.1.1 webpack/components/TypeAhead/pf4Search/TypeAheadSearch.js
katello-4.1.0 webpack/components/TypeAhead/pf4Search/TypeAheadSearch.js
katello-4.0.1.2 webpack/components/TypeAhead/pf4Search/TypeAheadSearch.js
katello-4.1.0.rc2.2 webpack/components/TypeAhead/pf4Search/TypeAheadSearch.js
katello-4.1.0.rc2.1 webpack/components/TypeAhead/pf4Search/TypeAheadSearch.js
katello-4.0.1.1 webpack/components/TypeAhead/pf4Search/TypeAheadSearch.js