npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

contactnumberreact

v1.0.1

Published

A reusable React phone input component.

Readme

PhoneInputComponent 📱

A customizable and responsive React phone input component with country code dropdown, formatting, and validation support.


📦 Installation

npm install your-phone-input-package-name

🚀 Usage

import PhoneInputComponent from 'your-phone-input-package-name';

<PhoneInputComponent
  phoneValues={{ number: '', editNumber: '', editCountryCode: '' }}
  handlePhoneChange={(data) => console.log(data)}
  defaultCountryCode="91"
  PreferredCountryCodes={["91", "1"]}
  setError={(msg) => console.error(msg)}
  error={error}
  CombinedToSeperate={false}
  containerCss="myContainer"
  selectedFlagCss="myFlag"
  selectedCountryCss="mySelectedCountry"
  dropdownCss="myDropdown"
  searchInputCss="mySearchInput"
  ulCss="myUl"
  PreferredliCss="myPreferredLi"
  filteredliCss="myFilteredLi"
  liCss="myLi"
  inputCss="myInput"
  validationObject={true}
  requiredError="Phone number required."
  setTempErrorOut={(tempErr) => console.warn(tempErr)}
  onFocus={() => console.log('Focused')}
  onClickOutside={() => console.log('Clicked outside')}
  inputTriggers={{ autoFocus: true }}
  addedData={[{ name: "Atlantis", code: "at", dialingCode: "999", phoneNumberFormat: "0##########" }]}
/>

🧩 Props

| Prop | Type | Description | | ----------------------- | ----------- | ---------------------------------------------------------------------------------------- | | phoneValues | object | Current phone number data: { number, editNumber, editCountryCode }. | | handlePhoneChange | function | Callback triggered when phone data changes. | | PreferredCountryCodes | string[] | Country codes to show at top of dropdown. | | defaultCountryCode | string | Default country dialing code (e.g., "91"). | | setError | function | Callback to set error messages. | | error | string | Error message to display (used for styling). | | CombinedToSeperate | boolean | When true, separates country code and number in state handling. | | dropdownArrow | ReactNode | Custom SVG or element for dropdown arrow. | | containerCss | string | Class name for outer container. | | selectedFlagCss | string | Class name for selected flag container. | | selectedCountryCss | string | Class name for selected country list item. | | dropdownCss | string | Class name for dropdown wrapper. | | searchInputCss | string | Class name for search input field. | | ulCss | string | Class name for <ul> country list. | | PreferredliCss | string | Class name for preferred countries <li>. | | filteredliCss | string | Class name for filtered countries <li>. | | liCss | string | Default class for country <li> entries. | | inputCss | string | Class name for the phone <input> field. | | validationObject | boolean | If true, validation errors use setTempError, else setError. | | requiredError | string | Message shown if input is empty. | | setTempErrorOut | function | Callback to expose temporary error state. | | onFocus | function | Called when the input is focused. | | onClickOutside | function | Triggered when user clicks outside the input. | | inputTriggers | object | Additional input props (e.g., autoFocus, placeholder). | | addedData | Array | Additional country objects to include: { name, code, dialingCode, phoneNumberFormat }. |


🧪 Features

  • Live formatting based on country-specific patterns
  • Supports dynamic validation
  • Add your own countries
  • Fully stylable via className props
  • Preferred country ordering
  • Controlled via phoneValues

🎨 Styling

The component includes internal styles, but can be overridden with your own class names passed to the CSS-related props.

Flag icons must be included using a CSS sprite (typically via .flag and .flag.<country-code>), or imported from your preferred source.


📄 License

MIT


👤 Author

Made with ❤️ by Om Javheri