diff --git a/README.md b/README.md index fbf0a6f..791bf7a 100644 --- a/README.md +++ b/README.md @@ -99,6 +99,7 @@ Apart from the phone-specific properties described below, all [Input](https://mu |--------------------|-------------------------------------------------------------------------------------------------------------------------------|---------------------------| | value | An object containing a parsed phone number or the raw number. | [object](#value) / string | | country | Country code to be selected by default. By default, it will show the flag of the user's country. | string | +| distinct | Show the distinct list of country codes not listing all area codes. | boolean | | enableArrow | Shows an arrow next to the country flag. Default value is `false`. | boolean | | enableSearch | Enables search in the country selection dropdown menu. Default value is `false`. | boolean | | searchVariant | Accepts an Input variant, and values depend on the chosen Material distribution. | TextFieldVariants | diff --git a/examples/material/package.json b/examples/material/package.json index b9c7cf5..cfef90d 100644 --- a/examples/material/package.json +++ b/examples/material/package.json @@ -10,7 +10,7 @@ "@types/react": "^18.2.0", "@types/react-dom": "^18.2.0", "copy-to-clipboard": "^3.3.3", - "mui-phone-input": "^0.1.3", + "mui-phone-input": "^0.1.5", "react": "^18.2.0", "react-dom": "^18.2.0", "react-hook-form": "^7.51.4", diff --git a/examples/material/src/Demo.tsx b/examples/material/src/Demo.tsx index 33101ab..c79de5b 100644 --- a/examples/material/src/Demo.tsx +++ b/examples/material/src/Demo.tsx @@ -29,6 +29,7 @@ const Demo = () => { const [copied, setCopied] = useState(false); const [preview, setPreview] = useState(false); const [dropdown, setDropdown] = useState(true); + const [distinct, setDistinct] = useState(false); const [disabled, setDisabled] = useState(false); const [parentheses, setParentheses] = useState(true); @@ -50,6 +51,7 @@ const Demo = () => { const code = useMemo(() => { let code = " { if (code === " @@ -85,53 +87,64 @@ const Demo = () => {
setDropdown(!dropdown)} />} labelPlacement="start" style={{margin: 0}} - label="Theme" + label="Dropdown" /> setStrict(!strict)} + onChange={() => setParentheses(!parentheses)} />} labelPlacement="start" style={{margin: 0}} - label="Validation" - defaultChecked + label="Parentheses" /> +
+
setDisabled(!disabled)} + onChange={changeTheme} />} labelPlacement="start" style={{margin: 0}} - label="Disabled" + label="Theme" + /> + setStrict(!strict)} + />} + labelPlacement="start" + style={{margin: 0}} + label="Validation" + defaultChecked />
setDropdown(!dropdown)} + onChange={() => setDisabled(!disabled)} />} labelPlacement="start" style={{margin: 0}} - label="Dropdown" + label="Disabled" /> setParentheses(!parentheses)} + onChange={() => setDistinct(!distinct)} />} labelPlacement="start" style={{margin: 0}} - label="Parentheses" + label="Distinct" />
@@ -183,6 +196,7 @@ const Demo = () => { { country?: string; + distinct?: boolean; + enableArrow?: boolean; enableSearch?: boolean; diff --git a/src/index.tsx b/src/index.tsx index 6469bc6..1328c75 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -27,6 +27,7 @@ const PhoneInput = forwardRef(({ variant = undefined, searchVariant = undefined, country = getDefaultISO2Code(), + distinct = false, disabled = false, enableArrow = false, enableSearch = false, @@ -69,6 +70,7 @@ const PhoneInput = forwardRef(({ query, locale, country, + distinct, countryCode, initialValue, onlyCountries, diff --git a/src/joy/index.tsx b/src/joy/index.tsx index 0707a08..b447347 100644 --- a/src/joy/index.tsx +++ b/src/joy/index.tsx @@ -27,6 +27,7 @@ const PhoneInput = forwardRef(({ variant = undefined, searchVariant = undefined, country = getDefaultISO2Code(), + distinct = false, disabled = false, enableArrow = false, enableSearch = false, @@ -69,6 +70,7 @@ const PhoneInput = forwardRef(({ query, locale, country, + distinct, countryCode, initialValue, onlyCountries, diff --git a/src/joy/types.ts b/src/joy/types.ts index 5326e7e..e6e3fb5 100644 --- a/src/joy/types.ts +++ b/src/joy/types.ts @@ -13,6 +13,8 @@ export interface PhoneInputProps extends Omit country?: string; + distinct?: boolean; + enableArrow?: boolean; enableSearch?: boolean; diff --git a/src/types.ts b/src/types.ts index c48c3a4..4df78db 100644 --- a/src/types.ts +++ b/src/types.ts @@ -13,6 +13,8 @@ export interface PhoneInputProps extends Omit { country?: string; + distinct?: boolean; + enableArrow?: boolean; enableSearch?: boolean;