@omniumretail/component-library 1.1.44 → 1.1.46

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": "@omniumretail/component-library",
3
- "version": "1.1.44",
3
+ "version": "1.1.46",
4
4
  "private": false,
5
5
  "main": "dist/bundle.js",
6
6
  "typings": "./dist/types/index",
@@ -18,17 +18,16 @@ interface CountryCodeProps {
18
18
  onChange?: (value: any) => void;
19
19
  selectProps?: SelectProps;
20
20
  inputProps?: InputProps;
21
+ dialCode?: string;
21
22
  }
22
23
 
23
- const CountryCode = ({ value, onChange, selectProps, inputProps }: CountryCodeProps) => {
24
+ const CountryCode = ({ value, onChange, selectProps, inputProps, dialCode }: CountryCodeProps) => {
24
25
  const [inputDefaultValue, setInputDefaultValue] = useState<any>(inputProps?.defaultValue);
25
26
  const [countryCode, setCountryCode] = useState(selectProps?.defaultValue);
26
27
 
27
28
  useEffect(() => {
28
- if (inputProps?.defaultValue) {
29
- setInputDefaultValue(inputProps?.defaultValue);
30
- }
31
- }, [inputProps?.defaultValue]);
29
+ setInputDefaultValue(inputProps?.defaultValue);
30
+ }, []);
32
31
 
33
32
  useEffect(() => {
34
33
  if (value && typeof value === 'object') {
@@ -51,6 +50,8 @@ const CountryCode = ({ value, onChange, selectProps, inputProps }: CountryCodePr
51
50
  [onChange, countryCode, inputDefaultValue],
52
51
  );
53
52
 
53
+ const inputValueWithDialCode = dialCode ? `${dialCode} ${inputDefaultValue}` : inputDefaultValue;
54
+
54
55
  return (
55
56
  <Input.Group compact className={styles.inputGroup}>
56
57
  <Select
@@ -60,7 +61,7 @@ const CountryCode = ({ value, onChange, selectProps, inputProps }: CountryCodePr
60
61
  ></Select>
61
62
  <InputField
62
63
  {...inputProps}
63
- value={inputDefaultValue}
64
+ value={inputValueWithDialCode}
64
65
  onChange={(event) => changeLocalValue(event.target.value, 'phoneNumber')}
65
66
  />
66
67
  </Input.Group>