@longline/aqua-ui 1.0.322 → 1.0.323
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.
|
@@ -16,6 +16,8 @@ import { getCountries } from '../../formatters/CountryFormatter/CountryLocales';
|
|
|
16
16
|
import { CountryFormatter } from '../../formatters/CountryFormatter';
|
|
17
17
|
// Get country keys ("NL", "PT", "ZW"..) only once. They never change.
|
|
18
18
|
var countryKeys = Object.keys(Countries);
|
|
19
|
+
// Strip diacritics for search matching (e.g. "pai" matches "Países").
|
|
20
|
+
var stripDiacritics = function (s) { return s.normalize('NFD').replace(/[\u0300-\u036F]/g, ''); };
|
|
19
21
|
/**
|
|
20
22
|
* A dropdown preconfigured for country selection. Shows country flags.
|
|
21
23
|
* By default, this will show all countries. A pre-filtered list of country
|
|
@@ -29,7 +31,7 @@ var CountryDropdown = function (props) {
|
|
|
29
31
|
}, [localizedNames]);
|
|
30
32
|
var data = sortedKeys
|
|
31
33
|
.filter(function (c) { return !props.countries || props.countries.includes(c.toUpperCase()); })
|
|
32
|
-
.filter(function (c) { return localizedNames[c].toLocaleLowerCase().includes((q || "").toLocaleLowerCase()); });
|
|
34
|
+
.filter(function (c) { return stripDiacritics(localizedNames[c]).toLocaleLowerCase().includes(stripDiacritics(q || "").toLocaleLowerCase()); });
|
|
33
35
|
return (React.createElement(Dropdown, __assign({ data: data, onSearch: setQ, placeholder: props.placeholder || "Country", label: function (item) { return React.createElement(CountryFormatter, { type: 'both', value: item, locale: props.locale }); } }, props),
|
|
34
36
|
React.createElement(Dropdown.Column, null, function (item) { return React.createElement(CountryFormatter, { type: 'both', value: item, locale: props.locale }); })));
|
|
35
37
|
};
|