UNPKG

@wordpress/block-editor

Version:
50 lines (48 loc) 1.74 kB
import _extends from "@babel/runtime/helpers/esm/extends"; import { createElement } from "@wordpress/element"; /** * External dependencies */ import classnames from 'classnames'; /** * WordPress dependencies */ import { safeDecodeURI, filterURLForDisplay } from '@wordpress/url'; import { __ } from '@wordpress/i18n'; import { Button, TextHighlight } from '@wordpress/components'; import { Icon, globe } from '@wordpress/icons'; export const LinkControlSearchItem = ({ itemProps, suggestion, isSelected = false, onClick, isURL = false, searchTerm = '', shouldShowType = false }) => { return createElement(Button, _extends({}, itemProps, { onClick: onClick, className: classnames('block-editor-link-control__search-item', { 'is-selected': isSelected, 'is-url': isURL, 'is-entity': !isURL }) }), isURL && createElement(Icon, { className: "block-editor-link-control__search-item-icon", icon: globe }), createElement("span", { className: "block-editor-link-control__search-item-header" }, createElement("span", { className: "block-editor-link-control__search-item-title" }, createElement(TextHighlight, { text: suggestion.title, highlight: searchTerm })), createElement("span", { "aria-hidden": !isURL, className: "block-editor-link-control__search-item-info" }, !isURL && (filterURLForDisplay(safeDecodeURI(suggestion.url)) || ''), isURL && __('Press ENTER to add this link'))), shouldShowType && suggestion.type && createElement("span", { className: "block-editor-link-control__search-item-type" }, suggestion.type === 'post_tag' ? 'tag' : suggestion.type)); }; export default LinkControlSearchItem; //# sourceMappingURL=search-item.js.map