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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-frontend-common-components",
3
- "version": "0.0.11",
3
+ "version": "0.0.12",
4
4
  "description": "Reusable frontend library",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -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
- <div className={`appPhoneField ${className}`}>
25
- <div className={"intelWrapper"}>
26
- <IntlTelInput
27
- containerClassName={`${"intltelinput"} intl-tel-input`}
28
- inputClassName={`${"customintlinput"} custom-intl-input`}
29
- separateDialCode={true}
30
- defaultCountry="ae"
31
- placeholder="50-1234567"
32
- preferredCountries={["ae"]}
33
- value={phone}
34
- onPhoneNumberChange={(isValid, value, country, fullNumber) => {
35
- if (!isNaN(Number(value))) {
36
- setPhone(value);
37
- setCustomerCountryCode("+" + country.dialCode);
38
- setPhoneError("");
39
- } else if (value === "") {
40
- setPhoneError("");
41
- } else {
42
- setPhoneError("You can only enter numbers.");
43
- }
44
- }}
45
- onSelectFlag={(
46
- currentNumber,
47
- selectedCountryData,
48
- fullNumber,
49
- isValid
50
- ) => {
51
- setCustomerCountryCode("+" + selectedCountryData.dialCode);
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
- <p className={"error"}>{phoneError && phoneError}</p>
56
- </div>
59
+ </Suspense>
57
60
  );
58
61
  };
59
62