react-frontend-common-components 0.0.96 → 0.0.97

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.96",
3
+ "version": "0.0.97",
4
4
  "description": "Reusable frontend library",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -4,16 +4,22 @@ import PhoneInput, { CountryData } from "react-phone-input-2";
4
4
  import "./app-phone-input.css";
5
5
 
6
6
  interface AppPhoneInputProps {
7
+ countryIsoCode?: string;
7
8
  countryCode?: string;
8
9
  phone: string;
9
- handleChange: (phone: string, countryCode: string, uniCode: string) => void;
10
+ handleChange: (
11
+ phone: string,
12
+ countryCode: string,
13
+ countryIsoCode: string,
14
+ uniCode: string
15
+ ) => void;
10
16
  className: string;
11
17
  id: string;
12
18
  }
13
19
 
14
20
  const AppPhoneInput = ({
15
21
  handleChange,
16
- countryCode,
22
+ countryIsoCode,
17
23
  phone,
18
24
  className,
19
25
  id,
@@ -28,29 +34,28 @@ const AppPhoneInput = ({
28
34
  }
29
35
  }
30
36
  }, [id]);
37
+
31
38
  return (
32
39
  <div className={className}>
33
40
  <div className={"inputContainer"} ref={wrapperRef}>
34
41
  <PhoneInput
35
- value={`+${countryCode}${phone}`}
36
- country={
37
- (countryCode && phone) || (countryCode != "" && phone != "")
38
- ? ""
39
- : "us"
40
- }
42
+ value={phone}
43
+ country={countryIsoCode || "us"}
41
44
  countryCodeEditable={false}
42
- onChange={(phone, country: CountryData) => {
45
+ enableSearch={true}
46
+ inputProps={{ required: true }}
47
+ onChange={(value, country: CountryData) => {
43
48
  handleChange(
44
- phone.replace(country.dialCode, ""),
49
+ value,
45
50
  country.dialCode,
46
- country.countryCode
51
+ country.countryCode,
52
+ country.name
47
53
  );
48
54
  }}
49
- enableSearch={true}
50
- inputProps={{ required: true }}
51
55
  />
52
56
  </div>
53
57
  </div>
54
58
  );
55
59
  };
60
+
56
61
  export default AppPhoneInput;