@grdistro/store-locator-widget
Version:
A modular store locator widget with Mapbox integration that can be embedded in any website
73 lines (65 loc) • 1.77 kB
TypeScript
// Type definitions for Store Locator Widget
// Project: https://github.com/your-org/store-locator-widget
export interface Store {
id: number;
name: string;
address: string;
phone: string;
latitude: string | number;
longitude: string | number;
isOpen: boolean;
website?: string;
hours?: Record<string, string>;
services?: string[];
distance?: number;
}
export interface StoreLocatorConfig {
containerId: string;
stores?: Store[];
apiEndpoint?: string;
mapboxToken?: string;
height?: string;
showSearch?: boolean;
showFilters?: boolean;
showMap?: boolean;
theme?: 'light' | 'dark';
onStoreSelect?: (store: Store) => void;
onError?: (error: string) => void;
customStyles?: string;
maxResults?: number;
defaultZoom?: number;
center?: {
latitude: number;
longitude: number;
};
}
export interface StoreSelectEvent extends CustomEvent {
detail: {
store: Store;
};
}
export declare class StoreLocator {
constructor(config: StoreLocatorConfig);
// Public API methods
addStore(store: Store): void;
removeStore(storeId: number): void;
updateStore(storeId: number, updates: Partial<Store>): void;
getSelectedStore(): Store | null;
getAllStores(): Store[];
getFilteredStores(): Store[];
setFilter(filter: string): void;
search(query: string): void;
getUserLocation(): Promise<GeolocationPosition>;
destroy(): void;
// Event handling
on(event: 'storeSelect', callback: (store: Store) => void): void;
off(event: 'storeSelect', callback: (store: Store) => void): void;
}
// Global declaration for script tag usage
declare global {
interface Window {
StoreLocator: typeof StoreLocator;
storeLocatorConfig?: StoreLocatorConfig;
}
}
export default StoreLocator;