@ideal-postcodes/jsutil
Version:
Browser Address Autocomplete for api.ideal-postcodes.co.uk
75 lines (74 loc) • 2.77 kB
TypeScript
import { components } from "@ideal-postcodes/openapi";
export type UkSuggestion = components["schemas"]["UkAddressSuggestion"];
export type GlobalAddressSuggestion = components["schemas"]["AddressSuggestion"];
export type AddressSuggestion = GlobalAddressSuggestion | UkSuggestion;
export type PafAddress = components["schemas"]["PafAddress"];
export type MrAddress = components["schemas"]["MrAddress"];
export type NybAddress = components["schemas"]["NybAddress"];
export type PafaAddress = components["schemas"]["PafAliasAddress"];
export type WelshPafAddress = components["schemas"]["WelshPafAddress"];
export type GlobalAddress = components["schemas"]["GbrGlobalAddress"];
export type GbrAddress = PafAddress | MrAddress | NybAddress | PafaAddress | WelshPafAddress | GlobalAddress;
export type UspsAddress = components["schemas"]["UspsAddress"];
export type UsaGlobalAddress = components["schemas"]["UsaGlobalAddress"];
export type UsaAddress = UspsAddress | UsaGlobalAddress;
export type AnyAddress = GbrAddress | UsaAddress;
export interface Binding {
pageTest: PageTest;
bind: Bind;
}
export interface Start {
(config?: Config): number | null;
}
export interface Stop {
(): void;
}
export interface Bind<T extends Config = Config> {
(config?: T): void;
}
export interface PageTest {
(): boolean;
}
export interface Selectors {
line_1: string;
line_2?: string;
line_3?: string;
post_town: string;
county?: string;
postcode: string;
organisation?: string;
country: string;
}
export interface Config {
enabled: boolean;
apiKey: string;
populateCounty: boolean;
autocomplete: boolean;
autocompleteOverride: AutocompleteConfig;
postcodeLookup: boolean;
postcodeLookupOverride: PostcodeLookupConfig;
watchCountry?: boolean;
separateFinder?: boolean;
}
export interface Targets {
line_1: HTMLElement | null;
line_2?: HTMLElement | null;
line_3?: HTMLElement | null;
post_town: HTMLElement | null;
county: HTMLElement | null;
postcode: HTMLElement | null;
organisation: HTMLElement | null;
country: HTMLElement | null;
}
export type AutocompleteConfig = any;
export type PostcodeLookupConfig = any;
export type LineCount = 1 | 2 | 3;
export type LoadState = "complete" | "loading";
export interface ParentTest {
(e: HTMLElement): boolean;
}
export type OutputFields = Partial<Record<keyof GbrAddress, SelectorNode>>;
export type UsaOutputFields = Partial<Record<keyof UsaAddress, SelectorNode>>;
export type NamedFields = Partial<Record<keyof GbrAddress, string>>;
export type SelectorNode = string | HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement;
export declare const isGbrAddress: (address: AnyAddress) => address is GbrAddress;