Skip to content

Commit

Permalink
typesnippetGH-79: Reexport types and functions
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtyomVancyan committed Jun 28, 2024
1 parent 2f25f84 commit 7a992e6
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import {
usePhone,
} from "react-phone-hooks";

import locale from "./locale";
import {injectMergedStyles} from "./styles";
import {PhoneInputProps, PhoneNumber} from "./types";

Expand All @@ -45,8 +46,8 @@ const PhoneInput = forwardRef(({
onlyCountries = [],
excludeCountries = [],
preferredCountries = [],
searchNotFound = "No country found",
searchPlaceholder = "Search country",
searchNotFound: defaultSearchNotFound = "No country found",
searchPlaceholder: defaultSearchPlaceholder = "Search country",
dropdownRender = (node) => node,
onMount: handleMount = () => null,
onInput: handleInput = () => null,
Expand All @@ -55,6 +56,7 @@ const PhoneInput = forwardRef(({
...antInputProps
}: PhoneInputProps, forwardedRef: any) => {
const formInstance = useFormInstance();
const {locale = {}} = useContext(ConfigContext);
const formContext = useContext(FormContext);
const {getPrefixCls} = useContext(ConfigContext);
const inputRef = useRef<any>(null);
Expand All @@ -65,6 +67,12 @@ const PhoneInput = forwardRef(({
const [minWidth, setMinWidth] = useState<number>(0);
const [countryCode, setCountryCode] = useState<string>(country);

const {
searchNotFound = defaultSearchNotFound,
searchPlaceholder = defaultSearchPlaceholder,
countries = new Proxy({}, ({get: (_: any, prop: any) => prop})),
} = (locale as any).PhoneInput || {};

const prefixCls = getPrefixCls();
injectMergedStyles(prefixCls);

Expand Down Expand Up @@ -222,13 +230,13 @@ const PhoneInput = forwardRef(({
label={<div className={`flag ${iso}`}/>}
children={<div className={`${prefixCls}-phone-input-select-item`}>
<div className={`flag ${iso}`}/>
{name}&nbsp;{displayFormat(mask)}
{countries[name]}&nbsp;{displayFormat(mask)}
</div>}
/>
)
})}
</Select>
), [selectValue, query, disabled, disableParentheses, disableDropdown, onDropdownVisibleChange, minWidth, searchNotFound, countriesList, setFieldValue, setValue, prefixCls, enableSearch, searchPlaceholder])
), [selectValue, query, disabled, disableParentheses, disableDropdown, onDropdownVisibleChange, minWidth, searchNotFound, countries, countriesList, setFieldValue, setValue, prefixCls, enableSearch, searchPlaceholder])

return (
<div className={`${prefixCls}-phone-input-wrapper`}
Expand All @@ -249,3 +257,4 @@ const PhoneInput = forwardRef(({
})

export default PhoneInput;
export {PhoneInputProps, PhoneNumber, locale};

0 comments on commit 7a992e6

Please sign in to comment.