{"id":19979118,"url":"https://github.com/mariohmol/ng-brazil","last_synced_at":"2025-05-16T11:07:05.454Z","repository":{"id":42020274,"uuid":"124755529","full_name":"mariohmol/ng-brazil","owner":"mariohmol","description":"Commons and utils  in angular for brazillian apps ( pipes / validators / directives / masks )","archived":false,"fork":false,"pushed_at":"2025-02-20T08:20:24.000Z","size":554,"stargazers_count":118,"open_issues_count":22,"forks_count":24,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-05-10T12:08:36.732Z","etag":null,"topics":["angular","angular7","brazil","cnpj","cpf","directives","inscricao-estadual","mask","pipe","rg","telefone","validators"],"latest_commit_sha":null,"homepage":"http://geradorbrasileiro.com","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mariohmol.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-03-11T12:45:48.000Z","updated_at":"2024-11-08T13:12:57.000Z","dependencies_parsed_at":"2023-10-11T12:52:14.951Z","dependency_job_id":"93330702-19fd-44da-a29a-31f49aeb2535","html_url":"https://github.com/mariohmol/ng-brazil","commit_stats":{"total_commits":124,"total_committers":7,"mean_commits":"17.714285714285715","dds":"0.16935483870967738","last_synced_commit":"f7e89839f292bf334751e406aaed1fb01f538300"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mariohmol%2Fng-brazil","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mariohmol%2Fng-brazil/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mariohmol%2Fng-brazil/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mariohmol%2Fng-brazil/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mariohmol","download_url":"https://codeload.github.com/mariohmol/ng-brazil/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254518380,"owners_count":22084374,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["angular","angular7","brazil","cnpj","cpf","directives","inscricao-estadual","mask","pipe","rg","telefone","validators"],"created_at":"2024-11-13T03:36:38.401Z","updated_at":"2025-05-16T11:07:00.436Z","avatar_url":"https://github.com/mariohmol.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ng-Brazil\n\n\nContains pipes / directives / validators / mask for brazillian like apps\n\n[![Build Status](https://travis-ci.org/mariohmol/ng-brazil.svg?branch=master)](https://travis-ci.org/mariohmol/ng-brazil)\n\nSupports: Angular2 to Angular14\n\n## Live example:  \n\n* https://stackblitz.com/edit/ng-brazil\n\nThis project was tested integrated with the following techs:\n\n* angular\n* angular-material\n* ionic3 (masks is not fully working, that is an issue for that, but pipes/directives/validators/mask works)\n\nModules:\n\n* CPF \n* CNPJ\n* RG\n* Inscrição Estadual\n* Telefone e Celular\n* CEP\n* Currency (Dinheiro)\n* Time (horas e minutos)\n* Number (numero e ponto decimal)\n* Placa de Carro\n* Renavam\n* Título de Eleitor\n* Proceso Jurídico\n\n\nSee the demo working project:\n\n\n![Demo Image](/src/assets/print.png)\n\n\n## Installation\n\nTo install this library with npm, run:\n\n` npm install --save ng-brazil js-brasil`\n\n\n\n \n## Usage\n\n### Configuration\n\nImport module in root\n\n```ts\nimport { NgBrazil } from 'ng-brazil' \n\n@NgModule({\n  declarations: [\n    AppComponent\n  ],\n  imports: [\n    ....,\n    NgBrazil\n  ],\n  providers: [],\n  bootstrap: [AppComponent]\n})\nexport class AppModule { }\n```\n\n\n#### Using Masks\n\nIf you would like to use masks install the module: \n\n`npm i -S angular2-text-mask text-mask-addons`\n\n\nAnd import to your main app:\n\n```ts\nimport { TextMaskModule } from 'angular2-text-mask';\n\nimports: [\n    ....,\n    TextMaskModule,\n    NgBrazil\n  ], \n```\n\n\nThen setup your component:\n\n```ts\nimport { Component } from '@angular/core';\nimport { MASKS, NgBrazilValidators } from 'ng-brazil';\n\n@Component({\n  selector: 'app-root',\n  template: '\u003cinput type=\"text\" [cpf]\u003e',\n  styleUrls: ['./app.component.css']\n})\nexport class AppComponent {\n  public MASKS = MASKS;\n  \n  constructor() { \n    this.formFields = {\n      estado: [''],\n      cpf: ['', [\u003cany\u003eValidators.required, \u003cany\u003eNgBrazilValidators.cpf]],\n      cnpj: ['', [\u003cany\u003eValidators.required, \u003cany\u003eNgBrazilValidators.cnpj]],\n      rg: ['', [\u003cany\u003eValidators.required, \u003cany\u003eNgBrazilValidators.rg]],\n      cep: ['', [\u003cany\u003eValidators.required, \u003cany\u003eNgBrazilValidators.cep]],\n      telefone: ['', [\u003cany\u003eValidators.required, \u003cany\u003eNgBrazilValidators.telefone]],\n      inscricaoestadual: ['', [\u003cany\u003eValidators.required, \u003cany\u003eNgBrazilValidators.inscricaoestadual(this.estado)]]\n    };\n    this.form = this.fb.group(this.formFields);\n  }\n\n}\n```\n\n## Forms and Mask\n\n```html\n\u003cinput type=\"text\" formControlName=\"cnpj\" cnpj [textMask]=\"{mask: MASKS.cnpj.textMask}\"\u003e\n\u003cinput type=\"text\" formControlName=\"cpf\" cpf [textMask]=\"{mask: MASKS.cpf.textMask}\"\u003e\n\u003cinput type=\"text\" formControlName=\"rg\" rg [textMask]=\"{mask: MASKS.rg.textMask}\"\u003e \n\u003cinput type=\"text\" formControlName=\"inscricaoestadual\" inscricaoestadual=\"mg\" [textMask]=\"{mask: MASKS.inscricaoestadual[estado].textMask}\"\u003e\n\u003cinput type=\"text\" formControlName=\"telefone\" telefone #telefone [textMask]=\"{mask: MASKS.telefone.textMaskFunction}\"\u003e\n\u003cinput type=\"text\" formControlName=\"cep\" cep [textMask]=\"{mask: MASKS.cep.textMask}\"\u003e\n\n\u003cinput type=\"text\" formControlName=\"number\" number [textMask]=\"{mask: MASKS.number.textMask}\"\u003e\n```\n## Pipes\n\n```html\nCPF: From 12345678910 to {{'12345678910' | cpf}} \u003cbr/\u003e\nCNPJ: From 40841253000102 to {{'40841253000102' | cnpj}} \u003cbr/\u003e\nRG: From MG10111222 to {{'MG10111222' | rg}} \u003cbr/\u003e\nInscrição Estadual: From 0018192630048 to {{'0018192630048' | inscricaoestadual: 'mg'}} \u003cbr/\u003e\nTelefone: From 3199998888 to {{'3199998888' | telefone}} \u003cbr/\u003e\nNumber: From 123.23 to {{'123.23' | numberBrazil}} \u003cbr/\u003e\nNumber sem decimais: From 123.23 to {{'123.23' | numberBrazil: 0}} \u003cbr/\u003e\nCurrency: From 123.23 to {{'123.23' | currencyBrazil}} \u003cbr/\u003e\n```\n\n```ts\nimport { Component } from '@angular/core';\nimport { NgBrDirectives } from 'ng-brazil';\n\n@Component({\n  selector: 'app-root',\n  template: '\u003cinput type=\"text\" [cpf]\u003e',\n  styleUrls: ['./app.component.css']\n})\nexport class AppComponent {\n  inscricaoestadual() {\n    const {InscricaoEstadualPipe} = NgBrDirectives;\n    return new InscricaoEstadualPipe()\n      .transform('625085487072', 'sp');\n  }\n}\n```\n# Demo\n\nDemo component files are included in Git Project.\n\nDemo Project:\n[https://github.com/mariohmol/ng-brazil/tree/master/src/app/demo)\n\nReference projects:\n\n* https://github.com/mariohmol/js-brasil\n* https://github.com/yuyang041060120/ng2-validation\n* https://github.com/text-mask/text-mask\n\n\n# TODO\n\nThere is some issues to work with, check it out\n\n## Collaborate\n\nFork this project then install global libs:\n\n*  npm i -g rimraf ng-packagr @angular/compiler-cli @angular/compiler tslib ngc\n\nFinally working in the project folder:\n\n* npm i\n* npm run build:lib\n* npm run dist\n* npm run start\n\nTo publish a new release, update the version in [package.json](./package.json) and [src/package.json](./src/package.json),\nthen run `npm run publish-npm`.\n\n# License\n\nMIT(./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmariohmol%2Fng-brazil","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmariohmol%2Fng-brazil","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmariohmol%2Fng-brazil/lists"}