@trackunit/react-form-components 0.0.257 → 0.0.260
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/index.cjs.js +6 -7
- package/index.esm.js +7 -8
- package/package.json +1 -1
- package/src/components/PhoneInput/PhoneInputValidationUtils.d.ts +1 -1
- package/src/translation.d.ts +2 -2
- package/translation.cjs5.js +7 -7
- package/translation.cjs7.js +7 -7
- package/translation.esm5.js +7 -7
- package/translation.esm7.js +7 -7
package/index.cjs.js
CHANGED
|
@@ -46,6 +46,7 @@ var ReactAsyncSelect__default = /*#__PURE__*/_interopDefaultLegacy(ReactAsyncSel
|
|
|
46
46
|
var defaultTranslations = {
|
|
47
47
|
"phoneField.error.INVALID_COUNTRY": "The country code is not valid",
|
|
48
48
|
"phoneField.error.INVALID_LENGTH": "The phone number is not valid",
|
|
49
|
+
"phoneField.error.INVALID_NUMBER": "The phone number is not valid",
|
|
49
50
|
"phoneField.error.NOT_A_NUMBER": "The phone number can contain numbers only",
|
|
50
51
|
"phoneField.error.REQUIRED": "The phone number is required",
|
|
51
52
|
"phoneField.error.REQUIRED_COUNTRY": "The country code is required",
|
|
@@ -1511,6 +1512,9 @@ const PhoneInput = React.forwardRef((_a, ref) => {
|
|
|
1511
1512
|
*/
|
|
1512
1513
|
const validatePhoneNumber = ({ phone, countryCode, national, }) => {
|
|
1513
1514
|
const phoneNumber = phone ? phone : countryCode || national ? `${countryCode}${national}` : undefined;
|
|
1515
|
+
if (phoneNumber && parsePhoneNumberFromString.isValidPhoneNumber(phoneNumber)) {
|
|
1516
|
+
return undefined;
|
|
1517
|
+
}
|
|
1514
1518
|
if (!phoneNumber) {
|
|
1515
1519
|
return "REQUIRED";
|
|
1516
1520
|
}
|
|
@@ -1530,10 +1534,7 @@ const validatePhoneNumber = ({ phone, countryCode, national, }) => {
|
|
|
1530
1534
|
if (!number) {
|
|
1531
1535
|
return "NOT_A_NUMBER";
|
|
1532
1536
|
}
|
|
1533
|
-
|
|
1534
|
-
return parsePhoneNumberFromString.validatePhoneNumberLength(number.number, number.country);
|
|
1535
|
-
}
|
|
1536
|
-
return undefined;
|
|
1537
|
+
return "INVALID_NUMBER";
|
|
1537
1538
|
};
|
|
1538
1539
|
/**
|
|
1539
1540
|
* Checks if the country code is valid and required
|
|
@@ -1574,9 +1575,7 @@ const PhoneField = React.forwardRef((_a, ref) => {
|
|
|
1574
1575
|
setLocalError(Boolean(phoneValidationResult) ? t(`phoneField.error.${phoneValidationResult}`) : undefined);
|
|
1575
1576
|
};
|
|
1576
1577
|
const onChangeValueHandler = (phoneNumberValue) => {
|
|
1577
|
-
|
|
1578
|
-
validate(phoneNumberValue);
|
|
1579
|
-
}
|
|
1578
|
+
validate(phoneNumberValue);
|
|
1580
1579
|
onChangeValue && onChangeValue(Object.assign(Object.assign({}, phoneNumberValue), { isValid }));
|
|
1581
1580
|
};
|
|
1582
1581
|
const handleOnFieldBlur = (phoneNumberValue) => {
|
package/index.esm.js
CHANGED
|
@@ -6,7 +6,7 @@ import * as React from 'react';
|
|
|
6
6
|
import React__default, { useMemo, forwardRef, useState, cloneElement, useEffect, useRef } from 'react';
|
|
7
7
|
import { v4 } from 'uuid';
|
|
8
8
|
import { format } from 'date-fns';
|
|
9
|
-
import parsePhoneNumberFromString, { getCountries, getCountryCallingCode, parsePhoneNumberFromString as parsePhoneNumberFromString$1
|
|
9
|
+
import parsePhoneNumberFromString, { getCountries, getCountryCallingCode, isValidPhoneNumber, parsePhoneNumberFromString as parsePhoneNumberFromString$1 } from 'libphonenumber-js';
|
|
10
10
|
import ReactSelect, { components } from 'react-select';
|
|
11
11
|
export { default as ValueType } from 'react-select';
|
|
12
12
|
import ReactAsyncCreatableSelect from 'react-select/async-creatable';
|
|
@@ -16,6 +16,7 @@ import ReactAsyncSelect from 'react-select/async';
|
|
|
16
16
|
var defaultTranslations = {
|
|
17
17
|
"phoneField.error.INVALID_COUNTRY": "The country code is not valid",
|
|
18
18
|
"phoneField.error.INVALID_LENGTH": "The phone number is not valid",
|
|
19
|
+
"phoneField.error.INVALID_NUMBER": "The phone number is not valid",
|
|
19
20
|
"phoneField.error.NOT_A_NUMBER": "The phone number can contain numbers only",
|
|
20
21
|
"phoneField.error.REQUIRED": "The phone number is required",
|
|
21
22
|
"phoneField.error.REQUIRED_COUNTRY": "The country code is required",
|
|
@@ -1481,6 +1482,9 @@ const PhoneInput = forwardRef((_a, ref) => {
|
|
|
1481
1482
|
*/
|
|
1482
1483
|
const validatePhoneNumber = ({ phone, countryCode, national, }) => {
|
|
1483
1484
|
const phoneNumber = phone ? phone : countryCode || national ? `${countryCode}${national}` : undefined;
|
|
1485
|
+
if (phoneNumber && isValidPhoneNumber(phoneNumber)) {
|
|
1486
|
+
return undefined;
|
|
1487
|
+
}
|
|
1484
1488
|
if (!phoneNumber) {
|
|
1485
1489
|
return "REQUIRED";
|
|
1486
1490
|
}
|
|
@@ -1500,10 +1504,7 @@ const validatePhoneNumber = ({ phone, countryCode, national, }) => {
|
|
|
1500
1504
|
if (!number) {
|
|
1501
1505
|
return "NOT_A_NUMBER";
|
|
1502
1506
|
}
|
|
1503
|
-
|
|
1504
|
-
return validatePhoneNumberLength(number.number, number.country);
|
|
1505
|
-
}
|
|
1506
|
-
return undefined;
|
|
1507
|
+
return "INVALID_NUMBER";
|
|
1507
1508
|
};
|
|
1508
1509
|
/**
|
|
1509
1510
|
* Checks if the country code is valid and required
|
|
@@ -1544,9 +1545,7 @@ const PhoneField = forwardRef((_a, ref) => {
|
|
|
1544
1545
|
setLocalError(Boolean(phoneValidationResult) ? t(`phoneField.error.${phoneValidationResult}`) : undefined);
|
|
1545
1546
|
};
|
|
1546
1547
|
const onChangeValueHandler = (phoneNumberValue) => {
|
|
1547
|
-
|
|
1548
|
-
validate(phoneNumberValue);
|
|
1549
|
-
}
|
|
1548
|
+
validate(phoneNumberValue);
|
|
1550
1549
|
onChangeValue && onChangeValue(Object.assign(Object.assign({}, phoneNumberValue), { isValid }));
|
|
1551
1550
|
};
|
|
1552
1551
|
const handleOnFieldBlur = (phoneNumberValue) => {
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ValidatePhoneNumberLengthResult } from "libphonenumber-js";
|
|
2
|
-
export type PhoneInputValidationError = "REQUIRED" | "REQUIRED_COUNTRY" | ValidatePhoneNumberLengthResult | undefined;
|
|
2
|
+
export type PhoneInputValidationError = "REQUIRED" | "REQUIRED_COUNTRY" | "INVALID_NUMBER" | ValidatePhoneNumberLengthResult | undefined;
|
|
3
3
|
export interface PhoneNumberValueForValidation {
|
|
4
4
|
phone?: string | undefined | null;
|
|
5
5
|
national?: string | undefined | null;
|
package/src/translation.d.ts
CHANGED
|
@@ -15,8 +15,8 @@ export declare const translations: TranslationResource<TranslationKeys>;
|
|
|
15
15
|
/**
|
|
16
16
|
* Local useTranslation for this specific library
|
|
17
17
|
*/
|
|
18
|
-
export declare const useTranslation: () => [TransForLibs<"phoneField.error.INVALID_COUNTRY" | "phoneField.error.INVALID_LENGTH" | "phoneField.error.NOT_A_NUMBER" | "phoneField.error.REQUIRED" | "phoneField.error.REQUIRED_COUNTRY" | "phoneField.error.TOO_LONG" | "phoneField.error.TOO_SHORT" | "phoneField.error.undefined">, import("i18next").i18n, boolean] & {
|
|
19
|
-
t: TransForLibs<"phoneField.error.INVALID_COUNTRY" | "phoneField.error.INVALID_LENGTH" | "phoneField.error.NOT_A_NUMBER" | "phoneField.error.REQUIRED" | "phoneField.error.REQUIRED_COUNTRY" | "phoneField.error.TOO_LONG" | "phoneField.error.TOO_SHORT" | "phoneField.error.undefined">;
|
|
18
|
+
export declare const useTranslation: () => [TransForLibs<"phoneField.error.INVALID_COUNTRY" | "phoneField.error.INVALID_LENGTH" | "phoneField.error.INVALID_NUMBER" | "phoneField.error.NOT_A_NUMBER" | "phoneField.error.REQUIRED" | "phoneField.error.REQUIRED_COUNTRY" | "phoneField.error.TOO_LONG" | "phoneField.error.TOO_SHORT" | "phoneField.error.undefined">, import("i18next").i18n, boolean] & {
|
|
19
|
+
t: TransForLibs<"phoneField.error.INVALID_COUNTRY" | "phoneField.error.INVALID_LENGTH" | "phoneField.error.INVALID_NUMBER" | "phoneField.error.NOT_A_NUMBER" | "phoneField.error.REQUIRED" | "phoneField.error.REQUIRED_COUNTRY" | "phoneField.error.TOO_LONG" | "phoneField.error.TOO_SHORT" | "phoneField.error.undefined">;
|
|
20
20
|
i18n: import("i18next").i18n;
|
|
21
21
|
ready: boolean;
|
|
22
22
|
};
|
package/translation.cjs5.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var translation = {
|
|
4
|
-
"phoneField.error.INVALID_COUNTRY": "
|
|
5
|
-
"phoneField.error.INVALID_LENGTH": "
|
|
6
|
-
"phoneField.error.NOT_A_NUMBER": "
|
|
7
|
-
"phoneField.error.REQUIRED": "
|
|
8
|
-
"phoneField.error.REQUIRED_COUNTRY": "
|
|
9
|
-
"phoneField.error.TOO_LONG": "
|
|
10
|
-
"phoneField.error.TOO_SHORT": "
|
|
4
|
+
"phoneField.error.INVALID_COUNTRY": "L'indicatif du pays n'est pas valide",
|
|
5
|
+
"phoneField.error.INVALID_LENGTH": "Le numéro de téléphone n’est pas valide",
|
|
6
|
+
"phoneField.error.NOT_A_NUMBER": "Le numéro de téléphone peut contenir uniquement des chiffres",
|
|
7
|
+
"phoneField.error.REQUIRED": "Le numéro de téléphone est requis",
|
|
8
|
+
"phoneField.error.REQUIRED_COUNTRY": "L'indicatif du pays est requis",
|
|
9
|
+
"phoneField.error.TOO_LONG": "Le numéro de téléphone est trop long",
|
|
10
|
+
"phoneField.error.TOO_SHORT": "Le numéro de téléphone est trop court",
|
|
11
11
|
"phoneField.error.undefined": ""
|
|
12
12
|
};
|
|
13
13
|
|
package/translation.cjs7.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var translation = {
|
|
4
|
-
"phoneField.error.INVALID_COUNTRY": "
|
|
5
|
-
"phoneField.error.INVALID_LENGTH": "
|
|
6
|
-
"phoneField.error.NOT_A_NUMBER": "
|
|
7
|
-
"phoneField.error.REQUIRED": "
|
|
8
|
-
"phoneField.error.REQUIRED_COUNTRY": "
|
|
9
|
-
"phoneField.error.TOO_LONG": "
|
|
10
|
-
"phoneField.error.TOO_SHORT": "
|
|
4
|
+
"phoneField.error.INVALID_COUNTRY": "Az országkód érvénytelen",
|
|
5
|
+
"phoneField.error.INVALID_LENGTH": "A telefonszám érvénytelen",
|
|
6
|
+
"phoneField.error.NOT_A_NUMBER": "A telefonszám csak számokat tartalmazhat",
|
|
7
|
+
"phoneField.error.REQUIRED": "A telefonszám megadása kötelező",
|
|
8
|
+
"phoneField.error.REQUIRED_COUNTRY": "Az országkód megadása kötelező",
|
|
9
|
+
"phoneField.error.TOO_LONG": "A telefonszám túl hosszú",
|
|
10
|
+
"phoneField.error.TOO_SHORT": "A telefonszám túl rövid",
|
|
11
11
|
"phoneField.error.undefined": ""
|
|
12
12
|
};
|
|
13
13
|
|
package/translation.esm5.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
var translation = {
|
|
2
|
-
"phoneField.error.INVALID_COUNTRY": "
|
|
3
|
-
"phoneField.error.INVALID_LENGTH": "
|
|
4
|
-
"phoneField.error.NOT_A_NUMBER": "
|
|
5
|
-
"phoneField.error.REQUIRED": "
|
|
6
|
-
"phoneField.error.REQUIRED_COUNTRY": "
|
|
7
|
-
"phoneField.error.TOO_LONG": "
|
|
8
|
-
"phoneField.error.TOO_SHORT": "
|
|
2
|
+
"phoneField.error.INVALID_COUNTRY": "L'indicatif du pays n'est pas valide",
|
|
3
|
+
"phoneField.error.INVALID_LENGTH": "Le numéro de téléphone n’est pas valide",
|
|
4
|
+
"phoneField.error.NOT_A_NUMBER": "Le numéro de téléphone peut contenir uniquement des chiffres",
|
|
5
|
+
"phoneField.error.REQUIRED": "Le numéro de téléphone est requis",
|
|
6
|
+
"phoneField.error.REQUIRED_COUNTRY": "L'indicatif du pays est requis",
|
|
7
|
+
"phoneField.error.TOO_LONG": "Le numéro de téléphone est trop long",
|
|
8
|
+
"phoneField.error.TOO_SHORT": "Le numéro de téléphone est trop court",
|
|
9
9
|
"phoneField.error.undefined": ""
|
|
10
10
|
};
|
|
11
11
|
|
package/translation.esm7.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
var translation = {
|
|
2
|
-
"phoneField.error.INVALID_COUNTRY": "
|
|
3
|
-
"phoneField.error.INVALID_LENGTH": "
|
|
4
|
-
"phoneField.error.NOT_A_NUMBER": "
|
|
5
|
-
"phoneField.error.REQUIRED": "
|
|
6
|
-
"phoneField.error.REQUIRED_COUNTRY": "
|
|
7
|
-
"phoneField.error.TOO_LONG": "
|
|
8
|
-
"phoneField.error.TOO_SHORT": "
|
|
2
|
+
"phoneField.error.INVALID_COUNTRY": "Az országkód érvénytelen",
|
|
3
|
+
"phoneField.error.INVALID_LENGTH": "A telefonszám érvénytelen",
|
|
4
|
+
"phoneField.error.NOT_A_NUMBER": "A telefonszám csak számokat tartalmazhat",
|
|
5
|
+
"phoneField.error.REQUIRED": "A telefonszám megadása kötelező",
|
|
6
|
+
"phoneField.error.REQUIRED_COUNTRY": "Az országkód megadása kötelező",
|
|
7
|
+
"phoneField.error.TOO_LONG": "A telefonszám túl hosszú",
|
|
8
|
+
"phoneField.error.TOO_SHORT": "A telefonszám túl rövid",
|
|
9
9
|
"phoneField.error.undefined": ""
|
|
10
10
|
};
|
|
11
11
|
|