@arkyn/components 1.4.56 → 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":"AAEA,OAAO,EAAe,eAAe,EAAE,MAAM,cAAc,CAAC;AAY5D,iBAAS,UAAU,CAAC,KAAK,EAAE,eAAe,2CAkKzC;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"}
@@ -1,6 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { countries } from "@arkyn/templates";
3
- import { formatToPhone } from "@arkyn/shared";
4
3
  import { useRef, useState } from "react";
5
4
  import { useFormController } from "../Form/FormController";
6
5
  import { PhoneInputContainer } from "./components/PhoneInputContainer";
@@ -11,13 +10,12 @@ import { PhoneInputCountrySelector } from "./components/PhoneInputCountrySelecto
11
10
  import { PhoneInputMask } from "./components/PhoneInputMask";
12
11
  import { getDefaultFormatPhoneNumber } from "./services/getDefaultFormatPhoneNumber";
13
12
  function PhoneInput(props) {
14
- 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;
15
14
  const defaultData = getDefaultFormatPhoneNumber(defaultValue);
16
15
  const [isFocused, setIsFocused] = useState(false);
17
16
  const [search, setSearch] = useState("");
18
17
  const [showCountryOptions, setShowCountryOptions] = useState(false);
19
18
  const [value, setValue] = useState(defaultData.formattedNumber || "");
20
- const usedValue = formatToPhone(fixedValue) || value;
21
19
  const [currentCountry, setCurrentCountry] = useState(() => {
22
20
  if (defaultData.country)
23
21
  return defaultData.country;
@@ -75,7 +73,7 @@ function PhoneInput(props) {
75
73
  if (currentCountry.prefix)
76
74
  returnValue += `-${currentCountry.prefix}`;
77
75
  returnValue += " ";
78
- returnValue += removeNumberMasks(props || usedValue);
76
+ returnValue += removeNumberMasks(props || value);
79
77
  return returnValue;
80
78
  }
81
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
@@ -85,7 +83,7 @@ function PhoneInput(props) {
85
83
  setShowCountryOptions(false);
86
84
  setValue(country.mask);
87
85
  }, isActive: country.iso === currentCountry.iso, size: size }, country.iso))), countries.filter((country) => filterCountryFunction(country))
88
- .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) => {
89
87
  setValue(e);
90
88
  onChange && onChange(inputValue(e));
91
89
  }, disabled: disabled, onBlur: handleInputBlur, onFocus: handleInputFocus, size: size }), _jsx("input", { ref: inputRef, type: "hidden", name: name, value: inputValue() })] }));