india-state-district
Version:
A lightweight TypeScript library for handling Indian states and districts data with type safety and easy integration
40 lines (39 loc) • 1.06 kB
TypeScript
export interface StateData {
[stateCode: string]: string[];
}
export interface State {
name: string;
code: string;
districts: string[];
}
export interface IndiaStateDistrictOptions {
stateSelectId?: string;
districtSelectId?: string;
defaultState?: string;
defaultDistrict?: string;
onChange?: (state: string, district: string) => void;
onStateChange?: (state: string, stateCode: string) => void;
onDistrictChange?: (district: string, stateCode: string) => void;
placeholder?: {
state?: string;
district?: string;
};
validation?: {
required?: boolean;
customValidation?: (state: string, district: string) => boolean;
};
displayStateCode?: boolean;
}
export interface StateDistrictSelection {
state: string;
stateCode: string;
district: string;
}
export interface ValidationResult {
isValid: boolean;
errors: string[];
}
export type FilterFunction = (state: State) => boolean;
export declare const STATE_NAMES: {
[key: string]: string;
};