react-frontend-common-components 0.0.11 → 0.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/dist/index.js +10 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/components/app-phone-field/app-phone-field.tsx +37 -34
package/package.json
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
-
import React from "react";
|
1
|
+
import React, { lazy, Suspense } from "react";
|
2
2
|
import "react-intl-tel-input/dist/main.css";
|
3
|
-
import IntlTelInput from "react-intl-tel-input";
|
4
3
|
import "./app-phone-field.css";
|
5
4
|
|
5
|
+
const IntlTelInput = lazy(() => import("react-intl-tel-input"));
|
6
|
+
|
6
7
|
interface AppPhoneFieldProps {
|
7
8
|
phone: string;
|
8
9
|
setPhone: (phone: string) => void;
|
@@ -21,39 +22,41 @@ const AppPhoneField = ({
|
|
21
22
|
className,
|
22
23
|
}: AppPhoneFieldProps) => {
|
23
24
|
return (
|
24
|
-
<
|
25
|
-
<div className={
|
26
|
-
<
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
25
|
+
<Suspense fallback={<div>Loading...</div>}>
|
26
|
+
<div className={`appPhoneField ${className}`}>
|
27
|
+
<div className={"intelWrapper"}>
|
28
|
+
<IntlTelInput
|
29
|
+
containerClassName={`${"intltelinput"} intl-tel-input`}
|
30
|
+
inputClassName={`${"customintlinput"} custom-intl-input`}
|
31
|
+
separateDialCode={true}
|
32
|
+
defaultCountry="ae"
|
33
|
+
placeholder="50-1234567"
|
34
|
+
preferredCountries={["ae"]}
|
35
|
+
value={phone}
|
36
|
+
onPhoneNumberChange={(isValid, value, country, fullNumber) => {
|
37
|
+
if (!isNaN(Number(value))) {
|
38
|
+
setPhone(value);
|
39
|
+
setCustomerCountryCode("+" + country.dialCode);
|
40
|
+
setPhoneError("");
|
41
|
+
} else if (value === "") {
|
42
|
+
setPhoneError("");
|
43
|
+
} else {
|
44
|
+
setPhoneError("You can only enter numbers.");
|
45
|
+
}
|
46
|
+
}}
|
47
|
+
onSelectFlag={(
|
48
|
+
currentNumber,
|
49
|
+
selectedCountryData,
|
50
|
+
fullNumber,
|
51
|
+
isValid
|
52
|
+
) => {
|
53
|
+
setCustomerCountryCode("+" + selectedCountryData.dialCode);
|
54
|
+
}}
|
55
|
+
/>
|
56
|
+
</div>
|
57
|
+
<p className={"error"}>{phoneError && phoneError}</p>
|
54
58
|
</div>
|
55
|
-
|
56
|
-
</div>
|
59
|
+
</Suspense>
|
57
60
|
);
|
58
61
|
};
|
59
62
|
|