intl-tel-input 25.4.8 → 25.5.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "intl-tel-input",
3
- "version": "25.4.8",
3
+ "version": "25.5.0",
4
4
  "description": "A JavaScript plugin for entering and validating international telephone numbers",
5
5
  "keywords": [
6
6
  "international",
package/react/README.md CHANGED
@@ -28,7 +28,7 @@ import "intl-tel-input/styles";
28
28
 
29
29
  See the [Validation demo](https://github.com/jackocnr/intl-tel-input/blob/master/react/demo/validation/ValidationApp.tsx) for a more fleshed-out example of how to handle validation.
30
30
 
31
- A note on the utils script (~260KB): if you're lazy loading the IntlTelInput chunk (and so less worried about filesize) then you can just import IntlTelInput from `"intl-tel-input/reactWithUtils"`, to include the utils script. Alternatively, if you use the main `"intl-tel-input/react"` import, then you should couple this with the `loadUtils` initialisation option - you will need to host the [utils.js](https://github.com/jackocnr/intl-tel-input/blob/master/build/js/utils.js) file, and then set the `loadUtils` option to that URL, or alternatively just point it to a CDN hosted version e.g. `"https://cdn.jsdelivr.net/npm/intl-tel-input@25.4.8/build/js/utils.js"`.
31
+ A note on the utils script (~260KB): if you're lazy loading the IntlTelInput chunk (and so less worried about filesize) then you can just import IntlTelInput from `"intl-tel-input/reactWithUtils"`, to include the utils script. Alternatively, if you use the main `"intl-tel-input/react"` import, then you should couple this with the `loadUtils` initialisation option - you will need to host the [utils.js](https://github.com/jackocnr/intl-tel-input/blob/master/build/js/utils.js) file, and then set the `loadUtils` option to that URL, or alternatively just point it to a CDN hosted version e.g. `"https://cdn.jsdelivr.net/npm/intl-tel-input@25.5.0/build/js/utils.js"`.
32
32
 
33
33
  ## Props
34
34
  Here's a list of all of the current props you can pass to the IntlTelInput React component.
@@ -2494,16 +2494,45 @@ var Iti = class {
2494
2494
  let noCountriesAddedYet = true;
2495
2495
  this.countryList.innerHTML = "";
2496
2496
  const normalisedQuery = normaliseString(query);
2497
+ const queryLength = normalisedQuery.length;
2498
+ const iso2Matches = [];
2499
+ const nameStartWith = [];
2500
+ const nameContains = [];
2501
+ const dialCodeMatches = [];
2502
+ const dialCodeContains = [];
2503
+ const initialsMatches = [];
2497
2504
  for (let i = 0; i < this.countries.length; i++) {
2498
2505
  const c = this.countries[i];
2499
2506
  const normalisedCountryName = normaliseString(c.name);
2500
2507
  const countryInitials = c.name.split(/[^a-zA-ZÀ-ÿа-яА-Я]/).map((word) => word[0]).join("").toLowerCase();
2501
- const fullDialCode = `+${c.dialCode}`;
2502
- if (isReset || normalisedCountryName.includes(normalisedQuery) || fullDialCode.includes(normalisedQuery) || c.iso2.includes(normalisedQuery) || countryInitials.includes(normalisedQuery)) {
2503
- const listItem = c.nodeById[this.id];
2504
- if (listItem) {
2505
- this.countryList.appendChild(listItem);
2506
- }
2508
+ if (isReset || queryLength === 0) {
2509
+ nameContains.push(c);
2510
+ } else if (c.iso2.toLowerCase() === normalisedQuery) {
2511
+ iso2Matches.push(c);
2512
+ } else if (normalisedCountryName.startsWith(normalisedQuery)) {
2513
+ nameStartWith.push(c);
2514
+ } else if (normalisedCountryName.includes(normalisedQuery)) {
2515
+ nameContains.push(c);
2516
+ } else if (normalisedQuery === c.dialCode || normalisedQuery === `+${c.dialCode}`) {
2517
+ dialCodeMatches.push(c);
2518
+ } else if (`+${c.dialCode}`.includes(normalisedQuery)) {
2519
+ dialCodeContains.push(c);
2520
+ } else if (countryInitials.includes(normalisedQuery)) {
2521
+ initialsMatches.push(c);
2522
+ }
2523
+ }
2524
+ const matchedCountries = [
2525
+ ...iso2Matches.sort((a, b) => a.priority - b.priority),
2526
+ ...nameStartWith.sort((a, b) => a.priority - b.priority),
2527
+ ...nameContains.sort((a, b) => a.priority - b.priority),
2528
+ ...dialCodeMatches.sort((a, b) => a.priority - b.priority),
2529
+ ...dialCodeContains.sort((a, b) => a.priority - b.priority),
2530
+ ...initialsMatches.sort((a, b) => a.priority - b.priority)
2531
+ ];
2532
+ for (const c of matchedCountries) {
2533
+ const listItem = c.nodeById[this.id];
2534
+ if (listItem) {
2535
+ this.countryList.appendChild(listItem);
2507
2536
  if (noCountriesAddedYet) {
2508
2537
  this._highlightListItem(listItem, false);
2509
2538
  noCountriesAddedYet = false;
@@ -3173,7 +3202,7 @@ var intlTelInput = Object.assign(
3173
3202
  attachUtils,
3174
3203
  startedLoadingUtilsScript: false,
3175
3204
  startedLoadingAutoCountry: false,
3176
- version: "25.4.8"
3205
+ version: "25.5.0"
3177
3206
  }
3178
3207
  );
3179
3208
  var intl_tel_input_default = intlTelInput;
@@ -2458,16 +2458,45 @@ var Iti = class {
2458
2458
  let noCountriesAddedYet = true;
2459
2459
  this.countryList.innerHTML = "";
2460
2460
  const normalisedQuery = normaliseString(query);
2461
+ const queryLength = normalisedQuery.length;
2462
+ const iso2Matches = [];
2463
+ const nameStartWith = [];
2464
+ const nameContains = [];
2465
+ const dialCodeMatches = [];
2466
+ const dialCodeContains = [];
2467
+ const initialsMatches = [];
2461
2468
  for (let i = 0; i < this.countries.length; i++) {
2462
2469
  const c = this.countries[i];
2463
2470
  const normalisedCountryName = normaliseString(c.name);
2464
2471
  const countryInitials = c.name.split(/[^a-zA-ZÀ-ÿа-яА-Я]/).map((word) => word[0]).join("").toLowerCase();
2465
- const fullDialCode = `+${c.dialCode}`;
2466
- if (isReset || normalisedCountryName.includes(normalisedQuery) || fullDialCode.includes(normalisedQuery) || c.iso2.includes(normalisedQuery) || countryInitials.includes(normalisedQuery)) {
2467
- const listItem = c.nodeById[this.id];
2468
- if (listItem) {
2469
- this.countryList.appendChild(listItem);
2470
- }
2472
+ if (isReset || queryLength === 0) {
2473
+ nameContains.push(c);
2474
+ } else if (c.iso2.toLowerCase() === normalisedQuery) {
2475
+ iso2Matches.push(c);
2476
+ } else if (normalisedCountryName.startsWith(normalisedQuery)) {
2477
+ nameStartWith.push(c);
2478
+ } else if (normalisedCountryName.includes(normalisedQuery)) {
2479
+ nameContains.push(c);
2480
+ } else if (normalisedQuery === c.dialCode || normalisedQuery === `+${c.dialCode}`) {
2481
+ dialCodeMatches.push(c);
2482
+ } else if (`+${c.dialCode}`.includes(normalisedQuery)) {
2483
+ dialCodeContains.push(c);
2484
+ } else if (countryInitials.includes(normalisedQuery)) {
2485
+ initialsMatches.push(c);
2486
+ }
2487
+ }
2488
+ const matchedCountries = [
2489
+ ...iso2Matches.sort((a, b) => a.priority - b.priority),
2490
+ ...nameStartWith.sort((a, b) => a.priority - b.priority),
2491
+ ...nameContains.sort((a, b) => a.priority - b.priority),
2492
+ ...dialCodeMatches.sort((a, b) => a.priority - b.priority),
2493
+ ...dialCodeContains.sort((a, b) => a.priority - b.priority),
2494
+ ...initialsMatches.sort((a, b) => a.priority - b.priority)
2495
+ ];
2496
+ for (const c of matchedCountries) {
2497
+ const listItem = c.nodeById[this.id];
2498
+ if (listItem) {
2499
+ this.countryList.appendChild(listItem);
2471
2500
  if (noCountriesAddedYet) {
2472
2501
  this._highlightListItem(listItem, false);
2473
2502
  noCountriesAddedYet = false;
@@ -3137,7 +3166,7 @@ var intlTelInput = Object.assign(
3137
3166
  attachUtils,
3138
3167
  startedLoadingUtilsScript: false,
3139
3168
  startedLoadingAutoCountry: false,
3140
- version: "25.4.8"
3169
+ version: "25.5.0"
3141
3170
  }
3142
3171
  );
3143
3172
  var intl_tel_input_default = intlTelInput;
@@ -2494,16 +2494,45 @@ var Iti = class {
2494
2494
  let noCountriesAddedYet = true;
2495
2495
  this.countryList.innerHTML = "";
2496
2496
  const normalisedQuery = normaliseString(query);
2497
+ const queryLength = normalisedQuery.length;
2498
+ const iso2Matches = [];
2499
+ const nameStartWith = [];
2500
+ const nameContains = [];
2501
+ const dialCodeMatches = [];
2502
+ const dialCodeContains = [];
2503
+ const initialsMatches = [];
2497
2504
  for (let i = 0; i < this.countries.length; i++) {
2498
2505
  const c = this.countries[i];
2499
2506
  const normalisedCountryName = normaliseString(c.name);
2500
2507
  const countryInitials = c.name.split(/[^a-zA-ZÀ-ÿа-яА-Я]/).map((word) => word[0]).join("").toLowerCase();
2501
- const fullDialCode = `+${c.dialCode}`;
2502
- if (isReset || normalisedCountryName.includes(normalisedQuery) || fullDialCode.includes(normalisedQuery) || c.iso2.includes(normalisedQuery) || countryInitials.includes(normalisedQuery)) {
2503
- const listItem = c.nodeById[this.id];
2504
- if (listItem) {
2505
- this.countryList.appendChild(listItem);
2506
- }
2508
+ if (isReset || queryLength === 0) {
2509
+ nameContains.push(c);
2510
+ } else if (c.iso2.toLowerCase() === normalisedQuery) {
2511
+ iso2Matches.push(c);
2512
+ } else if (normalisedCountryName.startsWith(normalisedQuery)) {
2513
+ nameStartWith.push(c);
2514
+ } else if (normalisedCountryName.includes(normalisedQuery)) {
2515
+ nameContains.push(c);
2516
+ } else if (normalisedQuery === c.dialCode || normalisedQuery === `+${c.dialCode}`) {
2517
+ dialCodeMatches.push(c);
2518
+ } else if (`+${c.dialCode}`.includes(normalisedQuery)) {
2519
+ dialCodeContains.push(c);
2520
+ } else if (countryInitials.includes(normalisedQuery)) {
2521
+ initialsMatches.push(c);
2522
+ }
2523
+ }
2524
+ const matchedCountries = [
2525
+ ...iso2Matches.sort((a, b) => a.priority - b.priority),
2526
+ ...nameStartWith.sort((a, b) => a.priority - b.priority),
2527
+ ...nameContains.sort((a, b) => a.priority - b.priority),
2528
+ ...dialCodeMatches.sort((a, b) => a.priority - b.priority),
2529
+ ...dialCodeContains.sort((a, b) => a.priority - b.priority),
2530
+ ...initialsMatches.sort((a, b) => a.priority - b.priority)
2531
+ ];
2532
+ for (const c of matchedCountries) {
2533
+ const listItem = c.nodeById[this.id];
2534
+ if (listItem) {
2535
+ this.countryList.appendChild(listItem);
2507
2536
  if (noCountriesAddedYet) {
2508
2537
  this._highlightListItem(listItem, false);
2509
2538
  noCountriesAddedYet = false;
@@ -3173,7 +3202,7 @@ var intlTelInput = Object.assign(
3173
3202
  attachUtils,
3174
3203
  startedLoadingUtilsScript: false,
3175
3204
  startedLoadingAutoCountry: false,
3176
- version: "25.4.8"
3205
+ version: "25.5.0"
3177
3206
  }
3178
3207
  );
3179
3208
  var intl_tel_input_default = intlTelInput;
@@ -2458,16 +2458,45 @@ var Iti = class {
2458
2458
  let noCountriesAddedYet = true;
2459
2459
  this.countryList.innerHTML = "";
2460
2460
  const normalisedQuery = normaliseString(query);
2461
+ const queryLength = normalisedQuery.length;
2462
+ const iso2Matches = [];
2463
+ const nameStartWith = [];
2464
+ const nameContains = [];
2465
+ const dialCodeMatches = [];
2466
+ const dialCodeContains = [];
2467
+ const initialsMatches = [];
2461
2468
  for (let i = 0; i < this.countries.length; i++) {
2462
2469
  const c = this.countries[i];
2463
2470
  const normalisedCountryName = normaliseString(c.name);
2464
2471
  const countryInitials = c.name.split(/[^a-zA-ZÀ-ÿа-яА-Я]/).map((word) => word[0]).join("").toLowerCase();
2465
- const fullDialCode = `+${c.dialCode}`;
2466
- if (isReset || normalisedCountryName.includes(normalisedQuery) || fullDialCode.includes(normalisedQuery) || c.iso2.includes(normalisedQuery) || countryInitials.includes(normalisedQuery)) {
2467
- const listItem = c.nodeById[this.id];
2468
- if (listItem) {
2469
- this.countryList.appendChild(listItem);
2470
- }
2472
+ if (isReset || queryLength === 0) {
2473
+ nameContains.push(c);
2474
+ } else if (c.iso2.toLowerCase() === normalisedQuery) {
2475
+ iso2Matches.push(c);
2476
+ } else if (normalisedCountryName.startsWith(normalisedQuery)) {
2477
+ nameStartWith.push(c);
2478
+ } else if (normalisedCountryName.includes(normalisedQuery)) {
2479
+ nameContains.push(c);
2480
+ } else if (normalisedQuery === c.dialCode || normalisedQuery === `+${c.dialCode}`) {
2481
+ dialCodeMatches.push(c);
2482
+ } else if (`+${c.dialCode}`.includes(normalisedQuery)) {
2483
+ dialCodeContains.push(c);
2484
+ } else if (countryInitials.includes(normalisedQuery)) {
2485
+ initialsMatches.push(c);
2486
+ }
2487
+ }
2488
+ const matchedCountries = [
2489
+ ...iso2Matches.sort((a, b) => a.priority - b.priority),
2490
+ ...nameStartWith.sort((a, b) => a.priority - b.priority),
2491
+ ...nameContains.sort((a, b) => a.priority - b.priority),
2492
+ ...dialCodeMatches.sort((a, b) => a.priority - b.priority),
2493
+ ...dialCodeContains.sort((a, b) => a.priority - b.priority),
2494
+ ...initialsMatches.sort((a, b) => a.priority - b.priority)
2495
+ ];
2496
+ for (const c of matchedCountries) {
2497
+ const listItem = c.nodeById[this.id];
2498
+ if (listItem) {
2499
+ this.countryList.appendChild(listItem);
2471
2500
  if (noCountriesAddedYet) {
2472
2501
  this._highlightListItem(listItem, false);
2473
2502
  noCountriesAddedYet = false;
@@ -3137,7 +3166,7 @@ var intlTelInput = Object.assign(
3137
3166
  attachUtils,
3138
3167
  startedLoadingUtilsScript: false,
3139
3168
  startedLoadingAutoCountry: false,
3140
- version: "25.4.8"
3169
+ version: "25.5.0"
3141
3170
  }
3142
3171
  );
3143
3172
  var intl_tel_input_default = intlTelInput;
package/vue/README.md CHANGED
@@ -34,7 +34,7 @@ See the [Validation demo](https://github.com/jackocnr/intl-tel-input/blob/master
34
34
  "vue:demo": "vite --config vue/demo/[demo variant]/vite.config.js"
35
35
  ```
36
36
 
37
- A note on the utils script (~260KB): if you're lazy loading the IntlTelInput chunk (and so less worried about filesize) then you can just import IntlTelInput from `"intl-tel-input/vueWithUtils"`, to include the utils script. Alternatively, if you use the main `"intl-tel-input/vue"` import, then you should couple this with the `loadUtils` initialisation option - you will need to host the [utils.js](https://github.com/jackocnr/intl-tel-input/blob/master/build/js/utils.js) file, and then set the `loadUtils` option to that URL, or alternatively just point it to a CDN hosted version e.g. `"https://cdn.jsdelivr.net/npm/intl-tel-input@25.4.8/build/js/utils.js"`.
37
+ A note on the utils script (~260KB): if you're lazy loading the IntlTelInput chunk (and so less worried about filesize) then you can just import IntlTelInput from `"intl-tel-input/vueWithUtils"`, to include the utils script. Alternatively, if you use the main `"intl-tel-input/vue"` import, then you should couple this with the `loadUtils` initialisation option - you will need to host the [utils.js](https://github.com/jackocnr/intl-tel-input/blob/master/build/js/utils.js) file, and then set the `loadUtils` option to that URL, or alternatively just point it to a CDN hosted version e.g. `"https://cdn.jsdelivr.net/npm/intl-tel-input@25.5.0/build/js/utils.js"`.
38
38
 
39
39
  ## Props
40
40
  Here's a list of all of the current props you can pass to the IntlTelInput Vue component.