@arkyn/components 1.4.42 → 1.4.44

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,2CAgKzC;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,7 +10,7 @@ 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, searchCountryPlaceholder = "Pesquisar país", notFoundCountryText = "Nenhum país encontrado", ...rest } = 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("");
@@ -68,12 +68,12 @@ function PhoneInput(props) {
68
68
  .replaceAll(")", "")
69
69
  .trim();
70
70
  }
71
- function inputValue() {
71
+ function inputValue(props) {
72
72
  let returnValue = currentCountry.code;
73
73
  if (currentCountry.prefix)
74
74
  returnValue += `-${currentCountry.prefix}`;
75
75
  returnValue += " ";
76
- returnValue += removeNumberMasks(value);
76
+ returnValue += removeNumberMasks(props || value);
77
77
  return returnValue;
78
78
  }
79
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 +85,7 @@ function PhoneInput(props) {
85
85
  }, isActive: country.iso === currentCountry.iso, size: size }, country.iso))), countries.filter((country) => filterCountryFunction(country))
86
86
  .length === 0 && _jsx("p", { children: notFoundCountryText })] }), _jsx(PhoneInputCountriesOverlay, { isOpen: showCountryOptions, onClick: handleCloseCountryOptions }), _jsx(PhoneInputMask, { ref: inputPhoneMaskRef, currentCountry: currentCountry, value: value, onChange: (e) => {
87
87
  setValue(e);
88
- rest.onChange && rest.onChange(e);
88
+ onChange && onChange(inputValue(e));
89
89
  }, disabled: disabled, onBlur: handleInputBlur, onFocus: handleInputFocus, size: size }), _jsx("input", { ref: inputRef, type: "hidden", name: name, value: inputValue() })] }));
90
90
  }
91
91
  export { PhoneInput };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkyn/components",
3
- "version": "1.4.42",
3
+ "version": "1.4.44",
4
4
  "main": "./dist/bundle.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "author": "Lucas Gonçalves",
@@ -23,6 +23,7 @@ function PhoneInput(props: PhoneInputProps) {
23
23
  defaultValue = "",
24
24
  variant = "solid",
25
25
  name,
26
+ onChange,
26
27
  searchCountryPlaceholder = "Pesquisar país",
27
28
  notFoundCountryText = "Nenhum país encontrado",
28
29
  ...rest
@@ -96,11 +97,11 @@ function PhoneInput(props: PhoneInputProps) {
96
97
  .trim();
97
98
  }
98
99
 
99
- function inputValue() {
100
+ function inputValue(props?: string) {
100
101
  let returnValue = currentCountry.code;
101
102
  if (currentCountry.prefix) returnValue += `-${currentCountry.prefix}`;
102
103
  returnValue += " ";
103
- returnValue += removeNumberMasks(value);
104
+ returnValue += removeNumberMasks(props || value);
104
105
  return returnValue;
105
106
  }
106
107
 
@@ -160,7 +161,7 @@ function PhoneInput(props: PhoneInputProps) {
160
161
  value={value}
161
162
  onChange={(e) => {
162
163
  setValue(e);
163
- rest.onChange && rest.onChange(e);
164
+ onChange && onChange(inputValue(e));
164
165
  }}
165
166
  disabled={disabled}
166
167
  onBlur={handleInputBlur}