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 🙏

© 2024 – Pkg Stats / Ryan Hefner

brasil-fields

v0.1.6

Published

O jeito mais fácil de utilizar padrões e formatos brasileiros em seu projeto.

Downloads

8

Readme

brasil-fields

Brasil Fields

Inspirado no brasil_fields

O jeito mais fácil de utilizar padrões e formatos brasileiros em seu projeto.

Instalação

npm

npm install brasil-fields

yarn

yarn add brasil-fields

Apresentação

Este package facilita o desenvolvimento de projetos que utilizam campos com os padrões e formatos brasileiros.

Como utilizar

Incluir o formatter no input.

React

import { cpfInputFormatter } from 'brasil-fields';

function App() {
  const [value, setValue] = useState('');

  return <input value={value} onchange={cpfInputFormatter(setValue)} />;
}

React Native

import { cpfInputFormatter } from 'brasil-fields';

function App() {
  const [value, setValue] = useState('');

  return <TextInput value={value} onChangeText={cpfInputFormatter(setValue)} />;
}

Formatters

| Padrão | Formatter | Formato | | :--------------- | :----------------------------- | :------------------------------------------ | | Altura | alturaInputFormatter() | 2,22 | | Cartão | cartaoBancarioInputFormatter() | 0000 1111 2222 3333 4444 | | CEP | cepInputFormatter() | 99.999-999 | | CPF | cpfInputFormatter() | 999.999.99-99 | | CNPJ | cnpjInputFormatter() | 99.999.999/9999-99 | | CPF / CNPJ | cpfOuCnpjInputFormatter() | se adapta conforme os números são inseridos | | CEST | cestInputFormatter() | 12.345.67 | | CNS | cnsInputFormatter() | 111 2222 3333 4444 | | Data | dataInputFormatter() | 01/01/1900 | | Hora | horaInputFormatter() | 23:59 | | KM | kmInputFormatter() | 999.999 | | Cert. nascimento | certNascimentoInputFormatter() | 000000 11 22 3333 4 55555 666 7777777 88 | | Peso | pesoInputFormatter() | 111,1 | | Placa | placaVeiculoInputFormatter() | AAA-1234 | | Real | realInputFormatter() | 20.550 | | Telefone | telefoneInputFormatter() | (99) 9999-9999 | | Validade cartão | validadeCartaoInputFormatter() | 12/24 ou 12/2024 | | Temperatura | temperaturaInputFormatter() | 27,1 |

Modelos

Estados.listaEstados
Estados.listaEstadosSigla
Meses.listaMeses
Regioes.listaRegioes
Semana.listaDiasUteis
Semana.listaDiasUteisAbrv

UtilBrasilFields

Métodos que facilitam manipular valores:

  • UtilBrasilFields.gerarCPF() (XXX.XXX.XXX-XX)
  • UtilBrasilFields.gerarCPF(false) (XXXXXXXXXXX)
  • UtilBrasilFields.gerarCNPJ() (XX.YYY.ZZZ/NNNN-SS)
  • UtilBrasilFields.gerarCNPJ(false) (XXYYYZZZNNNNSS)
  • UtilBrasilFields.obterCpf('11122233344') (111.222.333-44)
  • UtilBrasilFields.obterCnpj('11222333444455') (11.222.333/4444-55)
  • UtilBrasilFields.obterCep('11222333') (11.222-333)
  • UtilBrasilFields.obterCep('11222333', ponto: false) (11222-333)
  • UtilBrasilFields.obterTelefone('00999998877') ((00) 99999-8877)
  • UtilBrasilFields.obterTelefone('(00) 99999-8877', mascara: false) (00999998877)
  • UtilBrasilFields.obterTelefone('999998877', ddd: false) (99999-8877)
  • UtilBrasilFields.obterTelefone('99999-8877', ddd: false, mascara: false) (999998877)
  • UtilBrasilFields.obterReal (R$ 50.000,00 ou 50.000,00)
  • UtilBrasilFields.obterReal(85437107.04) (R$ 85.437.107,04)
  • UtilBrasilFields.obterReal(85437107.04, moeda: false) (85.437.107,04)
  • UtilBrasilFields.obterReal(85437107.04, moeda: false, decimal: 0) (85.437.107)
  • UtilBrasilFields.obterDDD('00999998877') (00)
  • UtilBrasilFields.removeCaracteres (remove caracteres especiais)
  • UtilBrasilFields.removerSimboloMoeda (remove o R$)
  • UtilBrasilFields.converterMoedaParaNumber (remove o R$ e retorna um number)
  • UtilBrasilFields.isCPFValido()
  • UtilBrasilFields.isCNPJValido()