@ideal-postcodes/address-finder
Version:
Address Finder JS library backed by the Ideal Postcodes UK address search API
72 lines (71 loc) • 1.5 kB
TypeScript
import { StateMachine } from "@xstate/fsm";
import { AddressSuggestion } from "@ideal-postcodes/jsutil";
import { ContextDetails } from "./contexts";
import { Controller } from "./controller";
export type CloseReason = "select" | "esc" | "blur";
/**
* @hidden
*/
export type Events = {
type: "AWAKE";
} | {
type: "COUNTRY_CHANGE_EVENT";
contextDetails: ContextDetails | undefined;
} | {
type: "SUGGEST";
suggestions: AddressSuggestion[];
} | {
type: "SELECT_ADDRESS";
suggestion: AddressSuggestion | undefined;
} | {
type: "NEXT";
} | {
type: "INPUT";
event: Event;
} | {
type: "PREVIOUS";
} | {
type: "RESET";
} | {
type: "CHANGE_COUNTRY";
} | {
type: "SELECT_COUNTRY";
contextDetails: ContextDetails | undefined;
} | {
type: "CLOSE";
reason: CloseReason;
} | {
type: "NOTIFY";
notification: string;
};
/**
* @hidden
*/
export interface Context {
}
/**
* @hidden
*/
export type States = {
value: "closed";
context: Context;
} | {
value: "suggesting_country";
context: Context;
} | {
value: "notifying";
context: Context;
} | {
value: "suggesting";
context: Context;
};
export type ViewMachine = StateMachine.Machine<Context, Events, States>;
export type ViewService = StateMachine.Service<Context, Events, States>;
interface Create {
(options: CreateOptions): ViewService;
}
export interface CreateOptions {
c: Controller;
}
export declare const create: Create;
export {};