@@ -10,6 +10,7 @@ import {
1010 useState
1111} from "react" ;
1212import useFormInstance from "antd/es/form/hooks/useFormInstance" ;
13+ import { ConfigContext } from "antd/es/config-provider" ;
1314import { FormContext } from "antd/es/form/context" ;
1415import { useWatch } from "antd/es/form/Form" ;
1516import Select from "antd/es/select" ;
@@ -32,8 +33,6 @@ import {
3233import { injectMergedStyles } from "./styles" ;
3334import { PhoneInputProps , PhoneNumber } from "./types" ;
3435
35- injectMergedStyles ( ) ;
36-
3736const PhoneInput = forwardRef ( ( {
3837 value : initialValue = "" ,
3938 country = getDefaultISO2Code ( ) ,
@@ -52,13 +51,17 @@ const PhoneInput = forwardRef(({
5251 } : PhoneInputProps , forwardedRef : any ) => {
5352 const formInstance = useFormInstance ( ) ;
5453 const formContext = useContext ( FormContext ) ;
54+ const { getPrefixCls} = useContext ( ConfigContext ) ;
5555 const inputRef = useRef < any > ( null ) ;
5656 const selectedRef = useRef < boolean > ( false ) ;
5757 const initiatedRef = useRef < boolean > ( false ) ;
5858 const [ query , setQuery ] = useState < string > ( "" ) ;
5959 const [ minWidth , setMinWidth ] = useState < number > ( 0 ) ;
6060 const [ countryCode , setCountryCode ] = useState < string > ( country ) ;
6161
62+ const prefixCls = getPrefixCls ( ) ;
63+ injectMergedStyles ( prefixCls ) ;
64+
6265 const {
6366 value,
6467 pattern,
@@ -183,7 +186,7 @@ const PhoneInput = forwardRef(({
183186 dropdownStyle = { { minWidth} }
184187 notFoundContent = { searchNotFound }
185188 dropdownRender = { ( menu ) => (
186- < div className = "ant -phone-input-search-wrapper" >
189+ < div className = { ` ${ prefixCls } -phone-input-search-wrapper` } >
187190 { enableSearch && (
188191 < Input
189192 placeholder = { searchPlaceholder }
@@ -199,7 +202,7 @@ const PhoneInput = forwardRef(({
199202 value = { iso + dial }
200203 key = { `${ iso } _${ mask } ` }
201204 label = { < div className = { `flag ${ iso } ` } /> }
202- children = { < div className = "ant -phone-input-select-item" >
205+ children = { < div className = { ` ${ prefixCls } -phone-input-select-item` } >
203206 < div className = { `flag ${ iso } ` } />
204207 { name } { displayFormat ( mask ) }
205208 </ div > }
@@ -209,7 +212,7 @@ const PhoneInput = forwardRef(({
209212 ) , [ selectValue , disableDropdown , minWidth , searchNotFound , countriesList , setFieldValue , setValue , enableSearch , searchPlaceholder ] )
210213
211214 return (
212- < div className = "ant -phone-input-wrapper"
215+ < div className = { ` ${ prefixCls } -phone-input-wrapper` }
213216 ref = { node => setMinWidth ( node ?. offsetWidth || 0 ) } >
214217 < Input
215218 ref = { ref }
0 commit comments