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}
    ) }
    {"id":1078,"date":"2024-11-19T04:03:23","date_gmt":"2024-11-19T07:03:23","guid":{"rendered":"https:\/\/automax.net.br\/?page_id=1078"},"modified":"2024-11-19T04:03:23","modified_gmt":"2024-11-19T07:03:23","slug":"windowsxia-zai-gitlab-14-2-3-quan-mian-jie-shao-yu-an-zhuang-zhi-nan","status":"publish","type":"page","link":"https:\/\/automax.net.br\/windowsxia-zai-gitlab-14-2-3-quan-mian-jie-shao-yu-an-zhuang-zhi-nan\/","title":{"rendered":"Windows\u4e0b\u8f7d – GitLab 14.2.3\uff1a\u5168\u9762\u4ecb\u7ecd\u4e0e\u5b89\u88c5\u6307\u5357"},"content":{"rendered":"

    \u4e0b\u8f7d GitLab 14.2.3<\/a><\/h1>\n

    \"GitLab<\/p>\n

    GitLab 14.2.3 \u662f\u4e00\u6b3e\u5353\u8d8a\u7684\u8f6f\u4ef6\uff0c\u4e13\u95e8\u7528\u4e8e\u56e2\u961f\u534f\u4f5c\u548c\u7248\u672c\u63a7\u5236\u3002…<\/p>\n

    <\/p>\n","protected":false},"excerpt":{"rendered":"

    \u4e0b\u8f7d GitLab 14.2.3 GitLab 14.2.3 \u662f\u4e00\u6b3e\u5353\u8d8a\u7684\u8f6f\u4ef6\uff0c\u4e13\u95e8\u7528\u4e8e\u56e2\u961f\u534f\u4f5c\u548c\u7248\u672c\u63a7\u5236\u3002…<\/p>\n","protected":false},"author":5,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_joinchat":[],"footnotes":""},"class_list":["post-1078","page","type-page","status-publish","hentry"],"yoast_head":"\nWindows\u4e0b\u8f7d - GitLab 14.2.3\uff1a\u5168\u9762\u4ecb\u7ecd\u4e0e\u5b89\u88c5\u6307\u5357 - Automax<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/automax.net.br\/windowsxia-zai-gitlab-14-2-3-quan-mian-jie-shao-yu-an-zhuang-zhi-nan\/\" \/>\n<meta property=\"og:locale\" content=\"pt_BR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Windows\u4e0b\u8f7d - GitLab 14.2.3\uff1a\u5168\u9762\u4ecb\u7ecd\u4e0e\u5b89\u88c5\u6307\u5357 - Automax\" \/>\n<meta property=\"og:description\" content=\"\u4e0b\u8f7d GitLab 14.2.3 GitLab 14.2.3 \u662f\u4e00\u6b3e\u5353\u8d8a\u7684\u8f6f\u4ef6\uff0c\u4e13\u95e8\u7528\u4e8e\u56e2\u961f\u534f\u4f5c\u548c\u7248\u672c\u63a7\u5236\u3002…\" \/>\n<meta property=\"og:url\" content=\"https:\/\/automax.net.br\/windowsxia-zai-gitlab-14-2-3-quan-mian-jie-shao-yu-an-zhuang-zhi-nan\/\" \/>\n<meta property=\"og:site_name\" content=\"Automax\" \/>\n<meta property=\"og:image\" content=\"https:\/\/about.gitlab.com\/images\/press\/logo\/png\/gitlab-logo-gray-rgb.png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/automax.net.br\/windowsxia-zai-gitlab-14-2-3-quan-mian-jie-shao-yu-an-zhuang-zhi-nan\/\",\"url\":\"https:\/\/automax.net.br\/windowsxia-zai-gitlab-14-2-3-quan-mian-jie-shao-yu-an-zhuang-zhi-nan\/\",\"name\":\"Windows\u4e0b\u8f7d - GitLab 14.2.3\uff1a\u5168\u9762\u4ecb\u7ecd\u4e0e\u5b89\u88c5\u6307\u5357 - Automax\",\"isPartOf\":{\"@id\":\"https:\/\/automax.net.br\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/automax.net.br\/windowsxia-zai-gitlab-14-2-3-quan-mian-jie-shao-yu-an-zhuang-zhi-nan\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/automax.net.br\/windowsxia-zai-gitlab-14-2-3-quan-mian-jie-shao-yu-an-zhuang-zhi-nan\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/about.gitlab.com\/images\/press\/logo\/png\/gitlab-logo-gray-rgb.png\",\"datePublished\":\"2024-11-19T07:03:23+00:00\",\"dateModified\":\"2024-11-19T07:03:23+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/automax.net.br\/windowsxia-zai-gitlab-14-2-3-quan-mian-jie-shao-yu-an-zhuang-zhi-nan\/#breadcrumb\"},\"inLanguage\":\"pt-BR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/automax.net.br\/windowsxia-zai-gitlab-14-2-3-quan-mian-jie-shao-yu-an-zhuang-zhi-nan\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"pt-BR\",\"@id\":\"https:\/\/automax.net.br\/windowsxia-zai-gitlab-14-2-3-quan-mian-jie-shao-yu-an-zhuang-zhi-nan\/#primaryimage\",\"url\":\"https:\/\/about.gitlab.com\/images\/press\/logo\/png\/gitlab-logo-gray-rgb.png\",\"contentUrl\":\"https:\/\/about.gitlab.com\/images\/press\/logo\/png\/gitlab-logo-gray-rgb.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/automax.net.br\/windowsxia-zai-gitlab-14-2-3-quan-mian-jie-shao-yu-an-zhuang-zhi-nan\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"In\u00edcio\",\"item\":\"https:\/\/automax.net.br\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Windows\u4e0b\u8f7d – GitLab 14.2.3\uff1a\u5168\u9762\u4ecb\u7ecd\u4e0e\u5b89\u88c5\u6307\u5357\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/automax.net.br\/#website\",\"url\":\"https:\/\/automax.net.br\/\",\"name\":\"Automax\",\"description\":\"Sistemas para Oficinas e Frotas\",\"publisher\":{\"@id\":\"https:\/\/automax.net.br\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/automax.net.br\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"pt-BR\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/automax.net.br\/#organization\",\"name\":\"Automax\",\"url\":\"https:\/\/automax.net.br\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"pt-BR\",\"@id\":\"https:\/\/automax.net.br\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/automax.net.br\/wp-content\/uploads\/2021\/11\/logo.png\",\"contentUrl\":\"https:\/\/automax.net.br\/wp-content\/uploads\/2021\/11\/logo.png\",\"width\":313,\"height\":60,\"caption\":\"Automax\"},\"image\":{\"@id\":\"https:\/\/automax.net.br\/#\/schema\/logo\/image\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Windows\u4e0b\u8f7d - GitLab 14.2.3\uff1a\u5168\u9762\u4ecb\u7ecd\u4e0e\u5b89\u88c5\u6307\u5357 - Automax","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/automax.net.br\/windowsxia-zai-gitlab-14-2-3-quan-mian-jie-shao-yu-an-zhuang-zhi-nan\/","og_locale":"pt_BR","og_type":"article","og_title":"Windows\u4e0b\u8f7d - GitLab 14.2.3\uff1a\u5168\u9762\u4ecb\u7ecd\u4e0e\u5b89\u88c5\u6307\u5357 - Automax","og_description":"\u4e0b\u8f7d GitLab 14.2.3 GitLab 14.2.3 \u662f\u4e00\u6b3e\u5353\u8d8a\u7684\u8f6f\u4ef6\uff0c\u4e13\u95e8\u7528\u4e8e\u56e2\u961f\u534f\u4f5c\u548c\u7248\u672c\u63a7\u5236\u3002…","og_url":"https:\/\/automax.net.br\/windowsxia-zai-gitlab-14-2-3-quan-mian-jie-shao-yu-an-zhuang-zhi-nan\/","og_site_name":"Automax","og_image":[{"url":"https:\/\/about.gitlab.com\/images\/press\/logo\/png\/gitlab-logo-gray-rgb.png"}],"twitter_card":"summary_large_image","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/automax.net.br\/windowsxia-zai-gitlab-14-2-3-quan-mian-jie-shao-yu-an-zhuang-zhi-nan\/","url":"https:\/\/automax.net.br\/windowsxia-zai-gitlab-14-2-3-quan-mian-jie-shao-yu-an-zhuang-zhi-nan\/","name":"Windows\u4e0b\u8f7d - GitLab 14.2.3\uff1a\u5168\u9762\u4ecb\u7ecd\u4e0e\u5b89\u88c5\u6307\u5357 - Automax","isPartOf":{"@id":"https:\/\/automax.net.br\/#website"},"primaryImageOfPage":{"@id":"https:\/\/automax.net.br\/windowsxia-zai-gitlab-14-2-3-quan-mian-jie-shao-yu-an-zhuang-zhi-nan\/#primaryimage"},"image":{"@id":"https:\/\/automax.net.br\/windowsxia-zai-gitlab-14-2-3-quan-mian-jie-shao-yu-an-zhuang-zhi-nan\/#primaryimage"},"thumbnailUrl":"https:\/\/about.gitlab.com\/images\/press\/logo\/png\/gitlab-logo-gray-rgb.png","datePublished":"2024-11-19T07:03:23+00:00","dateModified":"2024-11-19T07:03:23+00:00","breadcrumb":{"@id":"https:\/\/automax.net.br\/windowsxia-zai-gitlab-14-2-3-quan-mian-jie-shao-yu-an-zhuang-zhi-nan\/#breadcrumb"},"inLanguage":"pt-BR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/automax.net.br\/windowsxia-zai-gitlab-14-2-3-quan-mian-jie-shao-yu-an-zhuang-zhi-nan\/"]}]},{"@type":"ImageObject","inLanguage":"pt-BR","@id":"https:\/\/automax.net.br\/windowsxia-zai-gitlab-14-2-3-quan-mian-jie-shao-yu-an-zhuang-zhi-nan\/#primaryimage","url":"https:\/\/about.gitlab.com\/images\/press\/logo\/png\/gitlab-logo-gray-rgb.png","contentUrl":"https:\/\/about.gitlab.com\/images\/press\/logo\/png\/gitlab-logo-gray-rgb.png"},{"@type":"BreadcrumbList","@id":"https:\/\/automax.net.br\/windowsxia-zai-gitlab-14-2-3-quan-mian-jie-shao-yu-an-zhuang-zhi-nan\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"In\u00edcio","item":"https:\/\/automax.net.br\/"},{"@type":"ListItem","position":2,"name":"Windows\u4e0b\u8f7d – GitLab 14.2.3\uff1a\u5168\u9762\u4ecb\u7ecd\u4e0e\u5b89\u88c5\u6307\u5357"}]},{"@type":"WebSite","@id":"https:\/\/automax.net.br\/#website","url":"https:\/\/automax.net.br\/","name":"Automax","description":"Sistemas para Oficinas e Frotas","publisher":{"@id":"https:\/\/automax.net.br\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/automax.net.br\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"pt-BR"},{"@type":"Organization","@id":"https:\/\/automax.net.br\/#organization","name":"Automax","url":"https:\/\/automax.net.br\/","logo":{"@type":"ImageObject","inLanguage":"pt-BR","@id":"https:\/\/automax.net.br\/#\/schema\/logo\/image\/","url":"https:\/\/automax.net.br\/wp-content\/uploads\/2021\/11\/logo.png","contentUrl":"https:\/\/automax.net.br\/wp-content\/uploads\/2021\/11\/logo.png","width":313,"height":60,"caption":"Automax"},"image":{"@id":"https:\/\/automax.net.br\/#\/schema\/logo\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/automax.net.br\/wp-json\/wp\/v2\/pages\/1078","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/automax.net.br\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/automax.net.br\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/automax.net.br\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/automax.net.br\/wp-json\/wp\/v2\/comments?post=1078"}],"version-history":[{"count":1,"href":"https:\/\/automax.net.br\/wp-json\/wp\/v2\/pages\/1078\/revisions"}],"predecessor-version":[{"id":1079,"href":"https:\/\/automax.net.br\/wp-json\/wp\/v2\/pages\/1078\/revisions\/1079"}],"wp:attachment":[{"href":"https:\/\/automax.net.br\/wp-json\/wp\/v2\/media?parent=1078"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}