Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🪄 Enhancement - Prop that shows distinct country codes without area codes, and prop that returns only string instead of PhoneNumber object #115

Closed
kanatzholayev opened this issue Jan 8, 2025 · 2 comments · Fixed by typesnippet/react-phone-hooks#67
Assignees
Labels
enhancement New feature or request

Comments

@kanatzholayev
Copy link

Summary

I like your library, but there is some options i want to add

Show distinct country codes without area codes option

image i do not really like this kind of duplicates in select, so we need here a boolean prop that will show only country codes without area codes

Return only string option

PhoneNumber object is great, but not all projects need that detailed object, sometimes we need just string. This library applies string in value prop, but when it returns to Form.Item, it always return object. I think there must be prop: valueAsString, that returns string like "+1 123 123123"

@kanatzholayev kanatzholayev added the enhancement New feature or request label Jan 8, 2025
@ArtyomVancyan
Copy link
Member

@kanatzholayev, thanks for the thoughts and recommendations. I like the idea of a boolean property that will show only a distinct list of countries. I will work on it in the coming weeks.

PhoneNumber object is great, but not all projects need that detailed object, sometimes we need just string.

Agreed, and of course, I counted this case. Ant Design's Form.Item has this normalize property that can easily convert anything to anything, such as an object, to a string.

import Form from "antd/es/form";
import PhoneInput from "antd-phone-input";
import {getRawValue} from "react-phone-hooks";

const Demo = () => {
    return (
        <Form.Item name="phone" normalize={getRawValue}>
            <PhoneInput />
        </Form.Item>
    )
}

NOTE: If you already have antd-phone-input installed, you don't need to install the react-phone-hooks package.

@ArtyomVancyan
Copy link
Member

ArtyomVancyan commented Feb 3, 2025

@kanatzholayev, please enjoy the new distinct boolean property for delisting the duplications from the countries list as you need.

<Form.Item name="phone">
    <PhoneInput distinct />
</Form.Item>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants