@arkyn/components 1.4.57 → 1.5.0

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,2CAoKzC;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,2CAiKzC;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
@@ -10,15 +10,12 @@ import { PhoneInputCountrySelector } from "./components/PhoneInputCountrySelecto
10
10
  import { PhoneInputMask } from "./components/PhoneInputMask";
11
11
  import { getDefaultFormatPhoneNumber } from "./services/getDefaultFormatPhoneNumber";
12
12
  function PhoneInput(props) {
13
- const { defaultCountry, className = "", disabled = false, isError: baseIsError = false, isLoading = false, readOnly = false, size = "md", defaultValue = "", variant = "solid", name, onChange, searchCountryPlaceholder = "Pesquisar país", notFoundCountryText = "Nenhum país encontrado", value: fixedValue, } = props;
13
+ const { defaultCountry, className = "", disabled = false, isError: baseIsError = false, isLoading = false, readOnly = false, size = "md", defaultValue = "", variant = "solid", name, onChange, searchCountryPlaceholder = "Pesquisar país", notFoundCountryText = "Nenhum país encontrado", ...rest } = props;
14
14
  const defaultData = getDefaultFormatPhoneNumber(defaultValue);
15
15
  const [isFocused, setIsFocused] = useState(false);
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;
22
19
  const [currentCountry, setCurrentCountry] = useState(() => {
23
20
  if (defaultData.country)
24
21
  return defaultData.country;
@@ -76,7 +73,7 @@ function PhoneInput(props) {
76
73
  if (currentCountry.prefix)
77
74
  returnValue += `-${currentCountry.prefix}`;
78
75
  returnValue += " ";
79
- returnValue += removeNumberMasks(props || usedValue);
76
+ returnValue += removeNumberMasks(props || value);
80
77
  return returnValue;
81
78
  }
82
79
  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
@@ -86,7 +83,7 @@ function PhoneInput(props) {
86
83
  setShowCountryOptions(false);
87
84
  setValue(country.mask);
88
85
  }, isActive: country.iso === currentCountry.iso, size: size }, country.iso))), countries.filter((country) => filterCountryFunction(country))
89
- .length === 0 && _jsx("p", { children: notFoundCountryText })] }), _jsx(PhoneInputCountriesOverlay, { isOpen: showCountryOptions, onClick: handleCloseCountryOptions }), _jsx(PhoneInputMask, { ref: inputPhoneMaskRef, currentCountry: currentCountry, value: usedValue, onChange: (e) => {
86
+ .length === 0 && _jsx("p", { children: notFoundCountryText })] }), _jsx(PhoneInputCountriesOverlay, { isOpen: showCountryOptions, onClick: handleCloseCountryOptions }), _jsx(PhoneInputMask, { ref: inputPhoneMaskRef, currentCountry: currentCountry, value: value, onChange: (e) => {
90
87
  setValue(e);
91
88
  onChange && onChange(inputValue(e));
92
89
  }, disabled: disabled, onBlur: handleInputBlur, onFocus: handleInputFocus, size: size }), _jsx("input", { ref: inputRef, type: "hidden", name: name, value: inputValue() })] }));