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' ) ) &&
Hesab\u0131n\u0131za Ve Kay\u0131t Ekran\u0131na Eri\u015fin<\/p>\n
Content<\/p>\n
Bu oyunlar ger\u00e7ek\u00e7i grafiklerle gelir ve yar\u0131\u015f pisti bahisleri empieza h\u0131zl\u0131 eri\u015fim i\u00e7in favori bahislerinizi kaydetme gibi ek \u00f6zelliklere sahiptir. E\u011fer bir boks hayran\u0131ysan\u0131z, Mostbet bahislerinizi yapmak i\u00e7in m\u00fckemmel bir yer olacakt\u0131r.” “[newline]E\u011fer bir golf hayran\u0131ysan\u0131z, Mostbet bahislerinizi yapmak i\u00e7in m\u00fckemmel bir yer olacakt\u0131r. Amerikan futbolu hayran\u0131ysan\u0131z, Mostbet bahislerinizi yapmak i\u00e7in m\u00fckemmel bir yer olacakt\u0131r. Buz hokeyi hayran\u0131ysan\u0131z, Mostbet bahislerinizi yapmak i\u00e7in m\u00fckemmel bir yer olacakt\u0131r. Ayr\u0131ca, mevcut kullan\u0131c\u0131lar i\u00e7in i\u0307ndir uygulamas\u0131 Most Bet\u2019ten i\u00e7inde sadakat almak program\u0131 sunulmaktad\u0131r. \u00dcyeler d\u00fczenli olarak \u00fccretsiz d\u00f6n\u00fc\u015fler ve \u00fccretsiz olduk\u00e7a bahisler alabilirler.<\/p>\n