DeSource-Labs/phone-mask
Über uns
⚡ Ultra-lightweight international phone number formatter & validator with auto-sync to Google libphonenumber
Web- und App-EntwicklungWhat 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
Gemessener Sternzuwachs
- in 24h
- 0
- in 7 days
- +1
- in 15 days
- +1
- in 1 month
- Verlauf wird gesammelt
Nettoänderungen in überlappenden Zeiträumen, keine Tagessummen. Fehlende Messwerte bleiben leer. Sterne zeigen Interesse, nicht Qualität.
README.md
Original📱 Phone Mask
Always-fresh, extreme small & easy-to-use international phone masking with Google's libphonenumber data
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 | Core library — TypeScript/JS | |
| @desource/phone-mask-react | React component + hook | |
| @desource/phone-mask-vue | Vue 3 component + composable + directive | |
| @desource/phone-mask-svelte | Svelte 5 component + composable + action + attachment | |
| @desource/phone-mask-nuxt | Nuxt module | |
| @desource/phone-mask-angular | 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
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
- Fork the repository
- Clone your fork:
git clone https://github.com/YOUR_USERNAME/phone-mask.git - Install dependencies:
pnpm install - Create a branch:
git checkout -b feature/my-feature - Make your changes
- Commit:
git commit -m "feat: add awesome feature" - Push:
git push origin feature/my-feature - 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
Ähnliche Projekte entdecken
Wird geladen…