mui-tel-input icon indicating copy to clipboard operation
mui-tel-input copied to clipboard

feat: ✨ Support Extensions with Additional Field

Open leachtucker opened this issue 1 year ago • 9 comments

Description

Adds support for inputting extensions via an additional input field.

image

Why

This library is incredibly useful yet it lacks support for entering extensions which is commonplace in the B2B world.

Changes

  • Extensions are managed via an additional input which can be enabled/disabled. It is off by default.
  • Parse extensions passed within the value prop of MuiTelInput.
  • Upon change of extension, the new value is included in the number (and info object) provided to the onChange callback.

Considerations

The formatted value passed to the onChange callback of MuiTelInput adheres to Google's development style guide on phone numbers.

Google's Dev Style Guide

To specify a phone extension, follow the phone number with the word extension, and then specify the extension number.

Due to the As You Type formatter not supporting extensions, the extension feature requires some additional layers of indirection and complexity in number parsing and formatting. As the complexity of the usePhoneDigits hook is growing, it is beginning to warrant some refactoring in order to improve code readability.

https://github.com/catamphetamine/libphonenumber-js

Google's "As You Type" formatter does not support entering phone number extensions. If your project requires phone number extensions input then use a separate input field for that.

leachtucker avatar Feb 02 '24 04:02 leachtucker

Hello !

Hum I'm waiting for more upvote because I for my personal POV, I've never seen an tel input like this. I don't really know the usecase for that.

But thanks for your PR <3

Ty

viclafouch avatar Feb 13 '24 23:02 viclafouch

Hello !

Hum I'm waiting for more upvote because I for my personal POV, I've never seen an tel input like this. I don't really know the usecase for that.

But thanks for your PR <3

Ty

Sounds good! Usually on the web, you would either find one input which supports the addition of extensions. Or, two inputs--one for the main number and one for the extension. Here, we technically have two but they act as one, which is convenient when integrating with a form. Anyhow, will keep an eye on this PR -- I am confident others have a use-case as well since extensions are relatively common for B2B.

leachtucker avatar Feb 15 '24 16:02 leachtucker

Hi, we've been looking for this as well and it seems like a good idea :)

pierce23john avatar Mar 06 '24 00:03 pierce23john

Hey @viclafouch. Any word on this?

leachtucker avatar Mar 25 '24 18:03 leachtucker

Hello !

Hum I'm waiting for more upvote because I for my personal POV, I've never seen an tel input like this. I don't really know the usecase for that.

But thanks for your PR <3

Ty

Dear @viclafouch

You are right, This type of tel input is not common case for general use cases in B2C application like social network web pages, online stores and etc.

This type of input is common on enterprise web application like ERP applications CRM or admin panels, for example when you register the company as an entity, in contact details they generally have only one phone line and many extensions. when you need to call finance department you will call that phone number and ext: 101 for Sales Ext:102, Fax Ext: 103 and so on. this feature is very useful for enterprise application and B2B use cases.

We've been looking for this as well and seems the implementation is good.

Thanks

mohsenomidi avatar Jun 16 '24 12:06 mohsenomidi

Hello !

Could you please fix the conflicts in order to merge the PR ;)

viclafouch avatar Jul 07 '24 12:07 viclafouch

Hey @viclafouch, PR is fixed up. Should be ready for merge 👍

leachtucker avatar Jul 17 '24 16:07 leachtucker

@viclafouch Waiting on a release with this change

bryanjtc avatar Aug 08 '24 15:08 bryanjtc