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

vue-formatix

v0.1.2

Published

Biblioteca de máscaras e formatação para Vue 3, focada em dados brasileiros.

Readme

vue-formatix 🚀

A modern mask and data formatting library for Vue 3, focused on Brazilian standards.

Formatação elegante para Vue 3 com foco em dados brasileiros. Funções puras, API simples e DX impecável. ✨

npm version downloads license types

Destaques

  • Vue 3+ 🇧🇷
  • TypeScript completo 🛠️
  • Tree‑shakeable ✅
  • Funções puras (sem DOM) 🧩
  • Composable useMask e diretiva v-mask 🔧

Instalação 📦

  • npm install vue-formatix
  • yarn add vue-formatix
  • pnpm add vue-formatix

Requisitos ✅

  • vue ^3.3.0
  • Node >= 18

Uso básico 🧠

import maskData from "vue-formatix";
const mask = maskData();

mask.CPF("12345678901"); // "123.456.789-01"
mask.CNH("12345678900"); // "12345678900"
mask.Passport("AB123456"); // "AB123456"
mask.altura(1.75); // "1,75 m"
mask.cm(175); // "175 cm"
mask.mt(1.75); // "1,75 m"
mask.kg(80.5); // "80,5 kg"
mask.lb(180); // "180 lb"
mask.dataFormat01("2025-01-01"); // "01/01/2025"
mask.RUC("12345678901"); // "12345678901"
mask.phone("+55", "44999998888"); // "+55 (44) 99999-8888"
mask.brl(true, 10000); // "R$ 10.000,00"
mask.usd(true, 10000); // "$10,000.00"

Composable useMask 🧩

import { computed, ref } from "vue";
import { useMask } from "vue-formatix";

const cpf = ref("");
const mask = useMask();

const cpfFormatado = computed(() => mask.CPF(cpf.value));

Diretiva v-mask 🔧

<input v-mask.cpf v-model="cpf" />
<input v-mask.phone.br v-model="telefone" />
<input v-mask.date-ddmmyyyy v-model="data" />

Modificadores disponíveis:

  • v-mask.cpf
  • v-mask.phone.br
  • v-mask.date-ddmmyyyy

Plugin Vue 3 🧩

import { createApp } from "vue";
import App from "./App.vue";
import { VueFormatixPlugin } from "vue-formatix/vue";

createApp(App).use(VueFormatixPlugin).mount("#app");

Exports ✨

  • vue-formatix → default maskData() e exports nomeados (core)
  • vue-formatix/vue → exports para integração Vue (useMask, vMask, VueFormatixPlugin)
  • Subpaths:
    • vue-formatix/vue/useMask
    • vue-formatix/vue/directives/mask
    • vue-formatix/vue/plugin

Métodos 📚

| Método | Descrição | Exemplo de entrada | Exemplo de saída | | ------------------- | --------------------------- | ---------------------- | ----------------------- | | mask.CPF | Formata CPF | "12345678901" | "123.456.789-01" | | mask.CNH | Normaliza CNH (11 dígitos) | "12345678900" | "12345678900" | | mask.Passport | 2 letras + 6 dígitos | "AB123456" | "AB123456" | | mask.altura | Metros com vírgula | 1.75 | "1,75 m" | | mask.cm | Centímetros inteiros | 175 | "175 cm" | | mask.mt | Metros com vírgula | 1.75 | "1,75 m" | | mask.kg | Quilos (1 casa dec.) | 80.5 | "80,5 kg" | | mask.lb | Libras | 180 | "180 lb" | | mask.dataFormat01 | YYYY-MM-DDDD/MM/YYYY | "2025-01-01" | "01/01/2025" | | mask.RUC | Dígitos (8–14) | "12345678901" | "12345678901" | | mask.phone | Telefone BR | "+55", "44999998888" | "+55 (44) 99999-8888" | | mask.brl | Moeda BRL (pt-BR) | true, 10000 | "R$ 10.000,00" | | mask.usd | Moeda USD (en-US) | true, 10000 | "$10,000.00" |

Tratamento de erros ⚠️

  • CPF: TypeError se vazio; RangeError se tamanho ≠ 11
  • CNH: TypeError se vazio; RangeError se tamanho ≠ 11
  • Passport: TypeError se vazio; RangeError se formato inválido
  • altura/cm/mt/kg/lb: TypeError se nulo/undefined/NaN
  • dataFormat01: TypeError se vazio; RangeError se inválido
  • RUC: TypeError se vazio; RangeError se tamanho fora de 8–14
  • phone: TypeError se código/número vazio; RangeError se BR com tamanho inválido
  • brl/usd: TypeError se nulo/undefined/NaN

Scripts 🛠️

  • build: tsup
  • test: vitest
  • lint: eslint --ext .ts,.tsx src
  • prepare: npm run build

Testes 🧪

  • Rodar testes: npm test
  • Exemplos em tests/:
    • cpf.spec.ts
    • data.spec.ts
    • phone-br.spec.ts

Estrutura do projeto 📁

src/
  index.ts
  core/
    cpf.ts
    cnh.ts
    passport.ts
    altura.ts
    cm.ts
    mt.ts
    kg.ts
    lb.ts
    data.ts
    ruc.ts
    phone.ts
  vue/
    useMask.ts
    directives/
      mask.ts
    plugin.ts
    index.ts
tests/
  cpf.spec.ts
  data.spec.ts
  phone-br.spec.ts
package.json
tsconfig.json
tsup.config.ts
README.md

Roadmap 🧭

  • CNPJ
  • CEP
  • Placa veicular Mercosul
  • PIS/PASEP
  • RG/IE/IM por estado

Como contribuir 🤝

  • Faça fork
  • Crie uma branch
  • Abra um PR com descrição e exemplos

Licença 📄

MIT — veja o arquivo LICENSE (quando disponível).

English Version (soon) 🇺🇸