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' ) ) &&
  • { listItem.onClick(); clearDropdown(); } } > {listItem.display}
  • ) ) ) } } const getDefaultMessage = () => { return
  • {props.defaultMessage}
  • ; } const dropdownContent = () => { if ( props.showDefaultMessage && props.defaultMessage ) { return getDefaultMessage(); } else if ( props.showNoResultsMessage && props.noResultsMessage ) { return
  • {props.noResultsMessage}
  • ; } return printItems(); } return(
    { handleSearchDropdownFocus(e) }} onClick={(e)=> { handleSearchDropdownClick(e) }} onKeyDown={(e)=> { handleSearchDropdownKeyDown(e) }} onBlur={(e)=> { handleSearchDropdownBlur(e) }} >
    { handleResultsContainerClick(e) }} >
      {dropdownMarkup}
    ) }
    Nosso blog - Página 10 de 28 - Automax

    Nosso blog

    3 de novembro de 2024

    Mostbet Türkiye Mobil Uygulamasını Indi

    Mostbet Türkiye Mobil Uygulamasını Indir En İyi Bahis Empieza Online Casino Platformu Content Mostbet’te Müşteri Desteği Mostbet Bahis Şirketinin Faydaları Mostbet’e Şimdi Kaydolun! Mostbet Hesabınıza Giriş” […]
    31 de outubro de 2024

    Here are a few options for the title – Exploring the Benefits of Using Vegas Pro 14 Crack for Video Editing Unlocking the Full Potential of Vegas Pro 14 with a Crack Version A Comprehensive Guide to Vegas Pro 14 Crack for Aspiring Video Editors How to Access Vegas Pro 14 Features with a Crack Version for Free

    Download Unlock the full potential of Vegas Pro 14 with a crack that enables access to premium features without the financial burden. This powerful video editing […]
    28 de outubro de 2024

    Explaining Casinos Vip Program

    Explaining Casinos Vip Programs How To Be Able To Earn Vip Status In Bookmaker Strategies Betting Online Content 🎰 What Are Typically The Most Widely Used […]
    28 de outubro de 2024

    “самые Букмекерские Конторы Онлайн Рейтинг Бк 202

    “самые Букмекерские Конторы Онлайн Рейтинг Бк 2024 Рейтинг Букмекеров Лучшие Букмекерские Конторы В России и Мире%2C Топ-10 Бк%2C Онлайн-список Content Топ-5 Бк С Фрибетом Бк «леон» […]
    Nosso WhatsApp
    WhatsApp
    Escanear o código
    Olá! Como posso te ajudar?