@arkyn/components 3.0.1-beta.121 → 3.0.1-beta.123
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/dist/bundle.js +3141 -3125
- package/dist/bundle.umd.cjs +41 -40
- package/dist/components/phoneInput/index.d.ts +1 -106
- package/dist/components/phoneInput/index.d.ts.map +1 -1
- package/dist/components/phoneInput/index.js +11 -139
- package/dist/components/phoneInput/phoneInputCountryOption/index.d.ts +1 -2
- package/dist/components/phoneInput/phoneInputCountryOption/index.d.ts.map +1 -1
- package/dist/components/phoneInput/phoneInputCountrySelector/index.d.ts +1 -2
- package/dist/components/phoneInput/phoneInputCountrySelector/index.d.ts.map +1 -1
- package/dist/components/phoneInput/phoneInputMask/index.d.ts +1 -2
- package/dist/components/phoneInput/phoneInputMask/index.d.ts.map +1 -1
- package/dist/components/phoneInput/phoneInputMask/index.js +5 -2
- package/dist/utils/phoneInputUtilities.d.ts +1 -1713
- package/dist/utils/phoneInputUtilities.d.ts.map +1 -1
- package/dist/utils/phoneInputUtilities.js +1 -63
- package/package.json +6 -3
|
@@ -14,114 +14,9 @@ type PhoneInputProps = {
|
|
|
14
14
|
notFoundCountryText?: string;
|
|
15
15
|
name: string;
|
|
16
16
|
searchCountryPlaceholder?: string;
|
|
17
|
-
|
|
17
|
+
defaultCountryIso?: (typeof countries)[number]["iso"];
|
|
18
18
|
onChange?: (e: string) => void;
|
|
19
19
|
};
|
|
20
|
-
/**
|
|
21
|
-
* PhoneInput component - used for international phone number input with country selection and automatic formatting
|
|
22
|
-
*
|
|
23
|
-
* @param props - PhoneInput component properties
|
|
24
|
-
* @param props.name - Required field name for form handling and phone input identification
|
|
25
|
-
* @param props.label - Optional label text to display above the phone input
|
|
26
|
-
* @param props.showAsterisk - Whether to show asterisk on label for required fields
|
|
27
|
-
* @param props.errorMessage - Error message to display below the phone input
|
|
28
|
-
* @param props.size - Size variant of the phone input. Default: "md"
|
|
29
|
-
* @param props.variant - Visual variant of the phone input. Default: "solid"
|
|
30
|
-
* @param props.defaultValue - Default phone number value for the input
|
|
31
|
-
* @param props.defaultCountry - Default country ISO code to be selected. Uses country index 30 if not provided
|
|
32
|
-
* @param props.disabled - Whether the phone input is disabled. Default: false
|
|
33
|
-
* @param props.readOnly - Whether the phone input is read-only. Default: false
|
|
34
|
-
* @param props.isLoading - Whether the phone input is in loading state. Default: false
|
|
35
|
-
* @param props.className - Additional CSS classes for styling
|
|
36
|
-
* @param props.id - Optional unique identifier for the input
|
|
37
|
-
* @param props.searchCountryPlaceholder - Placeholder text for country search field. Default: "Pesquisar país"
|
|
38
|
-
* @param props.notFoundCountryText - Text displayed when no countries match the search. Default: "Nenhum país encontrado"
|
|
39
|
-
* @param props.onChange - Callback function called when phone number changes, receives the formatted value with country code
|
|
40
|
-
*
|
|
41
|
-
* @returns PhoneInput JSX element wrapped in FieldWrapper with country selector, masked input, and validation
|
|
42
|
-
*
|
|
43
|
-
* @example
|
|
44
|
-
* ```tsx
|
|
45
|
-
* // Basic phone input
|
|
46
|
-
* <PhoneInput name="phone" />
|
|
47
|
-
*
|
|
48
|
-
* // Phone input with label and default country
|
|
49
|
-
* <PhoneInput
|
|
50
|
-
* name="contactPhone"
|
|
51
|
-
* label="Contact Phone"
|
|
52
|
-
* defaultCountry="US"
|
|
53
|
-
* showAsterisk
|
|
54
|
-
* />
|
|
55
|
-
*
|
|
56
|
-
* // Phone input with validation and custom text
|
|
57
|
-
* <PhoneInput
|
|
58
|
-
* name="businessPhone"
|
|
59
|
-
* label="Business Phone"
|
|
60
|
-
* errorMessage="Please enter a valid phone number"
|
|
61
|
-
* searchCountryPlaceholder="Search country..."
|
|
62
|
-
* notFoundCountryText="Country not found"
|
|
63
|
-
* />
|
|
64
|
-
*
|
|
65
|
-
* // Large phone input with default value
|
|
66
|
-
* <PhoneInput
|
|
67
|
-
* name="emergencyContact"
|
|
68
|
-
* label="Emergency Contact"
|
|
69
|
-
* size="lg"
|
|
70
|
-
* variant="outline"
|
|
71
|
-
* defaultValue="+1 (555) 123-4567"
|
|
72
|
-
* defaultCountry="US"
|
|
73
|
-
* />
|
|
74
|
-
*
|
|
75
|
-
* // Controlled phone input with callback
|
|
76
|
-
* <PhoneInput
|
|
77
|
-
* name="userPhone"
|
|
78
|
-
* label="Your Phone Number"
|
|
79
|
-
* onChange={(formattedPhone) => {
|
|
80
|
-
* console.log('Phone number:', formattedPhone);
|
|
81
|
-
* setPhoneNumber(formattedPhone);
|
|
82
|
-
* }}
|
|
83
|
-
* defaultCountry="BR"
|
|
84
|
-
* showAsterisk
|
|
85
|
-
* />
|
|
86
|
-
*
|
|
87
|
-
* // Read-only phone input for display
|
|
88
|
-
* <PhoneInput
|
|
89
|
-
* name="displayPhone"
|
|
90
|
-
* label="Registered Phone"
|
|
91
|
-
* defaultValue="+55 11 99999-9999"
|
|
92
|
-
* readOnly
|
|
93
|
-
* variant="outline"
|
|
94
|
-
* />
|
|
95
|
-
*
|
|
96
|
-
* // Disabled phone input
|
|
97
|
-
* <PhoneInput
|
|
98
|
-
* name="lockedPhone"
|
|
99
|
-
* label="Phone (Locked)"
|
|
100
|
-
* defaultValue="+1 (555) 987-6543"
|
|
101
|
-
* disabled
|
|
102
|
-
* className="locked-field"
|
|
103
|
-
* />
|
|
104
|
-
*
|
|
105
|
-
* // Phone input with loading state
|
|
106
|
-
* <PhoneInput
|
|
107
|
-
* name="loadingPhone"
|
|
108
|
-
* label="Phone Number"
|
|
109
|
-
* isLoading
|
|
110
|
-
* defaultCountry="CA"
|
|
111
|
-
* />
|
|
112
|
-
* ```
|
|
113
|
-
*
|
|
114
|
-
* @remarks
|
|
115
|
-
* This component provides:
|
|
116
|
-
* - Automatic phone number formatting based on selected country
|
|
117
|
-
* - Searchable country dropdown with flags and country codes
|
|
118
|
-
* - Support for international phone number formats
|
|
119
|
-
* - Integration with form validation systems
|
|
120
|
-
* - Accessibility features with proper labeling
|
|
121
|
-
*
|
|
122
|
-
* The component uses country data from @arkyn/templates and automatically formats
|
|
123
|
-
* phone numbers according to each country's specific format and mask patterns.
|
|
124
|
-
*/
|
|
125
20
|
declare function PhoneInput(props: PhoneInputProps): import("react/jsx-runtime").JSX.Element;
|
|
126
21
|
export { PhoneInput };
|
|
127
22
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/phoneInput/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/phoneInput/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AA6B7C,KAAK,eAAe,GAAG;IACrB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,iBAAiB,CAAC,EAAE,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC;IACtD,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;CAChC,CAAC;AAEF,iBAAS,UAAU,CAAC,KAAK,EAAE,eAAe,2CAmKzC;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { countries } from "@arkyn/templates";
|
|
3
3
|
import { useId, useRef, useState } from "react";
|
|
4
|
+
import { findCountryMask, formatToPhone, removeNonNumeric, } from "@arkyn/shared";
|
|
4
5
|
import { useForm } from "../../hooks/useForm";
|
|
5
|
-
import { getDefaultFormatPhoneNumber } from "../../utils/phoneInputUtilities";
|
|
6
6
|
import { FieldError } from "../fieldError";
|
|
7
7
|
import { FieldLabel } from "../fieldLabel";
|
|
8
8
|
import { FieldWrapper } from "../fieldWrapper";
|
|
@@ -12,126 +12,18 @@ import { PhoneInputCountryOption } from "./phoneInputCountryOption";
|
|
|
12
12
|
import { PhoneInputCountryOptionsContainer } from "./phoneInputCountryOptionsContainer";
|
|
13
13
|
import { PhoneInputCountrySelector } from "./phoneInputCountrySelector";
|
|
14
14
|
import { PhoneInputMask } from "./phoneInputMask";
|
|
15
|
-
/**
|
|
16
|
-
* PhoneInput component - used for international phone number input with country selection and automatic formatting
|
|
17
|
-
*
|
|
18
|
-
* @param props - PhoneInput component properties
|
|
19
|
-
* @param props.name - Required field name for form handling and phone input identification
|
|
20
|
-
* @param props.label - Optional label text to display above the phone input
|
|
21
|
-
* @param props.showAsterisk - Whether to show asterisk on label for required fields
|
|
22
|
-
* @param props.errorMessage - Error message to display below the phone input
|
|
23
|
-
* @param props.size - Size variant of the phone input. Default: "md"
|
|
24
|
-
* @param props.variant - Visual variant of the phone input. Default: "solid"
|
|
25
|
-
* @param props.defaultValue - Default phone number value for the input
|
|
26
|
-
* @param props.defaultCountry - Default country ISO code to be selected. Uses country index 30 if not provided
|
|
27
|
-
* @param props.disabled - Whether the phone input is disabled. Default: false
|
|
28
|
-
* @param props.readOnly - Whether the phone input is read-only. Default: false
|
|
29
|
-
* @param props.isLoading - Whether the phone input is in loading state. Default: false
|
|
30
|
-
* @param props.className - Additional CSS classes for styling
|
|
31
|
-
* @param props.id - Optional unique identifier for the input
|
|
32
|
-
* @param props.searchCountryPlaceholder - Placeholder text for country search field. Default: "Pesquisar país"
|
|
33
|
-
* @param props.notFoundCountryText - Text displayed when no countries match the search. Default: "Nenhum país encontrado"
|
|
34
|
-
* @param props.onChange - Callback function called when phone number changes, receives the formatted value with country code
|
|
35
|
-
*
|
|
36
|
-
* @returns PhoneInput JSX element wrapped in FieldWrapper with country selector, masked input, and validation
|
|
37
|
-
*
|
|
38
|
-
* @example
|
|
39
|
-
* ```tsx
|
|
40
|
-
* // Basic phone input
|
|
41
|
-
* <PhoneInput name="phone" />
|
|
42
|
-
*
|
|
43
|
-
* // Phone input with label and default country
|
|
44
|
-
* <PhoneInput
|
|
45
|
-
* name="contactPhone"
|
|
46
|
-
* label="Contact Phone"
|
|
47
|
-
* defaultCountry="US"
|
|
48
|
-
* showAsterisk
|
|
49
|
-
* />
|
|
50
|
-
*
|
|
51
|
-
* // Phone input with validation and custom text
|
|
52
|
-
* <PhoneInput
|
|
53
|
-
* name="businessPhone"
|
|
54
|
-
* label="Business Phone"
|
|
55
|
-
* errorMessage="Please enter a valid phone number"
|
|
56
|
-
* searchCountryPlaceholder="Search country..."
|
|
57
|
-
* notFoundCountryText="Country not found"
|
|
58
|
-
* />
|
|
59
|
-
*
|
|
60
|
-
* // Large phone input with default value
|
|
61
|
-
* <PhoneInput
|
|
62
|
-
* name="emergencyContact"
|
|
63
|
-
* label="Emergency Contact"
|
|
64
|
-
* size="lg"
|
|
65
|
-
* variant="outline"
|
|
66
|
-
* defaultValue="+1 (555) 123-4567"
|
|
67
|
-
* defaultCountry="US"
|
|
68
|
-
* />
|
|
69
|
-
*
|
|
70
|
-
* // Controlled phone input with callback
|
|
71
|
-
* <PhoneInput
|
|
72
|
-
* name="userPhone"
|
|
73
|
-
* label="Your Phone Number"
|
|
74
|
-
* onChange={(formattedPhone) => {
|
|
75
|
-
* console.log('Phone number:', formattedPhone);
|
|
76
|
-
* setPhoneNumber(formattedPhone);
|
|
77
|
-
* }}
|
|
78
|
-
* defaultCountry="BR"
|
|
79
|
-
* showAsterisk
|
|
80
|
-
* />
|
|
81
|
-
*
|
|
82
|
-
* // Read-only phone input for display
|
|
83
|
-
* <PhoneInput
|
|
84
|
-
* name="displayPhone"
|
|
85
|
-
* label="Registered Phone"
|
|
86
|
-
* defaultValue="+55 11 99999-9999"
|
|
87
|
-
* readOnly
|
|
88
|
-
* variant="outline"
|
|
89
|
-
* />
|
|
90
|
-
*
|
|
91
|
-
* // Disabled phone input
|
|
92
|
-
* <PhoneInput
|
|
93
|
-
* name="lockedPhone"
|
|
94
|
-
* label="Phone (Locked)"
|
|
95
|
-
* defaultValue="+1 (555) 987-6543"
|
|
96
|
-
* disabled
|
|
97
|
-
* className="locked-field"
|
|
98
|
-
* />
|
|
99
|
-
*
|
|
100
|
-
* // Phone input with loading state
|
|
101
|
-
* <PhoneInput
|
|
102
|
-
* name="loadingPhone"
|
|
103
|
-
* label="Phone Number"
|
|
104
|
-
* isLoading
|
|
105
|
-
* defaultCountry="CA"
|
|
106
|
-
* />
|
|
107
|
-
* ```
|
|
108
|
-
*
|
|
109
|
-
* @remarks
|
|
110
|
-
* This component provides:
|
|
111
|
-
* - Automatic phone number formatting based on selected country
|
|
112
|
-
* - Searchable country dropdown with flags and country codes
|
|
113
|
-
* - Support for international phone number formats
|
|
114
|
-
* - Integration with form validation systems
|
|
115
|
-
* - Accessibility features with proper labeling
|
|
116
|
-
*
|
|
117
|
-
* The component uses country data from @arkyn/templates and automatically formats
|
|
118
|
-
* phone numbers according to each country's specific format and mask patterns.
|
|
119
|
-
*/
|
|
120
15
|
function PhoneInput(props) {
|
|
121
|
-
const {
|
|
122
|
-
const
|
|
16
|
+
const { defaultCountryIso, label, className: wrapperClassName = "", disabled = false, errorMessage: baseErrorMessage, isLoading = false, readOnly = false, size = "md", defaultValue = "", variant = "solid", showAsterisk, name, onChange, searchCountryPlaceholder = "Pesquisar país", notFoundCountryText = "Nenhum país encontrado", id, } = props;
|
|
17
|
+
const brasilCountry = countries.find((country) => country.iso === "BR");
|
|
18
|
+
const defaultData = defaultValue ? formatToPhone(defaultValue) : "";
|
|
19
|
+
const defaultCountry = defaultValue
|
|
20
|
+
? findCountryMask(defaultValue)[1]
|
|
21
|
+
: brasilCountry;
|
|
123
22
|
const [isFocused, setIsFocused] = useState(false);
|
|
124
23
|
const [search, setSearch] = useState("");
|
|
125
24
|
const [showCountryOptions, setShowCountryOptions] = useState(false);
|
|
126
|
-
const [value, setValue] = useState(defaultData
|
|
127
|
-
const [currentCountry, setCurrentCountry] = useState(
|
|
128
|
-
if (defaultData.country)
|
|
129
|
-
return defaultData.country;
|
|
130
|
-
const country = countries.find((country) => country.iso === defaultCountry);
|
|
131
|
-
if (country)
|
|
132
|
-
return country;
|
|
133
|
-
return countries[30];
|
|
134
|
-
});
|
|
25
|
+
const [value, setValue] = useState(defaultData);
|
|
26
|
+
const [currentCountry, setCurrentCountry] = useState(defaultCountry);
|
|
135
27
|
const { fieldErrors } = useForm();
|
|
136
28
|
const phoneInputRef = useRef(null);
|
|
137
29
|
const phoneInputId = id || useId();
|
|
@@ -165,29 +57,9 @@ function PhoneInput(props) {
|
|
|
165
57
|
function filterCountryFunction(country) {
|
|
166
58
|
return country.name.toLowerCase().includes(search.toLowerCase());
|
|
167
59
|
}
|
|
168
|
-
function removeNumberMasks(number) {
|
|
169
|
-
if (currentCountry.prefix) {
|
|
170
|
-
return number
|
|
171
|
-
.replace(currentCountry.prefix, "")
|
|
172
|
-
.replaceAll(" ", "")
|
|
173
|
-
.replaceAll("-", "")
|
|
174
|
-
.replaceAll("(", "")
|
|
175
|
-
.replaceAll(")", "")
|
|
176
|
-
.trim();
|
|
177
|
-
}
|
|
178
|
-
return number
|
|
179
|
-
.replaceAll(" ", "")
|
|
180
|
-
.replaceAll("-", "")
|
|
181
|
-
.replaceAll("(", "")
|
|
182
|
-
.replaceAll(")", "")
|
|
183
|
-
.trim();
|
|
184
|
-
}
|
|
185
60
|
function inputValue(props) {
|
|
186
61
|
let returnValue = currentCountry.code;
|
|
187
|
-
|
|
188
|
-
returnValue += `-${currentCountry.prefix}`;
|
|
189
|
-
returnValue += " ";
|
|
190
|
-
returnValue += removeNumberMasks(props || value);
|
|
62
|
+
returnValue += removeNonNumeric(props || value);
|
|
191
63
|
return returnValue;
|
|
192
64
|
}
|
|
193
65
|
return (_jsxs(FieldWrapper, { className: wrapperClassName, children: [label && (_jsx(FieldLabel, { htmlFor: phoneInputId, showAsterisk: showAsterisk, children: label })), _jsxs(PhoneInputContainer, { disabled: isDisabled, isError: isError, isLoading: isLoading, isFocused: isFocused, readOnly: readOnly, size: size, variant: variant, onFocus: handleContainerFocus, children: [_jsx(PhoneInputCountrySelector, { currentCountry: currentCountry, onClick: handleOpenCountryOptions, size: size }), _jsxs(PhoneInputCountryOptionsContainer, { isOpen: isDisabled ? false : readOnly ? false : showCountryOptions, search: search, placeholder: searchCountryPlaceholder, onSearch: setSearch, children: [countries
|
|
@@ -195,7 +67,7 @@ function PhoneInput(props) {
|
|
|
195
67
|
.map((country) => (_jsx(PhoneInputCountryOption, { country: country, handleChangeValue: () => {
|
|
196
68
|
setCurrentCountry(country);
|
|
197
69
|
setShowCountryOptions(false);
|
|
198
|
-
setValue(
|
|
70
|
+
setValue("");
|
|
199
71
|
}, isActive: country.iso === currentCountry.iso, size: size }, country.iso))), countries.filter((country) => filterCountryFunction(country))
|
|
200
72
|
.length === 0 && _jsx("p", { children: notFoundCountryText })] }), _jsx(PhoneInputCountriesOverlay, { isOpen: isDisabled ? false : readOnly ? false : showCountryOptions, onClick: handleCloseCountryOptions }), _jsx(PhoneInputMask, { id: phoneInputId, ref: inputPhoneMaskRef, readonly: readOnly, currentCountry: currentCountry, value: value, disabled: isDisabled, onBlur: handleInputBlur, onFocus: handleInputFocus, size: size, onChange: (e) => {
|
|
201
73
|
setValue(e);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/phoneInput/phoneInputCountryOption/index.tsx"],"names":[],"mappings":"AACA,OAAO,cAAc,CAAC;AAEtB,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/phoneInput/phoneInputCountryOption/index.tsx"],"names":[],"mappings":"AACA,OAAO,cAAc,CAAC;AAEtB,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CACzB,CAAC;AAEF,KAAK,4BAA4B,GAAG;IAClC,OAAO,EAAE,WAAW,CAAC;IACrB,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,iBAAiB,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,IAAI,CAAC;CACnD,CAAC;AAEF,iBAAS,uBAAuB,CAAC,KAAK,EAAE,4BAA4B,2CAanE;AAED,OAAO,EAAE,uBAAuB,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/phoneInput/phoneInputCountrySelector/index.tsx"],"names":[],"mappings":"AAGA,OAAO,cAAc,CAAC;AAEtB,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/phoneInput/phoneInputCountrySelector/index.tsx"],"names":[],"mappings":"AAGA,OAAO,cAAc,CAAC;AAEtB,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CACzB,CAAC;AAEF,KAAK,8BAA8B,GAAG;IACpC,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;IAClB,cAAc,EAAE,WAAW,CAAC;IAC5B,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC;AAEF,iBAAS,yBAAyB,CAAC,KAAK,EAAE,8BAA8B,2CAcvE;AAED,OAAO,EAAE,yBAAyB,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/phoneInput/phoneInputMask/index.tsx"],"names":[],"mappings":"AAiBA,OAAO,aAAa,CAAC;AAErB,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/phoneInput/phoneInputMask/index.tsx"],"names":[],"mappings":"AAiBA,OAAO,aAAa,CAAC;AAErB,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CACzB,CAAC;AAEF,KAAK,mBAAmB,GAAG;IACzB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;IAClB,cAAc,EAAE,WAAW,CAAC;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9B,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AASF,QAAA,MAAM,cAAc,kHA0EnB,CAAC;AAEF,OAAO,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -9,9 +9,12 @@ const BaseInput = forwardRef((props, ref) => {
|
|
|
9
9
|
const PhoneInputMask = forwardRef((props, ref) => {
|
|
10
10
|
const { onFocus, readonly, onBlur, size, onChange, value, currentCountry, disabled, id, } = props;
|
|
11
11
|
const [isMounted, setIsMounted] = useState(false);
|
|
12
|
+
const mask = typeof currentCountry.mask === "string"
|
|
13
|
+
? currentCountry.mask
|
|
14
|
+
: currentCountry.mask[0];
|
|
12
15
|
useEffect(() => {
|
|
13
16
|
if (isMounted)
|
|
14
|
-
onChange(
|
|
17
|
+
onChange(mask);
|
|
15
18
|
else
|
|
16
19
|
setIsMounted(true);
|
|
17
20
|
}, [currentCountry]);
|
|
@@ -29,6 +32,6 @@ const PhoneInputMask = forwardRef((props, ref) => {
|
|
|
29
32
|
if (currentCountry.code === "+55") {
|
|
30
33
|
return (_jsx("input", { id: id, value: value, onChange: handleChange, className: className, onFocus: onFocus, onBlur: onBlur, disabled: disabled, ref: ref }));
|
|
31
34
|
}
|
|
32
|
-
return (_jsx(InputMask, { id: id, value: value, readOnly: readonly, onChange: (e) => onChange(e.target.value), className: className, component: BaseInput, onFocus: onFocus, onBlur: onBlur, disabled: disabled, mask:
|
|
35
|
+
return (_jsx(InputMask, { id: id, value: value, readOnly: readonly, onChange: (e) => onChange(e.target.value), className: className, component: BaseInput, onFocus: onFocus, onBlur: onBlur, disabled: disabled, mask: mask, showMask: true, replacement: { _: /\d/ }, ref: ref }));
|
|
33
36
|
});
|
|
34
37
|
export { PhoneInputMask };
|