Skip to content

Commit 10de49f

Browse files
committed
Sync with the latest releases
1 parent 55d586b commit 10de49f

File tree

9 files changed

+166
-114
lines changed

9 files changed

+166
-114
lines changed

development/src/ant-phone/index.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import {
3232
usePhone,
3333
} from "../phone-hooks";
3434

35+
import locale from "./locale";
3536
import {injectMergedStyles} from "./styles";
3637
import {PhoneInputProps, PhoneNumber} from "./types";
3738

@@ -46,6 +47,8 @@ const PhoneInput = forwardRef(({
4647
onlyCountries = [],
4748
excludeCountries = [],
4849
preferredCountries = [],
50+
searchNotFound: defaultSearchNotFound = "No country found",
51+
searchPlaceholder: defaultSearchPlaceholder = "Search country",
4952
dropdownRender = (node) => node,
5053
onMount: handleMount = () => null,
5154
onInput: handleInput = () => null,
@@ -66,8 +69,8 @@ const PhoneInput = forwardRef(({
6669
const [countryCode, setCountryCode] = useState<string>(country);
6770

6871
const {
69-
searchNotFound = "No country found",
70-
searchPlaceholder = "Search country",
72+
searchNotFound = defaultSearchNotFound,
73+
searchPlaceholder = defaultSearchPlaceholder,
7174
countries = new Proxy({}, ({get: (_: any, prop: any) => prop})),
7275
} = (locale as any).PhoneInput || {};
7376

@@ -266,3 +269,4 @@ const PhoneInput = forwardRef(({
266269
})
267270

268271
export default PhoneInput;
272+
export type {PhoneInputProps, PhoneNumber, locale};

development/src/mui-phone/base/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,3 +145,4 @@ const PhoneInput = forwardRef(({
145145
})
146146

147147
export default PhoneInput;
148+
export type {PhoneInputProps, PhoneNumber};

development/src/mui-phone/index.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
usePhone,
1717
} from "../phone-hooks";
1818

19+
import locale from "./locale";
1920
import {injectMergedStyles} from "./styles";
2021
import {PhoneInputProps, PhoneNumber} from "./types";
2122

@@ -34,6 +35,8 @@ const PhoneInput = forwardRef(({
3435
onlyCountries = [],
3536
excludeCountries = [],
3637
preferredCountries = [],
38+
searchNotFound: defaultSearchNotFound = "No country found",
39+
searchPlaceholder: defaultSearchPlaceholder = "Search country",
3740
onMount: handleMount = () => null,
3841
onInput: handleInput = () => null,
3942
onChange: handleChange = () => null,
@@ -50,8 +53,8 @@ const PhoneInput = forwardRef(({
5053
const [countryCode, setCountryCode] = useState<string>(country);
5154

5255
const {
53-
searchNotFound = "No country found",
54-
searchPlaceholder = "Search country",
56+
searchNotFound = defaultSearchNotFound,
57+
searchPlaceholder = defaultSearchPlaceholder,
5558
countries = new Proxy({}, ({get: (_: any, prop: any) => prop})),
5659
} = useThemeProps({props: {}, name: "MuiPhoneInput"}) as any;
5760

@@ -225,3 +228,4 @@ const PhoneInput = forwardRef(({
225228
})
226229

227230
export default PhoneInput;
231+
export type {PhoneInputProps, PhoneNumber, locale};

development/src/mui-phone/joy/index.tsx

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"use client";
22

33
import {ChangeEvent, forwardRef, KeyboardEvent, useCallback, useEffect, useMemo, useRef, useState} from "react";
4-
import {Input, Option, Select} from "@mui/joy";
4+
import {Input, Option, Select, useThemeProps} from "@mui/joy";
55

66
import {
77
checkValidity,
@@ -16,6 +16,7 @@ import {
1616
usePhone,
1717
} from "../../phone-hooks";
1818

19+
import locale from "../locale";
1920
import {injectMergedStyles} from "./styles";
2021
import {PhoneInputProps, PhoneNumber} from "./types";
2122

@@ -27,14 +28,15 @@ const PhoneInput = forwardRef(({
2728
searchVariant = undefined,
2829
country = getDefaultISO2Code(),
2930
disabled = false,
31+
enableArrow = false,
3032
enableSearch = false,
3133
disableDropdown = false,
3234
disableParentheses = false,
3335
onlyCountries = [],
3436
excludeCountries = [],
3537
preferredCountries = [],
36-
searchNotFound = "No country found",
37-
searchPlaceholder = "Search country",
38+
searchNotFound: defaultSearchNotFound = "No country found",
39+
searchPlaceholder: defaultSearchPlaceholder = "Search country",
3840
onMount: handleMount = () => null,
3941
onInput: handleInput = () => null,
4042
onChange: handleChange = () => null,
@@ -50,6 +52,12 @@ const PhoneInput = forwardRef(({
5052
const [maxWidth, setMaxWidth] = useState<number>(0);
5153
const [countryCode, setCountryCode] = useState<string>(country);
5254

55+
const {
56+
searchNotFound = defaultSearchNotFound,
57+
searchPlaceholder = defaultSearchPlaceholder,
58+
countries = new Proxy({}, ({get: (_: any, prop: any) => prop})),
59+
} = useThemeProps({props: {}, name: "MuiPhoneInput"}) as any;
60+
5361
const {
5462
value,
5563
pattern,
@@ -168,7 +176,7 @@ const PhoneInput = forwardRef(({
168176
children={<div className="mui-phone-input-select-item">
169177
<div className={`flag ${iso}`}/>
170178
<div className="label">
171-
{name}&nbsp;{displayFormat(mask)}
179+
{countries[name]}&nbsp;{displayFormat(mask)}
172180
</div>
173181
</div>}
174182
/>
@@ -189,10 +197,21 @@ const PhoneInput = forwardRef(({
189197
onKeyDown={onKeyDown}
190198
startDecorator={(
191199
<span
192-
style={{cursor: "pointer"}}
200+
style={{
201+
display: "flex",
202+
cursor: "pointer",
203+
alignItems: "center",
204+
justifyContent: "center",
205+
}}
193206
onClick={() => setOpen(!open)}
194207
>
195208
<div className={`flag ${countryCode}`}/>
209+
{enableArrow && (
210+
<svg viewBox="0 0 24 24" focusable="false" fill="currentColor"
211+
style={{paddingLeft: 4}} width="22" height="20">
212+
<path d="M7.41 8.59 12 13.17l4.59-4.58L18 10l-6 6-6-6z"/>
213+
</svg>
214+
)}
196215
</span>
197216
)}
198217
{...(muiInputProps as any)}
@@ -202,3 +221,4 @@ const PhoneInput = forwardRef(({
202221
})
203222

204223
export default PhoneInput;
224+
export type {PhoneInputProps, PhoneNumber, locale};

development/src/mui-phone/joy/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<InputProps, "value" | "onChange">
1313

1414
country?: string;
1515

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

1820
searchNotFound?: string;

0 commit comments

Comments
 (0)