Skip to content
프로젝트

소개

⚡ Ultra-lightweight international phone number formatter & validator with auto-sync to Google libphonenumber

웹 및 앱 개발

이 수치를 측정하는 방법

What you can do

  • 🌍 240+ countries with accurate dialing codes and formats
  • 🎭 Auto-formatting as you type with smart cursor positioning
  • 🔍 Country search with fuzzy matching and keyboard navigation
  • 🌐 Auto-detection via GeoIP and browser locale

측정된 스타 증가

in 24h
0
in 7 days
+1
in 15 days
+1
in 1 month
기록 수집 중

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

📱 Phone Mask

Always-fresh, extreme small & easy-to-use international phone masking with Google's libphonenumber data

npm version npm downloads code coverage SonarCloud Ask CodeWiki Ask Context7 Ask DeepWiki license

Quick Start • Packages • Features • Demo • Contributing

Before upgrading to 2.0.0, review Migration from 1.7.0 for breaking changes and required updates.


🎯 Why Phone Mask?

🔄 Always Up-to-Date

Phone formats sync automatically from Google's libphonenumber — no stale data, no manual updates. Just upgrade and you're current with global dialing rules.

🪶 Lightest in Class

Phone Mask is the best choice for lightweight phone masking, with automatically updated Google libphonenumber masks and the smallest measured data-backed bundles. See the full comparison.

🎨 Framework-Ready

Ready-made plugins for your stack:

  • ✅ TypeScript/Vanilla JS — Framework-agnostic core
  • ✅ Angular 19–22 — Component, headless masking function, directive, and pipe with SSR and zoneless support
  • ✅ React — Component & hook with modern React patterns
  • ✅ Svelte — Component, composable, action, and attachment for Svelte 5
  • ✅ Vue 3 — Component, composable, and directive
  • ✅ Nuxt — Auto-imported, SSR-compatible

📦 Packages

Package Version Description
@desource/phone-mask npm Core library — TypeScript/JS
@desource/phone-mask-react npm React component + hook
@desource/phone-mask-vue npm Vue 3 component + composable + directive
@desource/phone-mask-svelte npm Svelte 5 component + composable + action + attachment
@desource/phone-mask-nuxt npm Nuxt module
@desource/phone-mask-angular npm Angular 19–22 component + headless API + directive + pipe

⚡ Quick Start

React

npm install @desource/phone-mask-react
import { useState } from 'react';
import { PhoneInput } from '@desource/phone-mask-react';
import '@desource/phone-mask-react/assets/lib.css';

function App() {
  const [phone, setPhone] = useState('');

  return <PhoneInput value={phone} onChange={setPhone} country="US" />;
}

Vue 3

npm install @desource/phone-mask-vue
<script setup>
import { ref } from 'vue';
import { PhoneInput } from '@desource/phone-mask-vue';
import '@desource/phone-mask-vue/assets/lib.css';

const phone = ref('');
</script>

<template>
  <PhoneInput v-model="phone" country="US" />
</template>

Svelte 5

npm install @desource/phone-mask-svelte
<script lang="ts">
  import { PhoneInput } from '@desource/phone-mask-svelte';
  import '@desource/phone-mask-svelte/assets/lib.css';

  let phone = $state('');
</script>

<PhoneInput bind:value={phone} country="US" />

Angular 19–22

npm install @desource/phone-mask-angular
import { ChangeDetectionStrategy, Component, signal } from '@angular/core';
import { PhoneInputComponent } from '@desource/phone-mask-angular';

@Component({
  selector: 'app-profile',
  imports: [PhoneInputComponent],
  changeDetection: ChangeDetectionStrategy.OnPush,
  template: `<phone-input country="US" [(value)]="phone" />`
})
export class Profile {
  readonly phone = signal('');
}

Import @desource/phone-mask-angular/assets/lib.css in your global stylesheet.

Nuxt

npm install @desource/phone-mask-nuxt
// nuxt.config.ts
export default defineNuxtConfig({
  modules: ['@desource/phone-mask-nuxt']
});
<script setup>
import { ref } from 'vue';

const phone = ref('');
</script>

<template>
  <PhoneInput v-model="phone" country="US" />
</template>

TypeScript/Vanilla JS

npm install @desource/phone-mask
import { MasksFullMapEn } from '@desource/phone-mask';
import { formatDigitsWithMap } from '@desource/phone-mask/kit';

const mask = MasksFullMapEn.US.mask[0]; // "###-###-####"
const formatted = formatDigitsWithMap(mask, '2025551234').display;
// Result: "202-555-1234"

✨ Features

  • 🌍 240+ countries with accurate dialing codes and formats
  • 🎭 Auto-formatting as you type with smart cursor positioning
  • 🔍 Country search with fuzzy matching and keyboard navigation
  • 🌐 Auto-detection via GeoIP and browser locale
  • 📋 Copy to clipboard with one click
  • ✨ Validation with visual feedback
  • 🎨 Themeable (light/dark) with custom styling
  • ♿ Accessible with ARIA labels and keyboard support
  • 🌐 SSR Support - works seamlessly with server-side rendering
  • 📱 Mobile-optimized with proper input modes
  • 🌳 Tree-shakeable — only import what you use
  • 🔧 TypeScript — full type safety
  • 🧩 Additional tools for custom input styling (directives, formatters, headless API, etc.)

🎮 Demo

Live Demo →

Try the interactive playground with:

  • Real-time formatting preview
  • Country switching
  • Theme toggle
  • Code examples

📚 Documentation


🤝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

Quick Contribution Flow

  1. Fork the repository
  2. Clone your fork: git clone https://github.com/YOUR_USERNAME/phone-mask.git
  3. Install dependencies: pnpm install
  4. Create a branch: git checkout -b feature/my-feature
  5. Make your changes
  6. Commit: git commit -m "feat: add awesome feature"
  7. Push: git push origin feature/my-feature
  8. Open a Pull Request

For package changes intended for release, add a changeset in your PR: pnpm changeset

Development

# Install dependencies
pnpm install

# Build all packages
pnpm build

# Run unit tests with coverage report
pnpm test:unit:coverage

# Start demo dev server
pnpm dev:prepare
pnpm dev:demo

# Generate fresh data from Google's library
pnpm gen

# Refresh the competitor comparison
pnpm comparison:update

# Lint & format code (if you made changes)
pnpm lint
pnpm lint:fix
pnpm format

🌟 Sponsors

Developed and maintained by DeSource Labs.

Created by Stefan Popov


📄 License

MIT © 2026 DeSource Labs


🔗 Links


Built with ❤️ by the DeSource Labs team

관련 프로젝트 살펴보기

불러오는 중…