@arkyn/components 1.4.55 → 1.4.57

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/PhoneInput/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAe,eAAe,EAAE,MAAM,cAAc,CAAC;AAY5D,iBAAS,UAAU,CAAC,KAAK,EAAE,eAAe,2CAiKzC;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/PhoneInput/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAe,eAAe,EAAE,MAAM,cAAc,CAAC;AAY5D,iBAAS,UAAU,CAAC,KAAK,EAAE,eAAe,2CAoKzC;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
@@ -16,6 +16,9 @@ function PhoneInput(props) {
16
16
  const [search, setSearch] = useState("");
17
17
  const [showCountryOptions, setShowCountryOptions] = useState(false);
18
18
  const [value, setValue] = useState(defaultData.formattedNumber || "");
19
+ const usedValue = fixedValue
20
+ ? getDefaultFormatPhoneNumber(fixedValue).formattedNumber
21
+ : value;
19
22
  const [currentCountry, setCurrentCountry] = useState(() => {
20
23
  if (defaultData.country)
21
24
  return defaultData.country;
@@ -73,7 +76,7 @@ function PhoneInput(props) {
73
76
  if (currentCountry.prefix)
74
77
  returnValue += `-${currentCountry.prefix}`;
75
78
  returnValue += " ";
76
- returnValue += removeNumberMasks(fixedValue || props || value);
79
+ returnValue += removeNumberMasks(props || usedValue);
77
80
  return returnValue;
78
81
  }
79
82
  return (_jsxs(PhoneInputContainer, { id: id, disabled: disabled, isError: isError, isLoading: isLoading, isFocused: isFocused, readOnly: readOnly, size: size, variant: variant, className: className, onFocus: handleContainerFocus, children: [_jsx(PhoneInputCountrySelector, { currentCountry: currentCountry, onClick: handleOpenCountryOptions, size: size }), _jsxs(PhoneInputCountryOptionsContainer, { isOpen: showCountryOptions, search: search, placeholder: searchCountryPlaceholder, onSearch: setSearch, children: [countries
@@ -83,7 +86,7 @@ function PhoneInput(props) {
83
86
  setShowCountryOptions(false);
84
87
  setValue(country.mask);
85
88
  }, isActive: country.iso === currentCountry.iso, size: size }, country.iso))), countries.filter((country) => filterCountryFunction(country))
86
- .length === 0 && _jsx("p", { children: notFoundCountryText })] }), _jsx(PhoneInputCountriesOverlay, { isOpen: showCountryOptions, onClick: handleCloseCountryOptions }), _jsx(PhoneInputMask, { ref: inputPhoneMaskRef, currentCountry: currentCountry, value: inputValue(fixedValue || value), onChange: (e) => {
89
+ .length === 0 && _jsx("p", { children: notFoundCountryText })] }), _jsx(PhoneInputCountriesOverlay, { isOpen: showCountryOptions, onClick: handleCloseCountryOptions }), _jsx(PhoneInputMask, { ref: inputPhoneMaskRef, currentCountry: currentCountry, value: usedValue, onChange: (e) => {
87
90
  setValue(e);
88
91
  onChange && onChange(inputValue(e));
89
92
  }, disabled: disabled, onBlur: handleInputBlur, onFocus: handleInputFocus, size: size }), _jsx("input", { ref: inputRef, type: "hidden", name: name, value: inputValue() })] }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkyn/components",
3
- "version": "1.4.55",
3
+ "version": "1.4.57",
4
4
  "main": "./dist/bundle.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "author": "Lucas Gonçalves",
@@ -35,6 +35,9 @@ function PhoneInput(props: PhoneInputProps) {
35
35
  const [search, setSearch] = useState("");
36
36
  const [showCountryOptions, setShowCountryOptions] = useState(false);
37
37
  const [value, setValue] = useState(defaultData.formattedNumber || "");
38
+ const usedValue = fixedValue
39
+ ? getDefaultFormatPhoneNumber(fixedValue).formattedNumber
40
+ : value;
38
41
 
39
42
  const [currentCountry, setCurrentCountry] = useState<CountryType>(() => {
40
43
  if (defaultData.country) return defaultData.country;
@@ -101,7 +104,7 @@ function PhoneInput(props: PhoneInputProps) {
101
104
  let returnValue = currentCountry.code;
102
105
  if (currentCountry.prefix) returnValue += `-${currentCountry.prefix}`;
103
106
  returnValue += " ";
104
- returnValue += removeNumberMasks(fixedValue || props || value);
107
+ returnValue += removeNumberMasks(props || usedValue);
105
108
  return returnValue;
106
109
  }
107
110
 
@@ -158,7 +161,7 @@ function PhoneInput(props: PhoneInputProps) {
158
161
  <PhoneInputMask
159
162
  ref={inputPhoneMaskRef}
160
163
  currentCountry={currentCountry}
161
- value={inputValue(fixedValue || value)}
164
+ value={usedValue}
162
165
  onChange={(e) => {
163
166
  setValue(e);
164
167
  onChange && onChange(inputValue(e));