@kopexa/sight
Version:
Kopexa Sight Design System — React component library for GRC applications
42 lines (40 loc) • 2.03 kB
TypeScript
/**
* ISO 3166-1 country data for the CountryPicker / FlagIcon.
*
* We only embed the alpha-2 ↔ alpha-3 mapping. Country **names** come from the
* runtime `Intl.DisplayNames` (locale-aware → i18n for free, nothing to
* translate or maintain), and **flags** are inline SVGs from `country-flag-icons`
* keyed by the alpha-2 code (see `FlagIcon`).
*/
/** ISO 3166-1: alpha-2 (uppercase) → alpha-3 (uppercase). Officially assigned. */
declare const ALPHA2_TO_ALPHA3: Record<string, string>;
/** ISO 3166-1 alpha-3 (uppercase) → alpha-2 (uppercase). */
declare const ALPHA3_TO_ALPHA2: Record<string, string>;
/** All alpha-2 codes (uppercase), sorted. */
declare const COUNTRY_ALPHA2: string[];
type CountryCodeFormat = "alpha2" | "alpha3";
/**
* Normalize any alpha-2 / alpha-3 code (any case) to uppercase alpha-2, or
* `undefined` if it is not a known country code.
*/
declare function toAlpha2(code: string | null | undefined): string | undefined;
/** Normalize any code to uppercase alpha-3, or `undefined` if unknown. */
declare function toAlpha3(code: string | null | undefined): string | undefined;
/** Return a code in the requested format. */
declare function toFormat(code: string | null | undefined, format: CountryCodeFormat): string | undefined;
/**
* Localized country name via `Intl.DisplayNames`. Accepts alpha-2 or alpha-3.
* `locale` defaults to the runtime default; pass the app locale for i18n.
*/
declare function getCountryName(code: string | null | undefined, locale?: string): string | undefined;
type Country = {
/** Uppercase alpha-2 (e.g. "DE"). */
alpha2: string;
/** Uppercase alpha-3 (e.g. "DEU"). */
alpha3: string;
/** Localized display name. */
name: string;
};
/** Build the localized, name-sorted country list for the given locale. */
declare function getCountries(locale?: string): Country[];
export { ALPHA2_TO_ALPHA3, ALPHA3_TO_ALPHA2, COUNTRY_ALPHA2, type Country, type CountryCodeFormat, getCountries, getCountryName, toAlpha2, toAlpha3, toFormat };