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

@2londres/phone-country-select

v1.0.3

Published

Searchable phone country code selector with per-country digit validation for React

Downloads

420

Readme

@2londres/phone-country-select

Searchable phone country code selector with per-country digit validation for React.

Phone Country Select demo

  • Searchable combobox (by country name, ISO code, or calling code)
  • Built-in phone number length validation per country (ITU-T E.164)
  • 200+ countries with flags, calling codes, and local names
  • Headless-friendly: BYO styles or use the included CSS
  • Tree-shakeable ESM + CJS builds
  • Zero i18n dependency — pass your own labels

Install

pnpm add @2londres/phone-country-select
# or
npm install @2londres/phone-country-select

Quick start

PhoneCountrySelect (standalone selector)

import { PhoneCountrySelect } from "@2londres/phone-country-select";
import "@2londres/phone-country-select/styles.css";
import { useState } from "react";

export function MyForm() {
  const [code, setCode] = useState("+229");

  return (
    <PhoneCountrySelect
      value={code}
      onValueChange={setCode}
      searchPlaceholder="Search country..."
      emptyText="No country found"
    />
  );
}

PhoneInput (selector + input with validation)

import {
  PhoneInput,
  validatePhoneNumber,
  buildFullPhoneNumber,
  findCountryByCallingCode,
} from "@2londres/phone-country-select";
import "@2londres/phone-country-select/styles.css";
import { useState } from "react";

export function MyPhoneField() {
  const [callingCode, setCallingCode] = useState("+33");
  const [phone, setPhone] = useState("");

  const country = findCountryByCallingCode(callingCode);
  const { valid, error } = validatePhoneNumber(phone, country?.code);

  const handleSubmit = () => {
    const fullNumber = buildFullPhoneNumber(callingCode, phone);
    console.log(fullNumber); // "+33612345678"
  };

  return (
    <div>
      <PhoneInput
        callingCode={callingCode}
        onCallingCodeChange={setCallingCode}
        phoneNumber={phone}
        onPhoneNumberChange={setPhone}
        error={
          !valid
            ? error === "too_short"
              ? "Too short"
              : "Too long"
            : undefined
        }
      />
      <button onClick={handleSubmit} disabled={!valid || !phone}>
        Save
      </button>
    </div>
  );
}

Utilities

| Function | Description | | -------------------------------------- | ----------------------------------------- | | getCountryList() | Returns filtered list of countries | | findCountryByCallingCode(code) | Find country by calling code | | findCountryByCode(iso) | Find country by ISO code | | parseFullPhoneNumber("+22912345678") | Parse into { callingCode, localNumber } | | buildFullPhoneNumber(code, local) | Combine calling code + local digits | | validatePhoneNumber(local, iso?) | Validate digit count for country | | getPhoneMaxDigits(iso?) | Get max local digits for country | | getPhoneMinDigits() | Get min digits (6) | | clampPhoneDigits(input, iso?) | Strip non-digits & clamp to max |

Styling

Import @2londres/phone-country-select/styles.css for default styles, or target the pcs-* CSS classes for custom styling.

Publishing

# 1. Bump version
pnpm version patch  # or minor / major

# 2. Build & publish
pnpm publish --access public --no-git-checks

npm will prompt for OTP if 2FA is enabled on your account.

License

MIT