localized-regions 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
  [![types](https://img.shields.io/npm/types/localized-regions.svg)](./dist/index.d.ts)
7
7
 
8
8
  **Country, province and city data with bilingual localized labels and ISO 3166 codes.**
9
- Get country / province / city dropdown options with labels like `Spain (España)`, stable ISO
9
+ Get country / province / city dropdown options with labels like `España (Spain)`, stable ISO
10
10
  3166-1 and ISO 3166-2 codes, and the full set of **50 Spanish provinces** (not the 17
11
11
  autonomous communities). Framework-agnostic and TypeScript-first: the data drops straight into
12
12
  **react-select**, **MUI Autocomplete**, or any dropdown.
@@ -14,13 +14,13 @@ autonomous communities). Framework-agnostic and TypeScript-first: the data drops
14
14
  ```ts
15
15
  import { countryOptions, provinceOptions } from 'localized-regions';
16
16
 
17
- countryOptions('es'); // [{ value: 'ES', label: 'Spain (España)' }, { value: 'NL', label: 'Netherlands (Países Bajos)' }, ...]
17
+ countryOptions('es'); // [{ value: 'ES', label: 'España (Spain)' }, { value: 'NL', label: 'Nederland (Netherlands)' }, ...]
18
18
  provinceOptions('ES'); // [{ value: 'ES-MA', label: 'Málaga' }, { value: 'ES-B', label: 'Barcelona' }, ...]
19
19
  ```
20
20
 
21
21
  ## Features
22
22
 
23
- - **Bilingual / localized country labels** - `Spain (España)`, `Germany (Alemania)`, `France (Francia)`, computed from the browser-native `Intl.DisplayNames` for any locale.
23
+ - **Bilingual / localized country labels** - `España (Spain)`, `Deutschland (Germany)`, `Nederland (Netherlands)`, computed from the browser-native `Intl.DisplayNames` for any locale.
24
24
  - **Correct Spanish provinces** - all **50 provinces** with ISO 3166-2 codes and their parent autonomous community. (Popular datasets like `country-state-city` return only ~16 of them for Spain.)
25
25
  - **Stable, invoicing-safe values** - country = ISO 3166-1 code (`ES`), province = ISO 3166-2 code (`ES-MA`). Labels are display-only.
26
26
  - **Full city database** - cities for every country, sourced from `country-state-city` at runtime.
@@ -43,7 +43,7 @@ import {
43
43
  } from 'localized-regions';
44
44
 
45
45
  // Bilingual country labels (the locale drives the native part)
46
- getCountries({ locale: 'es' }); // [{ code:'ES', name:'Spain', localized:'España', label:'Spain (España)' }, ...]
46
+ getCountries({ locale: 'es' }); // [{ code:'ES', name:'Spain', localized:'España', label:'España (Spain)' }, ...]
47
47
  getCountries(); // English-only labels
48
48
 
49
49
  // Spain -> 50 provinces (ISO 3166-2 codes + community grouping)
@@ -53,11 +53,11 @@ getProvinces('ES'); // [{ code:'ES-MA', countryCode:'ES', name:'Má
53
53
  getCities('ES', 'ES-MA');
54
54
 
55
55
  // Ready-to-use dropdown options
56
- countryOptions('es'); // [{ value:'ES', label:'Spain (España)' }, ...]
56
+ countryOptions('es'); // [{ value:'ES', label:'España (Spain)' }, ...]
57
57
  provinceOptions('ES'); // [{ value:'ES-MA', label:'Málaga' }, ...]
58
58
  cityOptions('ES', 'ES-MA'); // [{ value:'Málaga', label:'Málaga' }, ...]
59
59
 
60
- formatCountryLabel('ES', 'es'); // "Spain (España)"
60
+ formatCountryLabel('ES', 'es'); // "España (Spain)"
61
61
  ```
62
62
 
63
63
  ### With react-select (editable / creatable dropdowns)
package/dist/index.d.ts CHANGED
@@ -1,13 +1,13 @@
1
1
  import { Country, CountryOption, Province, City, Option } from './types';
2
2
  /**
3
3
  * All countries. Pass a locale (e.g. "es") to get bilingual labels like
4
- * "Spain (España)". Omit or pass "en" for English-only labels.
4
+ * "España (Spain)". Omit or pass "en" for English-only labels.
5
5
  */
6
6
  export declare function getCountries(opts?: {
7
7
  locale?: string;
8
8
  }): CountryOption[];
9
9
  export declare function getCountry(code: string): Country | undefined;
10
- /** Bilingual (or English) display label for a single country code. */
10
+ /** Bilingual (Native (English)) or native-only display label for a single country code. */
11
11
  export declare function formatCountryLabel(code: string, locale?: string): string;
12
12
  /**
13
13
  * Provinces for a country. Spain returns the curated 50 Provinces (RAT-1776);
package/dist/index.js CHANGED
@@ -41,11 +41,11 @@ function displayName(code, locale) {
41
41
  }
42
42
  }
43
43
  function buildLabel(name, localized) {
44
- return localized && localized !== name ? `${name} (${localized})` : name;
44
+ return localized && localized !== name ? `${localized} (${name})` : name;
45
45
  }
46
46
  /**
47
47
  * All countries. Pass a locale (e.g. "es") to get bilingual labels like
48
- * "Spain (España)". Omit or pass "en" for English-only labels.
48
+ * "España (Spain)". Omit or pass "en" for English-only labels.
49
49
  */
50
50
  function getCountries(opts = {}) {
51
51
  const { locale } = opts;
@@ -57,7 +57,7 @@ function getCountries(opts = {}) {
57
57
  function getCountry(code) {
58
58
  return countries_1.default.find((c) => c.code === code.toUpperCase());
59
59
  }
60
- /** Bilingual (or English) display label for a single country code. */
60
+ /** Bilingual (Native (English)) or native-only display label for a single country code. */
61
61
  function formatCountryLabel(code, locale) {
62
62
  const c = getCountry(code);
63
63
  if (!c)
package/dist/types.d.ts CHANGED
@@ -10,7 +10,7 @@ export interface CountryOption {
10
10
  name: string;
11
11
  /** Name in the requested locale, e.g. "España" (undefined when locale is en/absent) */
12
12
  localized?: string;
13
- /** Display label, e.g. "Spain (España)" when localized, else "Spain" */
13
+ /** Display label, e.g. "España (Spain)" when localized, else "Spain" */
14
14
  label: string;
15
15
  }
16
16
  export interface Province {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "localized-regions",
3
- "version": "1.0.1",
4
- "description": "Country, province and city data with bilingual localized labels (e.g. \"Spain (España)\") and ISO 3166-1 / ISO 3166-2 codes. Ships all 50 Spanish provinces. Framework-agnostic, drop-in options for react-select and MUI dropdowns.",
3
+ "version": "1.0.2",
4
+ "description": "Country, province and city data with bilingual localized labels (e.g. \"España (Spain)\") and ISO 3166-1 / ISO 3166-2 codes. Ships all 50 Spanish provinces. Framework-agnostic, drop-in options for react-select and MUI dropdowns.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "files": [