itube-specs 0.0.947 → 0.0.948

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.
@@ -161,10 +161,29 @@ const clientCountryName = computed(() => (
161
161
 
162
162
  const isCountryOpen = ref(false);
163
163
  const countryValue = ref('');
164
+
165
+ // Список стран приходит с API только по-английски — подписываем его тем же ICU-словарём,
166
+ // что и текущую страну, и пересортировываем коллатором: порядок с бэка — английский
167
+ // алфавит. Нераспознанный код `isoCodeToCountryName` вернёт как есть — тогда имя с API.
168
+ const localizedCountries = computed(() => {
169
+ const collator = new Intl.Collator(locale.value);
170
+
171
+ return countriesItems.value
172
+ .map((item) => {
173
+ const code = (item.key || '').toUpperCase();
174
+ const name = isoCodeToCountryName(code, locale.value);
175
+ const title = name === code ? item.title : name;
176
+ return { ...item, title, value: title, apiTitle: item.title };
177
+ })
178
+ .sort((a, b) => collator.compare(a.title, b.title));
179
+ });
180
+
181
+ // Ищем и по английскому имени: привычка набирать `germany` не должна ломаться на ru-локали
164
182
  const filteredCountries = computed(() => {
165
- if (!countryValue.value) return countriesItems.value;
183
+ if (!countryValue.value) return localizedCountries.value;
166
184
  const query = countryValue.value.toLowerCase();
167
- return countriesItems.value.filter(item => item.title.toLowerCase().includes(query));
185
+ return localizedCountries.value.filter(item => item.title.toLowerCase().includes(query)
186
+ || item.apiTitle.toLowerCase().includes(query));
168
187
  });
169
188
 
170
189
  function onCountryToggle(e: Event) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "itube-specs",
3
3
  "type": "module",
4
- "version": "0.0.947",
4
+ "version": "0.0.948",
5
5
  "main": "./nuxt.config.ts",
6
6
  "types": "./types/index.d.ts",
7
7
  "scripts": {