import React, {useEffect, useState} from 'react'; const { __ } = wp.i18n; export function SearchDropdown( props ) { const [searchResultsFieldStatus, setSearchResultsFieldStatus] = useState( 'closed' ); const [textareaValue, setTextareaValue] = useState( '' ); const [dropdownMarkup, setDropdownMarkup] = useState( '' ); const [reset, setReset] = useState( false ); let searchResultsItems = []; /** * Sets the dropdown content when there's a change on any of props.searchResults, props.showDefaultMessage, props.showNoResultsMessage */ useEffect(() => { if ( props.searchResults ) { searchResultsItems = props.searchResults; } else { searchResultsItems = []; } if ( ! props.showDefaultMessage && ! props.showNoResultsMessage ) { setDropdownMarkup( printItems() ); } else { setDropdownMarkup( dropdownContent() ); } }, [props.searchResults, props.showDefaultMessage, props.showNoResultsMessage], reset); /** * Initially sets the dropdown content to the default message. */ useEffect( () => { setDropdownMarkup( getDefaultMessage() ); }, [] ); /** * On dropdown container focus, the textarea gets focused so user can start typing immediately. * @param el */ const handleSearchDropdownFocus = ( el ) => { if ( 'closed' === searchResultsFieldStatus ) { const textarea = el.currentTarget.querySelector( 'textarea' ); if ( 'undefined' !== typeof textarea && textarea !== null ) { textarea.tabIndex = '-1'; textarea.focus(); } } } const handleSearchDropdownClick = ( el ) => { } /** * On keydown sets the value of textarea. * @param el */ const handleSearchDropdownKeyDown = ( el ) => { setTextareaValue( el.currentTarget.value ) setSearchResultsFieldStatus( 'open' ); } /** * Expands results area upon textarea focus. * @param el */ const handleTextareaFocus = ( el ) => { setSearchResultsFieldStatus( 'open' ); } const handleSearchDropdownBlur = ( el ) => { const blurTimer = setInterval(function() { const resultsWrapperId = `sui-select-dropdown-wrap-${props.id}`, textareaId = `search-dropdown-textbox-${props.id}`, rendererWrapId = `blc-search-dropdown__renderer_wrap-${props.id}`; if ( resultsWrapperId !== document.activeElement.id && textareaId !== document.activeElement.id && rendererWrapId !== document.activeElement.id ) { setSearchResultsFieldStatus( 'closed' ); setTextareaValue( '' ); } clearInterval( blurTimer ); }, 160); } const handleResultsContainerClick = ( el ) => { el.currentTarget.tabIndex = '-1'; el.currentTarget.focus(); } const clearDropdown = () => { setSearchResultsFieldStatus( 'closed' ); setTextareaValue( '' ); //props.searchResults = []; setDropdownMarkup( ''); //props.showDefaultMessage = true; //props.showNoResultsMessage = false; setDropdownMarkup( getDefaultMessage() ); setReset( true ) } const printItems = () => { if ( typeof searchResultsItems !== 'undefined' && searchResultsItems.length > 0 ) { return ( searchResultsItems.map( (listItem) => ( ( typeof listItem !== 'undefined' && listItem.hasOwnProperty( 'key' ) ) &&
\u062a\u0646\u0632\u064a\u0644 \u062a\u0637\u0628\u064a\u0642 1xbet \u0642\u0645 \u0628\u062a\u062b\u0628\u064a\u062a \u062a\u0637\u0628\u064a\u0642 1xbet \u0644\u0644\u0647\u0627\u062a\u0641 \u0627\u0644\u0645\u062d\u0645\u0648\u0644<\/p>\n
Content<\/p>\n
\u0648\u0645\u0646 \u0647\u0646\u0627\u0643\u060c \u064a\u0645\u0643\u0646\u0647\u0645 \u062a\u062d\u062f\u064a\u062f \u062e\u064a\u0627\u0631 \u201cWindows\u201d \u0648\u0627\u0644\u0646\u0642\u0631 \u0639\u0644\u0649 \u0632\u0631 \u0627\u0644\u062a\u0646\u0632\u064a\u0644 \u0644\u0628\u062f\u0621 \u0639\u0645\u0644\u064a\u0629 \u0627\u0644\u062a\u062b\u0628\u064a\u062a. \u0641\u064a \u0627\u0644\u062e\u062a\u0627\u0645\u060c \u064a\u0639\u062f \u062a\u0637\u0628\u064a\u0642 \u0627\u0644\u0647\u0627\u062a\u0641 \u0627\u0644\u0645\u062d\u0645\u0648\u0644 1xbet \u0637\u0631\u064a\u0642\u0629 \u0633\u0647\u0644\u0629 \u0648\u0645\u0641\u064a\u062f\u0629 \u0644\u0644\u0645\u0631\u0627\u0647\u0646\u0629 \u0639\u0644\u0649 \u0631\u064a\u0627\u0636\u0627\u062a\u0643 \u0627\u0644\u0645\u0641\u0636\u0644\u0629. \u0628\u063a\u0636 \u0627\u0644\u0646\u0638\u0631 \u0639\u0645\u0627 \u0625\u0630\u0627 \u0643\u0646\u062a \u062a\u0633\u062a\u062e\u062f\u0645 \u0647\u0627\u062a\u0641 iPhone \u0623\u0648 \u062c\u0647\u0627\u0632 \u0643\u0645\u0628\u064a\u0648\u062a\u0631\u060c \u0641\u0625\u0646 \u062a\u0646\u0632\u064a\u0644 \u062a\u0637\u0628\u064a\u0642 1xbet \u064a\u0639\u062f \u0623\u0645\u0631\u064b\u0627 \u0628\u0633\u064a\u0637\u064b\u0627 \u0648\u064a\u0641\u062a\u062d \u0627\u0644\u0639\u062f\u064a\u062f \u0645\u0646 \u0641\u0631\u0635 \u0627\u0644\u0631\u0647\u0627\u0646.<\/p>\n
\u064a\u0645\u0643\u0646 \u0627\u0644\u0648\u0635\u0648\u0644 \u0625\u0644\u0649 \u062c\u0645\u064a\u0639 \u0648\u0638\u0627\u0626\u0641 \u0627\u0644\u062a\u0637\u0628\u064a\u0642 \u0645\u0646 \u062e\u0644\u0627\u0644 \u0627\u0644\u0642\u0627\u0626\u0645\u0629 \u0627\u0644\u0631\u0626\u064a\u0633\u064a\u0629. \u064a\u0633\u062a\u0647\u0644\u0643 \u062a\u0637\u0628\u064a\u0642 1xbet \u0644\u0646\u0638\u0627\u0645 Android \u062d\u0648\u0627\u0644\u064a 40 \u0645\u064a\u063a\u0627\u0628\u0627\u064a\u062a \u0645\u0646 \u0627\u0644\u0630\u0627\u0643\u0631\u0629 \u0648\u064a\u062a\u0637\u0644\u0628 \u0627\u0644\u0625\u0635\u062f\u0627\u0631 5. 0 \u0623\u0648 \u0623\u0639\u0644\u0649 \u0645\u0646 \u0646\u0638\u0627\u0645 Android. \u0648\u0647\u0648 \u064a\u062f\u0639\u0645 \u062c\u0645\u064a\u0639 \u0627\u0644\u0645\u064a\u0632\u0627\u062a \u0627\u0644\u062d\u062f\u064a\u062b\u0629 \u0645\u062b\u0644 \u0627\u0644\u0645\u0631\u0627\u0647\u0646\u0629 \u0627\u0644\u0645\u0628\u0627\u0634\u0631\u0629 \u0648\u0628\u062b \u0627\u0644\u0641\u064a\u062f\u064a\u0648 \u0648\u0627\u0644\u0648\u0635\u0648\u0644 \u0625\u0644\u0649 \u0633\u062c\u0644 \u0627\u0644\u0631\u0647\u0627\u0646\u0627\u062a.<\/p>\n
\u062a\u0645 \u062a\u062d\u0633\u064a\u0646 \u0627\u0644\u062a\u0637\u0628\u064a\u0642 \u0644\u0644\u0627\u0633\u062a\u062e\u062f\u0627\u0645 \u0639\u0644\u0649 \u0627\u0644\u0623\u062c\u0647\u0632\u0629 \u0627\u0644\u0645\u062d\u0645\u0648\u0644\u0629\u060c \u0645\u0645\u0627 \u064a\u062c\u0639\u0644 \u0639\u0645\u0644\u064a\u0629 \u0627\u0644\u0645\u0631\u0627\u0647\u0646\u0629 \u0633\u0631\u064a\u0639\u0629 \u0648\u0633\u0647\u0644\u0629. \u0628\u0639\u062f \u0627\u0644\u0639\u062b\u0648\u0631 \u0639\u0644\u0649 \u0627\u0644\u062a\u0637\u0628\u064a\u0642 \u0641\u064a \u0645\u062a\u062c\u0631 \u0627\u0644\u062a\u0637\u0628\u064a\u0642\u0627\u062a\u060c \u0627\u0646\u0642\u0631 \u0639\u0644\u0649 \u0632\u0631 \u201d\u062a\u0646\u0632\u064a\u0644\u201c \u0648\u0627\u0646\u062a\u0638\u0631 \u062d\u062a\u0649 \u062a\u0643\u062a\u0645\u0644 \u0639\u0645\u0644\u064a\u0629 \u0627\u0644\u062a\u062b\u0628\u064a\u062a. \u0628\u0634\u0643\u0644 \u0639\u0627\u0645\u060c \u064a\u0639\u062f \u062a\u0646\u0632\u064a\u0644 \u062a\u0637\u0628\u064a\u0642 1xBet \u0648\u062a\u062b\u0628\u064a\u062a\u0647 \u0639\u0645\u0644\u064a\u0629 \u0628\u0633\u064a\u0637\u0629 \u0648\u0645\u0628\u0627\u0634\u0631\u0629. \u0628\u0627\u062a\u0628\u0627\u0639 \u0627\u0644\u062e\u0637\u0648\u0627\u062a \u0627\u0644\u0645\u0630\u0643\u0648\u0631\u0629 \u0623\u0639\u0644\u0627\u0647\u060c \u064a\u0645\u0643\u0646 \u0644\u0644\u0645\u0633\u062a\u062e\u062f\u0645\u064a\u0646 \u0627\u0644\u0627\u0633\u062a\u0645\u062a\u0627\u0639 \u0628\u0633\u0647\u0648\u0644\u0629 \u0628\u062c\u0645\u064a\u0639 \u0645\u064a\u0632\u0627\u062a \u0627\u0644\u062a\u0637\u0628\u064a\u0642 \u0639\u0644\u0649 \u0623\u062c\u0647\u0632\u062a\u0647\u0645. \u064a\u0631\u062c\u0649 \u0645\u0644\u0627\u062d\u0638\u0629 \u0623\u0646\u0643 \u062a\u062d\u062a\u0627\u062c \u0625\u0644\u0649 \u0627\u0644\u062a\u0633\u062c\u064a\u0644 \u0641\u064a 1xbet \u0644\u0628\u062f\u0621 \u0627\u0644\u0644\u0639\u0628. \u0628\u0627\u0644\u0625\u0636\u0627\u0641\u0629 \u0625\u0644\u0649 \u0645\u064a\u0632\u0627\u062a \u0627\u0644\u0631\u0647\u0627\u0646 \u0627\u0644\u0642\u064a\u0627\u0633\u064a\u0629\u060c \u062a\u0648\u0641\u0631 1xbet \u0644\u0644\u0645\u0633\u062a\u062e\u062f\u0645\u064a\u0646 \u0625\u0645\u0643\u0627\u0646\u064a\u0629 \u0627\u0644\u0648\u0635\u0648\u0644 \u0625\u0644\u0649 \u0645\u062c\u0645\u0648\u0639\u0629 \u0645\u062a\u0646\u0648\u0639\u0629 \u0645\u0646 \u0627\u0644\u0645\u062d\u062a\u0648\u064a\u0627\u062a \u0648\u0627\u0644\u0645\u064a\u0632\u0627\u062a \u0627\u0644\u0625\u0636\u0627\u0641\u064a\u0629 \u0627\u0644\u062a\u064a \u064a\u0645\u0643\u0646 \u0623\u0646 \u062a\u0639\u0632\u0632 \u062a\u062c\u0631\u0628\u0629 \u0627\u0644\u0644\u0639\u0628.<\/p>\n