@jacksonavila/phone-lib 2.0.11 → 2.0.12
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 +7 -1
- package/phone-lib.js +6 -6
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jacksonavila/phone-lib",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.12",
|
|
4
4
|
"description": "Librería JavaScript para input de teléfono con selector de país y banderas - Compatible con Vanilla JS y React",
|
|
5
5
|
"main": "phone-lib.js",
|
|
6
6
|
"module": "phone-lib.js",
|
|
7
7
|
"type": "module",
|
|
8
|
+
"types": "index.d.ts",
|
|
8
9
|
"exports": {
|
|
9
10
|
".": {
|
|
10
11
|
"import": "./phone-lib.js",
|
|
@@ -20,6 +21,7 @@
|
|
|
20
21
|
"scripts": {
|
|
21
22
|
"serve": "npx http-server . -p 3004 -o",
|
|
22
23
|
"prepublishOnly": "echo 'Verificando archivos antes de publicar...' && node --check phone-lib.js",
|
|
24
|
+
"test": "vitest",
|
|
23
25
|
"update-version": "node update-version.js"
|
|
24
26
|
},
|
|
25
27
|
"keywords": [
|
|
@@ -73,5 +75,9 @@
|
|
|
73
75
|
],
|
|
74
76
|
"engines": {
|
|
75
77
|
"node": ">=14.0.0"
|
|
78
|
+
},
|
|
79
|
+
"devDependencies": {
|
|
80
|
+
"jsdom": "^27.4.0",
|
|
81
|
+
"vitest": "^4.0.17"
|
|
76
82
|
}
|
|
77
83
|
}
|
package/phone-lib.js
CHANGED
|
@@ -77,7 +77,7 @@ class PhoneLib {
|
|
|
77
77
|
// Estado interno
|
|
78
78
|
this.selectedCountry = this.options.initialCountry;
|
|
79
79
|
this.phoneNumber = options.initialPhoneNumber || '';
|
|
80
|
-
this.
|
|
80
|
+
this._isValid = false;
|
|
81
81
|
this.isDisabled = this.options.disabled;
|
|
82
82
|
this.isReadonly = this.options.readonly;
|
|
83
83
|
this.countries = this.getCountriesList();
|
|
@@ -1247,8 +1247,8 @@ class PhoneLib {
|
|
|
1247
1247
|
try {
|
|
1248
1248
|
const phoneNumber = parsePhoneNumber(this.phoneNumber, this.selectedCountry);
|
|
1249
1249
|
const isValid = phoneNumber.isValid();
|
|
1250
|
-
const previousValid = this.
|
|
1251
|
-
this.
|
|
1250
|
+
const previousValid = this._isValid;
|
|
1251
|
+
this._isValid = isValid;
|
|
1252
1252
|
|
|
1253
1253
|
if (updateVisuals && this.phoneInput) {
|
|
1254
1254
|
this.phoneInput.classList.toggle('phone-lib-input-invalid', !isValid);
|
|
@@ -1263,7 +1263,7 @@ class PhoneLib {
|
|
|
1263
1263
|
|
|
1264
1264
|
return isValid;
|
|
1265
1265
|
} catch (e) {
|
|
1266
|
-
this.
|
|
1266
|
+
this._isValid = false;
|
|
1267
1267
|
if (updateVisuals && this.phoneInput) {
|
|
1268
1268
|
this.phoneInput.classList.add('phone-lib-input-invalid');
|
|
1269
1269
|
this.phoneInput.classList.remove('phone-lib-input-valid');
|
|
@@ -1519,7 +1519,7 @@ class PhoneLib {
|
|
|
1519
1519
|
international: this.formatInternational(),
|
|
1520
1520
|
national: this.formatNational(),
|
|
1521
1521
|
rfc3966: this.formatRFC3966(),
|
|
1522
|
-
isValid: this.
|
|
1522
|
+
isValid: this._isValid,
|
|
1523
1523
|
type: this.getNumberType(),
|
|
1524
1524
|
countryName: countryData?.name || this.selectedCountry
|
|
1525
1525
|
};
|
|
@@ -1575,7 +1575,7 @@ class PhoneLib {
|
|
|
1575
1575
|
this.updatePhoneNumber();
|
|
1576
1576
|
|
|
1577
1577
|
// Ejecutar callbacks
|
|
1578
|
-
const isValid = this.
|
|
1578
|
+
const isValid = this._isValid;
|
|
1579
1579
|
this.executeCallback('onPhoneChange', this.phoneNumber, isValid, this.selectedCountry);
|
|
1580
1580
|
this.emitEvent('phoneChange', {
|
|
1581
1581
|
phoneNumber: this.phoneNumber,
|