Skip to content

Commit

Permalink
Country search: support initials
Browse files Browse the repository at this point in the history
  • Loading branch information
jackocnr committed Aug 19, 2024
1 parent 8fd385a commit 3d17583
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 13 deletions.
3 changes: 2 additions & 1 deletion build/js/intlTelInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -2211,8 +2211,9 @@ var factoryOutput = (() => {
for (let i = 0; i < this.countries.length; i++) {
const c = this.countries[i];
const normalisedCountryName = normaliseString(c.name);
const countryInitials = c.name.split(/[^a-zA-ZÀ-ÿа-яА-Я]/).map((word) => word[0]).join("").toLowerCase();
const fullDialCode = `+${c.dialCode}`;
if (isReset || normalisedCountryName.includes(normalisedQuery) || fullDialCode.includes(normalisedQuery) || c.iso2.includes(normalisedQuery)) {
if (isReset || normalisedCountryName.includes(normalisedQuery) || fullDialCode.includes(normalisedQuery) || c.iso2.includes(normalisedQuery) || countryInitials.includes(normalisedQuery)) {
const listItem = c.nodeById[this.id];
if (listItem) {
this.countryList.appendChild(listItem);
Expand Down
2 changes: 1 addition & 1 deletion build/js/intlTelInput.min.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion build/js/intlTelInputWithUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2210,8 +2210,9 @@ var factoryOutput = (() => {
for (let i = 0; i < this.countries.length; i++) {
const c = this.countries[i];
const normalisedCountryName = normaliseString(c.name);
const countryInitials = c.name.split(/[^a-zA-ZÀ-ÿа-яА-Я]/).map((word) => word[0]).join("").toLowerCase();
const fullDialCode = `+${c.dialCode}`;
if (isReset || normalisedCountryName.includes(normalisedQuery) || fullDialCode.includes(normalisedQuery) || c.iso2.includes(normalisedQuery)) {
if (isReset || normalisedCountryName.includes(normalisedQuery) || fullDialCode.includes(normalisedQuery) || c.iso2.includes(normalisedQuery) || countryInitials.includes(normalisedQuery)) {
const listItem = c.nodeById[this.id];
if (listItem) {
this.countryList.appendChild(listItem);
Expand Down
2 changes: 1 addition & 1 deletion build/js/intlTelInputWithUtils.min.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion react/build/IntlTelInput.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2206,8 +2206,9 @@ var Iti = class {
for (let i = 0; i < this.countries.length; i++) {
const c = this.countries[i];
const normalisedCountryName = normaliseString(c.name);
const countryInitials = c.name.split(/[^a-zA-ZÀ-ÿа-яА-Я]/).map((word) => word[0]).join("").toLowerCase();
const fullDialCode = `+${c.dialCode}`;
if (isReset || normalisedCountryName.includes(normalisedQuery) || fullDialCode.includes(normalisedQuery) || c.iso2.includes(normalisedQuery)) {
if (isReset || normalisedCountryName.includes(normalisedQuery) || fullDialCode.includes(normalisedQuery) || c.iso2.includes(normalisedQuery) || countryInitials.includes(normalisedQuery)) {
const listItem = c.nodeById[this.id];
if (listItem) {
this.countryList.appendChild(listItem);
Expand Down
3 changes: 2 additions & 1 deletion react/build/IntlTelInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -2170,8 +2170,9 @@ var Iti = class {
for (let i = 0; i < this.countries.length; i++) {
const c = this.countries[i];
const normalisedCountryName = normaliseString(c.name);
const countryInitials = c.name.split(/[^a-zA-ZÀ-ÿа-яА-Я]/).map((word) => word[0]).join("").toLowerCase();
const fullDialCode = `+${c.dialCode}`;
if (isReset || normalisedCountryName.includes(normalisedQuery) || fullDialCode.includes(normalisedQuery) || c.iso2.includes(normalisedQuery)) {
if (isReset || normalisedCountryName.includes(normalisedQuery) || fullDialCode.includes(normalisedQuery) || c.iso2.includes(normalisedQuery) || countryInitials.includes(normalisedQuery)) {
const listItem = c.nodeById[this.id];
if (listItem) {
this.countryList.appendChild(listItem);
Expand Down
3 changes: 2 additions & 1 deletion react/build/IntlTelInputWithUtils.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2206,8 +2206,9 @@ var Iti = class {
for (let i = 0; i < this.countries.length; i++) {
const c = this.countries[i];
const normalisedCountryName = normaliseString(c.name);
const countryInitials = c.name.split(/[^a-zA-ZÀ-ÿа-яА-Я]/).map((word) => word[0]).join("").toLowerCase();
const fullDialCode = `+${c.dialCode}`;
if (isReset || normalisedCountryName.includes(normalisedQuery) || fullDialCode.includes(normalisedQuery) || c.iso2.includes(normalisedQuery)) {
if (isReset || normalisedCountryName.includes(normalisedQuery) || fullDialCode.includes(normalisedQuery) || c.iso2.includes(normalisedQuery) || countryInitials.includes(normalisedQuery)) {
const listItem = c.nodeById[this.id];
if (listItem) {
this.countryList.appendChild(listItem);
Expand Down
3 changes: 2 additions & 1 deletion react/build/IntlTelInputWithUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2170,8 +2170,9 @@ var Iti = class {
for (let i = 0; i < this.countries.length; i++) {
const c = this.countries[i];
const normalisedCountryName = normaliseString(c.name);
const countryInitials = c.name.split(/[^a-zA-ZÀ-ÿа-яА-Я]/).map((word) => word[0]).join("").toLowerCase();
const fullDialCode = `+${c.dialCode}`;
if (isReset || normalisedCountryName.includes(normalisedQuery) || fullDialCode.includes(normalisedQuery) || c.iso2.includes(normalisedQuery)) {
if (isReset || normalisedCountryName.includes(normalisedQuery) || fullDialCode.includes(normalisedQuery) || c.iso2.includes(normalisedQuery) || countryInitials.includes(normalisedQuery)) {
const listItem = c.nodeById[this.id];
if (listItem) {
this.countryList.appendChild(listItem);
Expand Down
3 changes: 2 additions & 1 deletion react/demo/set-number-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -25757,8 +25757,9 @@
for (let i = 0; i < this.countries.length; i++) {
const c = this.countries[i];
const normalisedCountryName = normaliseString(c.name);
const countryInitials = c.name.split(/[^a-zA-ZÀ-ÿа-яА-Я]/).map((word) => word[0]).join("").toLowerCase();
const fullDialCode = `+${c.dialCode}`;
if (isReset || normalisedCountryName.includes(normalisedQuery) || fullDialCode.includes(normalisedQuery) || c.iso2.includes(normalisedQuery)) {
if (isReset || normalisedCountryName.includes(normalisedQuery) || fullDialCode.includes(normalisedQuery) || c.iso2.includes(normalisedQuery) || countryInitials.includes(normalisedQuery)) {
const listItem = c.nodeById[this.id];
if (listItem) {
this.countryList.appendChild(listItem);
Expand Down
3 changes: 2 additions & 1 deletion react/demo/simple-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -25757,8 +25757,9 @@
for (let i = 0; i < this.countries.length; i++) {
const c = this.countries[i];
const normalisedCountryName = normaliseString(c.name);
const countryInitials = c.name.split(/[^a-zA-ZÀ-ÿа-яА-Я]/).map((word) => word[0]).join("").toLowerCase();
const fullDialCode = `+${c.dialCode}`;
if (isReset || normalisedCountryName.includes(normalisedQuery) || fullDialCode.includes(normalisedQuery) || c.iso2.includes(normalisedQuery)) {
if (isReset || normalisedCountryName.includes(normalisedQuery) || fullDialCode.includes(normalisedQuery) || c.iso2.includes(normalisedQuery) || countryInitials.includes(normalisedQuery)) {
const listItem = c.nodeById[this.id];
if (listItem) {
this.countryList.appendChild(listItem);
Expand Down
3 changes: 2 additions & 1 deletion react/demo/toggle-disabled-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -25757,8 +25757,9 @@
for (let i = 0; i < this.countries.length; i++) {
const c = this.countries[i];
const normalisedCountryName = normaliseString(c.name);
const countryInitials = c.name.split(/[^a-zA-ZÀ-ÿа-яА-Я]/).map((word) => word[0]).join("").toLowerCase();
const fullDialCode = `+${c.dialCode}`;
if (isReset || normalisedCountryName.includes(normalisedQuery) || fullDialCode.includes(normalisedQuery) || c.iso2.includes(normalisedQuery)) {
if (isReset || normalisedCountryName.includes(normalisedQuery) || fullDialCode.includes(normalisedQuery) || c.iso2.includes(normalisedQuery) || countryInitials.includes(normalisedQuery)) {
const listItem = c.nodeById[this.id];
if (listItem) {
this.countryList.appendChild(listItem);
Expand Down
3 changes: 2 additions & 1 deletion react/demo/validation-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -25757,8 +25757,9 @@
for (let i = 0; i < this.countries.length; i++) {
const c = this.countries[i];
const normalisedCountryName = normaliseString(c.name);
const countryInitials = c.name.split(/[^a-zA-ZÀ-ÿа-яА-Я]/).map((word) => word[0]).join("").toLowerCase();
const fullDialCode = `+${c.dialCode}`;
if (isReset || normalisedCountryName.includes(normalisedQuery) || fullDialCode.includes(normalisedQuery) || c.iso2.includes(normalisedQuery)) {
if (isReset || normalisedCountryName.includes(normalisedQuery) || fullDialCode.includes(normalisedQuery) || c.iso2.includes(normalisedQuery) || countryInitials.includes(normalisedQuery)) {
const listItem = c.nodeById[this.id];
if (listItem) {
this.countryList.appendChild(listItem);
Expand Down
5 changes: 4 additions & 1 deletion src/js/intl-tel-input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1248,12 +1248,15 @@ export class Iti {
for (let i = 0; i < this.countries.length; i++) {
const c = this.countries[i];
const normalisedCountryName = normaliseString(c.name);
//* Initials: split on non-alpha chars (ignore ampersand, hyphen, dot etc) and take the first letter of each part.
const countryInitials = c.name.split(/[^a-zA-ZÀ-ÿа-яА-Я]/).map(word => word[0]).join("").toLowerCase();
const fullDialCode = `+${c.dialCode}`;
if (
isReset ||
normalisedCountryName.includes(normalisedQuery) ||
fullDialCode.includes(normalisedQuery) ||
c.iso2.includes(normalisedQuery)
c.iso2.includes(normalisedQuery) ||
countryInitials.includes(normalisedQuery)
) {
const listItem = c.nodeById[this.id];
if (listItem) {
Expand Down

0 comments on commit 3d17583

Please sign in to comment.