@simoko/tw-zip
Version:
台灣縣市、行政區、郵遞區號(3碼/6碼)查詢工具,支援 React/Vue/Svelte/SolidJS/Angular
50 lines (47 loc) • 1.47 kB
TypeScript
import * as react from 'react';
import { isCityCached, clearCache } from '../zip6/loader.js';
interface SearchResult {
city: string;
area: string;
road: string;
}
interface Zip6Result {
zipcode: string;
zip3: string;
city: string;
area: string;
road: string;
}
interface UseTwZip6Options {
/** 資料來源 URL(預設使用 jsDelivr CDN) */
baseUrl?: string;
/** 預載入的縣市列表 */
preload?: string[];
}
declare function useTwZip6(options?: UseTwZip6Options): {
loading: boolean;
cities: string[];
areas: string[];
roads: string[];
city: string;
area: string;
road: string;
number: number | undefined;
lane: number | undefined;
alley: number | undefined;
setCity: (value: string) => Promise<void>;
setArea: (value: string) => void;
setRoad: (value: string) => void;
setNumber: react.Dispatch<react.SetStateAction<number | undefined>>;
setLane: react.Dispatch<react.SetStateAction<number | undefined>>;
setAlley: react.Dispatch<react.SetStateAction<number | undefined>>;
searchRoads: (keyword: string) => void;
searchResults: SearchResult[];
zipCode: string;
zip3: string;
result: Zip6Result | undefined;
preloadCities: (citiesToPreload: string[]) => Promise<void>;
isCityCached: typeof isCityCached;
clearCache: typeof clearCache;
};
export { type SearchResult, type UseTwZip6Options, type Zip6Result, useTwZip6 };