npm install ng-brazil
Contains pipes / directives / validators / mask for brazillian like apps

Supports: Angular2 to Angular9
* https://stackblitz.com/edit/ng-brazil
This project was tested integrated with the following techs:
* angular
* angular-material
* ionic3 (masks is not fully working, that is an issue for that, but pipes/directives/validators/mask works)
Modules:
* CPF
* CNPJ
* RG
* Inscrição Estadual
* Telefone e Celular
* CEP
* Currency (Dinheiro)
* Time (horas e minutos)
* Number (numero e ponto decimal)
* Placa de Carro
* Renavam
* Título de Eleitor
* Proceso Jurídico
See the demo working project:
To install this library with npm, run:
npm install --save ng-brazil js-brasil
Import module in root
``ts
import { NgBrazil } from 'ng-brazil'
@NgModule({
declarations: [
AppComponent
],
imports: [
....,
NgBrazil
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
`
#### Using Masks
If you would like to use masks install the module:
npm i -S angular2-text-mask text-mask-addons
And import to your main app:
`ts
import { TextMaskModule } from 'angular2-text-mask';
imports: [
....,
TextMaskModule,
NgBrazil
],
`
Then setup your component:
`ts
import { Component } from '@angular/core';
import { MASKS, NgBrazilValidators } from 'ng-brazil';
@Component({
selector: 'app-root',
template: '',
styleUrls: ['./app.component.css']
})
export class AppComponent {
public MASKS = MASKS;
constructor() {
this.formFields = {
estado: [''],
cpf: ['', [
cnpj: ['', [
rg: ['', [
cep: ['', [
telefone: ['', [
inscricaoestadual: ['', [
};
this.form = this.fb.group(this.formFields);
}
}
`
`html
`Pipes
`html`
CPF: From 12345678910 to {{'12345678910' | cpf}}
CNPJ: From 40841253000102 to {{'40841253000102' | cnpj}}
RG: From MG10111222 to {{'MG10111222' | rg}}
Inscrição Estadual: From 0018192630048 to {{'0018192630048' | inscricaoestadual: 'mg'}}
Telefone: From 3199998888 to {{'3199998888' | telefone}}
Number: From 123.23 to {{'123.23' | numberBrazil}}
Currency: From 123.23 to {{'123.23' | currencyBrazil}}
`ts
import { Component } from '@angular/core';
import { NgBrDirectives } from 'ng-brazil';
@Component({
selector: 'app-root',
template: '',
styleUrls: ['./app.component.css']
})
export class AppComponent {
inscricaoestadual() {
const {InscricaoEstadualPipe} = NgBrDirectives;
return new InscricaoEstadualPipe()
.transform('625085487072', 'sp');
}
}
``
Demo component files are included in Git Project.
Demo Project:
[https://github.com/mariohmol/ng-brazil/tree/master/src/app/demo)
Reference projects:
* https://github.com/mariohmol/js-brasil
* https://github.com/yuyang041060120/ng2-validation
* https://github.com/text-mask/text-mask
There is some issues to work with, check it out
Fork this project then install global libs:
* npm i -g rimraf ng-packagr @angular/compiler-cli @angular/compiler tslib ngc
Finally working in the project folder:
* npm i
* npm run build:lib
* npm run dist
* npm run start
MIT(./LICENSE)