/** * External dependencies */ import { __ } from '@wordpress/i18n'; import { Button } from '@wordpress/components'; import { SelectControl } from '@woocommerce/components'; import { Icon, chevronDown } from '@wordpress/icons'; import { useState } from '@wordpress/element'; /** * Internal dependencies */ import { BusinessLocationEvent, CoreProfilerStateMachineContext, } from '../index'; import { CountryStateOption } from '../services/country'; import { Heading } from '../components/heading/heading'; import { Navigation } from '../components/navigation/navigation'; export const BusinessLocation = ( { sendEvent, navigationProgress, context, }: { sendEvent: ( event: BusinessLocationEvent ) => void; navigationProgress: number; context: Pick< CoreProfilerStateMachineContext, 'countries' >; } ) => { const [ storeCountry, setStoreCountry ] = useState< CountryStateOption >( { key: '', label: '', } ); const inputLabel = __( 'Select country/region', 'woocommerce' ); return (
{ return new RegExp( '(^' + query + '| — (' + query + '))', 'i' ); } } autoComplete="new-password" // disable autocomplete and autofill options={ context.countries } excludeSelectedOptions={ false } help={ } onChange={ ( results: Array< CountryStateOption > ) => { if ( results.length ) { setStoreCountry( results[ 0 ] ); } } } selected={ storeCountry ? [ storeCountry ] : [] } showAllOnFocus isSearchable />
); };