1.2.24 • Published 2 years ago

@bebeau/phone-number-input v1.2.24

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

Phone Number Input

This is a phone number input component that uses libphonenumber-js to validate and format as you type. The input includes a dial code selection dropdown and a search feature.

Install

  1. Add package to working project
yarn add @bebeau/phone-number-input
npm install @bebeau/phone-number-input
  1. Import into project
import PhoneNumberInput from '@bebeau/phone-number-input';
  1. Use the component
<PhoneNumberInput
  onInputChange={(data: {
    number: string,
    isValid: boolean
  }) => handlePhoneChange(data)}
  value="PHONE INPUT VALUE GOES HERE"
  placeholder="Phone Number"
>

Props

PropTypeDescription
onInputChangefunctiononInputChange is a function that passes a data object {number: string, isValid: boolean} up to the parent component.

Example

import react, {useState, useEffect} from 'react';
import PhoneNumberInput from '@bebeau/phone-number-input';

const Demo = () => {
  const [phone, setPhone] = useState<string>('');
  
  const handlePhoneUpdate = (data: any) => {
    setPhone(data.number);
  }

  return (
    <PhoneNumberInput 
      onInputChange={(data: {
        number: string,
        isValid: boolean
      }) => handlePhoneUpdate(data)}
      value={phone}
      placeholder='phone'
    />
  );

}

export default Demo;

Styling

The styling has been left bare for the most part to sync with the element styles of the project stylesheet it is being used in.

Here is the default stylesheet.

1.2.0

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.1.9

2 years ago

1.1.8

2 years ago

1.0.9

2 years ago

1.1.7

2 years ago

1.0.8

2 years ago

1.1.6

2 years ago

1.0.7

2 years ago

1.1.5

2 years ago

1.0.6

2 years ago

1.1.4

2 years ago

1.2.2

2 years ago

1.1.3

2 years ago

1.2.1

2 years ago

1.1.2

2 years ago

1.2.23

2 years ago

1.2.24

2 years ago

1.2.21

2 years ago

1.2.22

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.0

2 years ago

1.0.1

2 years ago