@osimatic/helpers-js 1.5.30 → 1.5.31

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/location.js CHANGED
@@ -24,7 +24,7 @@ class Country {
24
24
  return [...countryCode.toUpperCase()].map(c => String.fromCodePoint(0x1F1E6 - 65 + c.charCodeAt(0))).join('');
25
25
  }
26
26
 
27
- static fillSelect(select, defaultValue=null, showFlags=false, countriesList=null, addNoneValue=false, noneLabel='- Aucun -', locale='fr-FR') {
27
+ static fillSelect(select, defaultValue=null, showFlags=false, locale='fr-FR', countriesList=null, addNoneValue=false, noneLabel='- Aucun -') {
28
28
  select = toEl(select);
29
29
  if (!select) {
30
30
  return;
@@ -40,11 +40,10 @@ class Country {
40
40
  entries.forEach(([countryCode, countryName]) => {
41
41
  let attrs = '';
42
42
  if (showFlags) {
43
- if (typeof Country.flagsPath !== 'undefined') {
43
+ /*if (typeof Country.flagsPath !== 'undefined') {
44
44
  attrs = ' data-thumbnail="' + Country.getFlagPath(countryCode) + '"';
45
- } else {
46
- attrs = ' data-content="<span class=&quot;fi fi-' + countryCode.toLowerCase() + '&quot;></span> ' + countryName + '"';
47
- }
45
+ } else {*/
46
+ attrs = ' data-content="<span class=&quot;fi fi-' + countryCode.toLowerCase() + '&quot;></span> ' + countryName + '"';
48
47
  }
49
48
  select.insertAdjacentHTML('beforeend', '<option value="' + countryCode + '"' + attrs + '>' + countryName + '</option>');
50
49
  });
@@ -54,8 +53,8 @@ class Country {
54
53
  }
55
54
  }
56
55
 
57
- static fillSelectWithFlags(select, defaultValue=null, countriesList=null, addNoneValue=false, noneLabel='- Aucun -', locale='fr-FR') {
58
- return Country.fillSelect(select, defaultValue, true, countriesList, addNoneValue, noneLabel, locale);
56
+ static fillSelectWithFlags(select, defaultValue=null, locale='fr-FR', countriesList=null, addNoneValue=false, noneLabel='- Aucun -') {
57
+ return Country.fillSelect(select, defaultValue, true, locale, countriesList, addNoneValue, noneLabel);
59
58
  }
60
59
 
61
60
  static getCountryName(countryCode, locale='fr-FR') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@osimatic/helpers-js",
3
- "version": "1.5.30",
3
+ "version": "1.5.31",
4
4
  "main": "main.js",
5
5
  "scripts": {
6
6
  "test": "jest",
@@ -30,6 +30,12 @@ describe('Country', () => {
30
30
  expect(Country.getCountryName('DE', 'de')).toBeTruthy();
31
31
  });
32
32
 
33
+ test('should handle full locale with region (fr-FR, en-US)', () => {
34
+ expect(Country.getCountryName('FR', 'fr-FR')).toBe('France');
35
+ expect(Country.getCountryName('US', 'fr-FR')).toBe("États-Unis d'Amérique");
36
+ expect(Country.getCountryName('US', 'en-US')).toBe('United States of America');
37
+ });
38
+
33
39
  test('should return the code itself if country not found', () => {
34
40
  expect(Country.getCountryName('XX')).toBe('XX');
35
41
  expect(Country.getCountryName('ZZZ')).toBe('ZZZ');