localized-regions 1.0.2 → 1.1.0

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
@@ -24,6 +24,7 @@ provinceOptions('ES'); // [{ value: 'ES-MA', label: 'Málaga' }, { value: 'ES-B
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.
27
+ - **Correct Dutch cities** - the Netherlands is served from the official Dutch place register (BAG woonplaatsen), not `country-state-city`, whose NL list is 19% `Gemeente X` municipality records and missing roughly 1000 real places.
27
28
  - **Framework-agnostic** - no React / MUI / Chakra dependency. Plain data plus ready-to-use `{ value, label }` options.
28
29
  - **TypeScript types included.**
29
30
 
@@ -92,6 +93,7 @@ import { countryOptions } from 'localized-regions';
92
93
  | `getProvinces(countryCode)` | `Province[]` (Spain = curated 50) |
93
94
  | `getProvince(provinceCode)` | `Province` |
94
95
  | `getCities(countryCode, provinceCode?)` | `City[]` |
96
+ | `cityMatches(city, input)` | `boolean` - does this city match typed input, by name or alias |
95
97
  | `countryOptions(locale?)` | `Option[]` (`{ value, label }`) |
96
98
  | `provinceOptions(countryCode)` | `Option[]` |
97
99
  | `cityOptions(countryCode, provinceCode?)` | `Option[]` |
@@ -102,7 +104,8 @@ Data is generated at build time (`npm run generate`) and committed under `data/`
102
104
 
103
105
  - **Countries** - `Intl.DisplayNames` (English) plus a code list, 250 countries.
104
106
  - **Provinces** - `iso-3166-2` subdivisions. Spain is curated to 50 provinces, with 4 regional-language names aliased to their common form (Nafarroa -> Navarra, Balears -> Balearic Islands, Alacant -> Alicante, Castelló -> Castellón).
105
- - **Cities** - `country-state-city` at runtime.
107
+ - **Cities** - `country-state-city` at runtime, except the Netherlands.
108
+ - **Netherlands cities** - the official BAG woonplaats register, fetched at build time from the PDOK Locatieserver and baked into `data/cities-nl`. No runtime API call and no API key. Generation fails if a `Gemeente X` entry ever reappears.
106
109
 
107
110
  Regenerate after a data-source bump:
108
111
 
@@ -110,6 +113,33 @@ Regenerate after a data-source bump:
110
113
  npm run generate && npm run build
111
114
  ```
112
115
 
116
+ ## Netherlands cities
117
+
118
+ NL city data comes from the official Dutch place register (BAG woonplaatsen, via
119
+ the PDOK Locatieserver) rather than `country-state-city`, whose NL list contains
120
+ 325 `Gemeente X` municipality records and is missing roughly 1000 real places.
121
+
122
+ The Hague is returned as `Den Haag` - the name the municipality, PostNL and
123
+ Taaladvies all use for addresses. Its formal name `'s-Gravenhage` is kept as a
124
+ search alias on `City.aliases`, never as a separate selectable option. Use
125
+ `cityMatches` as your select's `filterOption` so aliases are searchable:
126
+
127
+ ```js
128
+ import { getCities, cityMatches } from 'localized-regions';
129
+
130
+ <Select
131
+ options={getCities('NL', 'NL-ZH')}
132
+ getOptionLabel={(c) => c.name}
133
+ getOptionValue={(c) => c.name}
134
+ filterOption={(option, input) => cityMatches(option.data, input)}
135
+ />
136
+ ```
137
+
138
+ `getProvinces('NL')` returns the 12 real provinces. Aruba, Curacao and Sint
139
+ Maarten are separate constituent countries, and Bonaire, Saba and Sint Eustatius
140
+ are Caribbean special municipalities; ISO 3166-2 lists all six under NL, but they
141
+ are not provinces and have no cities, so they are excluded.
142
+
113
143
  ## Notes and limitations
114
144
 
115
145
  - **Spain city cascade is community-level.** The source city data groups Spanish cities under autonomous communities, not the 50 provinces, so `getCities('ES', 'ES-MA')` returns the parent community's cities (best-effort). City is best treated as a free-text field.
@@ -0,0 +1,3 @@
1
+ import type { City } from '../types';
2
+ declare const data: Record<string, City[]>;
3
+ export default data;