Skip to content

Commit 9893ecd

Browse files
committed
Implement enableArrow prototype for phone inputs
1 parent cdb1908 commit 9893ecd

File tree

6 files changed

+37
-4
lines changed

6 files changed

+37
-4
lines changed

development/src/AntDemo.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,11 @@ const AntDemo = () => {
4848
)}
4949
<Form>
5050
<FormItem name="phone" rules={[{validator}]}>
51-
<PhoneInput enableSearch onChange={(e) => setValue(e as any)}/>
51+
<PhoneInput
52+
enableArrow
53+
enableSearch
54+
onChange={(e) => setValue(e as any)}
55+
/>
5256
</FormItem>
5357
<FormItem name="test">
5458
<Input/>

development/src/MuiDemo.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const Demo = () => {
3232
)}
3333
<form noValidate autoComplete="off" onSubmit={e => e.preventDefault()}>
3434
<PhoneInput
35+
enableArrow
3536
enableSearch
3637
error={error}
3738
variant="filled"

development/src/ant-phone/index.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ const PhoneInput = forwardRef(({
3939
value: initialValue = "",
4040
country = getDefaultISO2Code(),
4141
disabled = false,
42+
enableArrow = false,
4243
enableSearch = false,
4344
disableDropdown = false,
4445
disableParentheses = false,
@@ -224,7 +225,18 @@ const PhoneInput = forwardRef(({
224225
<Select.Option
225226
value={iso + dial}
226227
key={`${iso}_${mask}`}
227-
label={<div className={`flag ${iso}`}/>}
228+
label={<>
229+
<div className={`flag ${iso}`}/>
230+
{enableArrow && (
231+
<span role="img" className="anticon" style={{paddingLeft: 8}}>
232+
<svg className="icon" viewBox="0 0 1024 1024"
233+
focusable="false" fill="currentColor" width="16" height="18">
234+
<path
235+
d="M848 368a48 48 0 0 0-81.312-34.544l-0.016-0.016-254.784 254.784-251.488-251.488a48 48 0 1 0-71.04 64.464l-0.128 0.128 288 288 0.016-0.016a47.84 47.84 0 0 0 34.544 14.688h0.224a47.84 47.84 0 0 0 34.544-14.688l0.016 0.016 288-288-0.016-0.016c8.32-8.624 13.44-20.368 13.44-33.312z"/>
236+
</svg>
237+
</span>
238+
)}
239+
</>}
228240
children={<div className={`${prefixCls}-phone-input-select-item`}>
229241
<div className={`flag ${iso}`}/>
230242
{countries[name]}&nbsp;{displayFormat(mask)}
@@ -233,7 +245,7 @@ const PhoneInput = forwardRef(({
233245
)
234246
})}
235247
</Select>
236-
), [selectValue, query, disabled, disableParentheses, disableDropdown, onDropdownVisibleChange, minWidth, searchNotFound, countries, countriesList, setFieldValue, setValue, prefixCls, enableSearch, searchPlaceholder])
248+
), [selectValue, query, enableArrow, disabled, disableParentheses, disableDropdown, onDropdownVisibleChange, minWidth, searchNotFound, countries, countriesList, setFieldValue, setValue, prefixCls, enableSearch, searchPlaceholder])
237249

238250
return (
239251
<div className={`${prefixCls}-phone-input-wrapper`}

development/src/ant-phone/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ export interface PhoneInputProps extends Omit<InputProps, "value" | "onChange">
1111

1212
country?: string;
1313

14+
enableArrow?: boolean;
15+
1416
enableSearch?: boolean;
1517

1618
searchNotFound?: string;

development/src/mui-phone/index.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const PhoneInput = forwardRef(({
2727
searchVariant = undefined,
2828
country = getDefaultISO2Code(),
2929
disabled = false,
30+
enableArrow = false,
3031
enableSearch = false,
3132
disableDropdown = false,
3233
disableParentheses = false,
@@ -198,10 +199,21 @@ const PhoneInput = forwardRef(({
198199
startAdornment: (
199200
<InputAdornment position="start">
200201
<span
201-
style={{cursor: "pointer"}}
202+
style={{
203+
display: "flex",
204+
cursor: "pointer",
205+
alignItems: "center",
206+
justifyContent: "center",
207+
}}
202208
onClick={() => setOpen(!open)}
203209
>
204210
<div className={`flag ${countryCode}`}/>
211+
{enableArrow && (
212+
<svg viewBox="0 0 24 24" focusable="false" fill="currentColor"
213+
style={{paddingLeft: 4}} width="22" height="20">
214+
<path d="M7.41 8.59 12 13.17l4.59-4.58L18 10l-6 6-6-6z"/>
215+
</svg>
216+
)}
205217
</span>
206218
</InputAdornment>
207219
)

development/src/mui-phone/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ export interface PhoneInputProps extends Omit<TextFieldProps, "onChange"> {
1313

1414
country?: string;
1515

16+
enableArrow?: boolean;
17+
1618
enableSearch?: boolean;
1719

1820
searchNotFound?: string;

0 commit comments

Comments
 (0)