Sha256: edb83ae43378c8de6abcfdeb0a477b071840e4a563a11accff18866a3f028b8d

Contents?: true

Size: 1.47 KB

Versions: 17

Compression:

Stored size: 1.47 KB

Contents

import React from 'react';
import { Dropdown, MenuItem } from 'patternfly-react';

import { commonItemPropTypes } from '../helpers/commonPropTypes';

const TypeAheadItems = ({
  items, activeItems, getItemProps, highlightedIndex,
}) => (
  <Dropdown.Menu className="typeahead-dropdown" ouiaId="typeahead-dropdown">
    {items.map(({ text, type, disabled = false }, index) => {
      if (type === 'header') {
        return (
          <MenuItem key={text} header>
            {text}
          </MenuItem>
        );
      }

      if (type === 'divider') {
        // eslint-disable-next-line react/no-array-index-key
        return <MenuItem key={`divider-${index}`} divider />;
      }

      if (disabled) {
        return (
          <MenuItem key={text} disabled>
            {text}
          </MenuItem>
        );
      }

      const itemProps = getItemProps({
        index: activeItems.indexOf(text),
        item: text,
        active: activeItems[highlightedIndex] === text,
        onClick: (e) => {
          // At this point the event.defaultPrevented
          // is already set to true by react-bootstrap
          // MenuItem. We need to set it back to false
          // So downshift will execute it's own handler
          e.defaultPrevented = false;
        },
      });

      return (
        <MenuItem {...itemProps} key={text}>
          {text}
        </MenuItem>
      );
    })}
  </Dropdown.Menu>
);

TypeAheadItems.propTypes = commonItemPropTypes;

export default TypeAheadItems;

Version data entries

17 entries across 17 versions & 1 rubygems

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