import React from 'react';
import { List } from 'antd';
import { SearchOutlined } from '@ant-design/icons';
/**
 * SuggestWords 组件
 * 展示搜索联想词
 */
export var SuggestWords = function SuggestWords(props) {
  var suggestions = props.suggestions,
    onSelect = props.onSelect,
    render = props.render,
    className = props.className,
    style = props.style;

  // 如果没有联想词，不显示
  if (!suggestions || suggestions.length === 0) {
    return null;
  }

  // 使用自定义渲染
  if (render) {
    return /*#__PURE__*/React.createElement(React.Fragment, null, render(suggestions, onSelect));
  }

  /**
   * 处理点击联想词
   */
  var handleClick = function handleClick(keyword) {
    onSelect(keyword);
  };
  return /*#__PURE__*/React.createElement("div", {
    className: "pisell-lookup-suggestions ".concat(className || ''),
    style: style
  }, /*#__PURE__*/React.createElement(List, {
    className: "pisell-lookup-suggestions-list",
    size: "small",
    dataSource: suggestions,
    renderItem: function renderItem(item) {
      return /*#__PURE__*/React.createElement(List.Item, {
        className: "pisell-lookup-suggestions-item",
        onClick: function onClick() {
          return handleClick(item);
        }
      }, /*#__PURE__*/React.createElement(SearchOutlined, {
        style: {
          marginRight: 8,
          color: '#667085'
        }
      }), item);
    }
  }));
};
SuggestWords.displayName = 'SuggestWords';