import * as React from 'react'; import { InputProps } from '../Input'; import { GoogleMapsClient } from '../clients'; type Address = { formatted: string; formattedStreetAddress: string; latLng: { lat: string; lng: string; }; approximate: boolean; city?: string; state?: string; country?: string; /** Country code used to help with suggestions and geocoding. */ countryCode?: string; street?: string; number?: string; postalCode?: string; subpremise?: string; }; export interface GoogleAddressInputProps extends Omit< InputProps, 'onChange' | 'onBlur' | 'onFocus' | 'onKeyDown' | 'onKeyUp' | 'onPaste' > { /** Placeholder for the input box. */ placeholder?: string; /** Value to place before every search term (normally shouldn't be used) */ valuePrefix?: string; /** Country code used to help with suggestions and geocoding. */ countryCode?: string; /** Controlled mode - value to display. */ value?: string; /** Sets UI to indicate a status. */ status?: InputProps['status']; /** The status message to display when hovering the status icon, if not given or empty, no tooltip is displayed. */ statusMessage?: InputProps['statusMessage']; /** Defines a standard input onChange callback. */ onChange?: React.ChangeEventHandler; /** Defines a standard input onBlur callback. It's called with no arguments. */ onBlur?: React.FocusEventHandler; /** Defines a standard input onFocus callback. It's called with no arguments. */ onFocus?: React.FocusEventHandler; /** Defines a standard input onKeyDown callback. */ onKeyDown?: React.KeyboardEventHandler; /** Defines a standard input onKeyUp callback. */ onKeyUp?: React.KeyboardEventHandler; /** Defines a callback handler that is called when user pastes text from a clipboard (using a mouse or keyboard shortcut) */ onPaste?: React.ClipboardEventHandler; /** Callback for results. Receives an object containing: originValue (value in the search), googleResult (google geocode result for the search), address (which includes: formatted (google formatted address), country, countryCode, street, number, postalCode, latLng (lat, lng)) */ onSet?: (params: { originValue: string; googleResult: any; address: Address; }) => void; /** Show or hide magnifying glass icon. * @default true */ magnifyingGlass?: boolean; /** Sets the input to readOnly. */ readOnly?: boolean; /** Specifies whether the entire input text is selected when the input gets focus. * @default true */ autoSelect?: boolean; /** Clear the suggestions list upon input blur. * @default true */ clearSuggestionsOnBlur?: boolean; /** If set to `true`, the component attempts to get a Google location from the input's text if there are no suggestions. This is useful when looking for locations for which google doesn't give suggestions - for example: Apartment/Apt. * @default false */ fallbackToManual?: boolean; /** Shows the Powered By Google credit in a fixed footer. * @default false */ poweredByGoogle?: boolean; /** Display a footer as the last suggestion in the list. */ footer?: string; /** Limits the autocomplete to specific Google Places types, for example `address` or `geocode`. */ types?: any[]; /** Filters the autocomplete results by Google Places result type at a lower level, for example `street_address`. */ filterTypes?: any[]; /** Sets which Google Places data fields to return, for example `formatted_address` or `geometry`. */ placeDetailsFields?: any[]; /** Set the footer's options (e.g. disabled, overrideStyles, etc. ) */ footerOptions?: object; /** Sets how to get more details for a place (e.g. geocode, places, etc) */ handler?: 'geocode' | 'places'; /** Google map client implementation (should implement autocomplete and geocode functions). Normally you would use @wix/design-system/clients/GoogleMapsClient. */ Client: new () => GoogleMapsClient; } export class GoogleAddressInput extends React.Component { select: () => void; focus: () => void; } export {};