Skip to content

Commit

Permalink
If theres only one country then use it
Browse files Browse the repository at this point in the history
  • Loading branch information
jackocnr committed Aug 23, 2024
1 parent cf56a22 commit b967582
Show file tree
Hide file tree
Showing 15 changed files with 226 additions and 191 deletions.
3 changes: 3 additions & 0 deletions build/js/intlTelInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -1763,6 +1763,9 @@ var factoryOutput = (() => {
if (this.options.useFullscreenPopup) {
this.options.fixDropdownWidth = false;
}
if (this.options.onlyCountries.length === 1) {
this.options.initialCountry = this.options.onlyCountries[0];
}
if (this.options.separateDialCode) {
this.options.allowDropdown = true;
this.options.nationalMode = false;
Expand Down
2 changes: 1 addition & 1 deletion build/js/intlTelInput.min.js

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion build/js/intlTelInputWithUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1762,6 +1762,9 @@ var factoryOutput = (() => {
if (this.options.useFullscreenPopup) {
this.options.fixDropdownWidth = false;
}
if (this.options.onlyCountries.length === 1) {
this.options.initialCountry = this.options.onlyCountries[0];
}
if (this.options.separateDialCode) {
this.options.allowDropdown = true;
this.options.nationalMode = false;
Expand Down Expand Up @@ -3054,7 +3057,7 @@ var factoryOutput = (() => {
if (!intlTelInput.utils && !intlTelInput.startedLoadingUtilsScript) {
intlTelInput.startedLoadingUtilsScript = true;
return new Promise((resolve, reject) => {
import(
import_INTENTIONALLY_BROKEN(
/* webpackIgnore: true */
/* @vite-ignore */
path
Expand Down
2 changes: 1 addition & 1 deletion build/js/intlTelInputWithUtils.min.js

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion react/build/IntlTelInput.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -1758,6 +1758,9 @@ var Iti = class {
if (this.options.useFullscreenPopup) {
this.options.fixDropdownWidth = false;
}
if (this.options.onlyCountries.length === 1) {
this.options.initialCountry = this.options.onlyCountries[0];
}
if (this.options.separateDialCode) {
this.options.allowDropdown = true;
this.options.nationalMode = false;
Expand Down Expand Up @@ -2632,7 +2635,7 @@ var Iti = class {
//* Update the input padding to make space for the selected country/dial code.
_updateInputPadding() {
const selectedCountryWidth = this.selectedCountry.offsetWidth || this._getHiddenSelectedCountryWidth();
const inputPadding = selectedCountryWidth + 8;
const inputPadding = selectedCountryWidth + 6;
if (this.showSelectedCountryOnLeft) {
this.telInput.style.paddingLeft = `${inputPadding}px`;
} else {
Expand Down
5 changes: 4 additions & 1 deletion react/build/IntlTelInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -1722,6 +1722,9 @@ var Iti = class {
if (this.options.useFullscreenPopup) {
this.options.fixDropdownWidth = false;
}
if (this.options.onlyCountries.length === 1) {
this.options.initialCountry = this.options.onlyCountries[0];
}
if (this.options.separateDialCode) {
this.options.allowDropdown = true;
this.options.nationalMode = false;
Expand Down Expand Up @@ -2596,7 +2599,7 @@ var Iti = class {
//* Update the input padding to make space for the selected country/dial code.
_updateInputPadding() {
const selectedCountryWidth = this.selectedCountry.offsetWidth || this._getHiddenSelectedCountryWidth();
const inputPadding = selectedCountryWidth + 8;
const inputPadding = selectedCountryWidth + 6;
if (this.showSelectedCountryOnLeft) {
this.telInput.style.paddingLeft = `${inputPadding}px`;
} else {
Expand Down
5 changes: 4 additions & 1 deletion react/build/IntlTelInputWithUtils.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -1758,6 +1758,9 @@ var Iti = class {
if (this.options.useFullscreenPopup) {
this.options.fixDropdownWidth = false;
}
if (this.options.onlyCountries.length === 1) {
this.options.initialCountry = this.options.onlyCountries[0];
}
if (this.options.separateDialCode) {
this.options.allowDropdown = true;
this.options.nationalMode = false;
Expand Down Expand Up @@ -2632,7 +2635,7 @@ var Iti = class {
//* Update the input padding to make space for the selected country/dial code.
_updateInputPadding() {
const selectedCountryWidth = this.selectedCountry.offsetWidth || this._getHiddenSelectedCountryWidth();
const inputPadding = selectedCountryWidth + 8;
const inputPadding = selectedCountryWidth + 6;
if (this.showSelectedCountryOnLeft) {
this.telInput.style.paddingLeft = `${inputPadding}px`;
} else {
Expand Down
5 changes: 4 additions & 1 deletion react/build/IntlTelInputWithUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1722,6 +1722,9 @@ var Iti = class {
if (this.options.useFullscreenPopup) {
this.options.fixDropdownWidth = false;
}
if (this.options.onlyCountries.length === 1) {
this.options.initialCountry = this.options.onlyCountries[0];
}
if (this.options.separateDialCode) {
this.options.allowDropdown = true;
this.options.nationalMode = false;
Expand Down Expand Up @@ -2596,7 +2599,7 @@ var Iti = class {
//* Update the input padding to make space for the selected country/dial code.
_updateInputPadding() {
const selectedCountryWidth = this.selectedCountry.offsetWidth || this._getHiddenSelectedCountryWidth();
const inputPadding = selectedCountryWidth + 8;
const inputPadding = selectedCountryWidth + 6;
if (this.showSelectedCountryOnLeft) {
this.telInput.style.paddingLeft = `${inputPadding}px`;
} else {
Expand Down
5 changes: 4 additions & 1 deletion react/demo/set-number/set-number-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -25309,6 +25309,9 @@
if (this.options.useFullscreenPopup) {
this.options.fixDropdownWidth = false;
}
if (this.options.onlyCountries.length === 1) {
this.options.initialCountry = this.options.onlyCountries[0];
}
if (this.options.separateDialCode) {
this.options.allowDropdown = true;
this.options.nationalMode = false;
Expand Down Expand Up @@ -26183,7 +26186,7 @@
//* Update the input padding to make space for the selected country/dial code.
_updateInputPadding() {
const selectedCountryWidth = this.selectedCountry.offsetWidth || this._getHiddenSelectedCountryWidth();
const inputPadding = selectedCountryWidth + 8;
const inputPadding = selectedCountryWidth + 6;
if (this.showSelectedCountryOnLeft) {
this.telInput.style.paddingLeft = `${inputPadding}px`;
} else {
Expand Down
5 changes: 4 additions & 1 deletion react/demo/simple/simple-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -25309,6 +25309,9 @@
if (this.options.useFullscreenPopup) {
this.options.fixDropdownWidth = false;
}
if (this.options.onlyCountries.length === 1) {
this.options.initialCountry = this.options.onlyCountries[0];
}
if (this.options.separateDialCode) {
this.options.allowDropdown = true;
this.options.nationalMode = false;
Expand Down Expand Up @@ -26183,7 +26186,7 @@
//* Update the input padding to make space for the selected country/dial code.
_updateInputPadding() {
const selectedCountryWidth = this.selectedCountry.offsetWidth || this._getHiddenSelectedCountryWidth();
const inputPadding = selectedCountryWidth + 8;
const inputPadding = selectedCountryWidth + 6;
if (this.showSelectedCountryOnLeft) {
this.telInput.style.paddingLeft = `${inputPadding}px`;
} else {
Expand Down
5 changes: 4 additions & 1 deletion react/demo/toggle-disabled/toggle-disabled-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -25309,6 +25309,9 @@
if (this.options.useFullscreenPopup) {
this.options.fixDropdownWidth = false;
}
if (this.options.onlyCountries.length === 1) {
this.options.initialCountry = this.options.onlyCountries[0];
}
if (this.options.separateDialCode) {
this.options.allowDropdown = true;
this.options.nationalMode = false;
Expand Down Expand Up @@ -26183,7 +26186,7 @@
//* Update the input padding to make space for the selected country/dial code.
_updateInputPadding() {
const selectedCountryWidth = this.selectedCountry.offsetWidth || this._getHiddenSelectedCountryWidth();
const inputPadding = selectedCountryWidth + 8;
const inputPadding = selectedCountryWidth + 6;
if (this.showSelectedCountryOnLeft) {
this.telInput.style.paddingLeft = `${inputPadding}px`;
} else {
Expand Down
5 changes: 4 additions & 1 deletion react/demo/validation/validation-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -25309,6 +25309,9 @@
if (this.options.useFullscreenPopup) {
this.options.fixDropdownWidth = false;
}
if (this.options.onlyCountries.length === 1) {
this.options.initialCountry = this.options.onlyCountries[0];
}
if (this.options.separateDialCode) {
this.options.allowDropdown = true;
this.options.nationalMode = false;
Expand Down Expand Up @@ -26183,7 +26186,7 @@
//* Update the input padding to make space for the selected country/dial code.
_updateInputPadding() {
const selectedCountryWidth = this.selectedCountry.offsetWidth || this._getHiddenSelectedCountryWidth();
const inputPadding = selectedCountryWidth + 8;
const inputPadding = selectedCountryWidth + 6;
if (this.showSelectedCountryOnLeft) {
this.telInput.style.paddingLeft = `${inputPadding}px`;
} else {
Expand Down
5 changes: 5 additions & 0 deletions src/js/intl-tel-input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,11 @@ export class Iti {
this.options.fixDropdownWidth = false;
}

//* If theres only one country, then use it!
if (this.options.onlyCountries.length === 1) {
this.options.initialCountry = this.options.onlyCountries[0];
}

//* When separateDialCode enabled, we force nationalMode to false (because the displayed dial code is supposed to be thought of as part of the typed number), AND we force allowDropdown to true as we need the dropdown to select the dial code, AND we force countrySearch to true because that is used when the user types a plus in the tel input.
if (this.options.separateDialCode) {
this.options.allowDropdown = true;
Expand Down
4 changes: 2 additions & 2 deletions vue/build/IntlTelInput.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1680,7 +1680,7 @@ class j {
}
//* Can't be private as it's called from intlTelInput convenience wrapper.
_init() {
this.options.useFullscreenPopup && (this.options.fixDropdownWidth = !1), this.options.separateDialCode && (this.options.allowDropdown = !0, this.options.nationalMode = !1, this.options.countrySearch = !0), this.options.allowDropdown && !this.options.showFlags && !this.options.separateDialCode && (this.options.nationalMode = !1), this.options.useFullscreenPopup && !this.options.dropdownContainer && (this.options.dropdownContainer = document.body), this.isAndroid = typeof navigator < "u" ? /Android/i.test(navigator.userAgent) : !1, this.isRTL = !!this.telInput.closest("[dir=rtl]"), this.options.separateDialCode && (this.isRTL ? this.originalPaddingRight = this.telInput.style.paddingRight : this.originalPaddingLeft = this.telInput.style.paddingLeft), this.options.i18n = { ...A, ...this.options.i18n };
this.options.useFullscreenPopup && (this.options.fixDropdownWidth = !1), this.options.onlyCountries.length === 1 && (this.options.initialCountry = this.options.onlyCountries[0]), this.options.separateDialCode && (this.options.allowDropdown = !0, this.options.nationalMode = !1, this.options.countrySearch = !0), this.options.allowDropdown && !this.options.showFlags && !this.options.separateDialCode && (this.options.nationalMode = !1), this.options.useFullscreenPopup && !this.options.dropdownContainer && (this.options.dropdownContainer = document.body), this.isAndroid = typeof navigator < "u" ? /Android/i.test(navigator.userAgent) : !1, this.isRTL = !!this.telInput.closest("[dir=rtl]"), this.options.separateDialCode && (this.isRTL ? this.originalPaddingRight = this.telInput.style.paddingRight : this.originalPaddingLeft = this.telInput.style.paddingLeft), this.options.i18n = { ...A, ...this.options.i18n };
const t = new Promise((i, s) => {
this.resolveAutoCountryPromise = i, this.rejectAutoCountryPromise = s;
}), e = new Promise((i, s) => {
Expand Down Expand Up @@ -2170,7 +2170,7 @@ class j {
}
//* Update the input padding to make space for the selected country/dial code.
_updateInputPadding() {
const e = (this.selectedCountry.offsetWidth || this._getHiddenSelectedCountryWidth()) + 8;
const e = (this.selectedCountry.offsetWidth || this._getHiddenSelectedCountryWidth()) + 6;
this.showSelectedCountryOnLeft ? this.telInput.style.paddingLeft = `${e}px` : this.telInput.style.paddingRight = `${e}px`;
}
//* Update the maximum valid number length for the currently selected country.
Expand Down
Loading

0 comments on commit b967582

Please sign in to comment.