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 🙏

© 2025 – Pkg Stats / Ryan Hefner

country-phone-mask

v1.6.0

Published

Phone input with country selector and number masking (now using ipinfo.io for geo detection)

Readme

📞 country-phone-mask

Универсальный JavaScript-плагин для ввода телефонных номеров с поддержкой масок и выбора страны.
Поддерживает флаги через SVG-спрайт, смену маски при выборе страны, защиту префикса и умную работу с курсором.

Демо

👉 Открыть пример в CodeSandbox

Установка

NPM

npm install country-phone-mask

или

yarn add country-phone-mask

CDN (если не используете сборщик)

<link rel="stylesheet" href="https://unpkg.com/country-phone-mask/dist/style.css" />
<script type="module">
    import createPhoneInput, { countries } from 'https://unpkg.com/country-phone-mask/dist/index.esm.js';

    const container = document.querySelectorAll(".phone-input");

    container.forEach((item) => {
        createPhoneInput({
            container: item,
            countries: countries,
            spritePath: "public/sprite.svg", // можно переопределить путь
            apiKey: "", //https://ipinfo.io/
        });
    });
</script>

Быстрый старт

import createPhoneInput, { countries } from 'country-phone-mask';

const container = document.querySelectorAll(".phone-input");

container.forEach((item) => {
    createPhoneInput({
        container: item,
        countries: countries,
        spritePath: "public/sprite.svg", // можно переопределить путь
        apiKey: "", //https://ipinfo.io/
    });
});

Вы можете легко заменить на свои страны, просто замените массив countries.

import createPhoneInput, {
  countries as defaultCountries,
} from "country-phone-mask";

const container = document.querySelectorAll(".phone-input");

const myCountries = [
  {
    name: "None Country",
    code: "NA",
    dialCode: "",
    mask: "",
  },
  {
    name: "Russia",
    code: "RU",
    dialCode: "+7",
    mask: "+7 (___) ___-__-__",
  },
    {name: "other"}
 ]
container.forEach((item) => {
    createPhoneInput({
        container: item,
        countries: myCountries,
        spritePath: "public/sprite.svg", // переопределить путь
        apiKey: "", //https://ipinfo.io/
    });
});

Структура объекта Country

interface Country {
  name: string;      // Название страны
  code: string;      // Код страны (например, 'ru', 'kz')
  dialCode: string;  // Телефонный код (например, '+7')
  mask: string;      // Маска для ввода (например, '+7 (___) ___-__-__')
}

Особенности

  • 📱 Поддержка масок ввода по стране
  • 🚩 Отображение флагов через SVG-спрайт
  • 🔒 Защита префикса
  • 🧠 Умное позиционирование курсора
  • ✍️ Поддержка удаления и вставки номеров
  • Добавление уникального id
  • Добавление подсказки при фокусировке
  • Добавление уже вставленого номера

💖 Поддержать автора

Если вам понравился этот плагин и вы хотите поддержать его развитие:

  • 💳 Карта РФ: 5536 9139 9548 1773
  • ₿ Bitcoin: 18Ny4EDjZM2Y3xq6YoY9xmmjW8q3w9m6Eh
  • Tether USD: TUMKgoGgtAPgrd7ra82RyeqyAipD1Aj16w

Спасибо за вашу поддержку!