mascara para inputs
npm install brmasker-ionic-3




return custom mask in input for ionic 3
``sh`
npm install brmasker-ionic-3 --save
`javascript
import { BrMaskerModule } from 'brmasker-ionic-3';
@NgModule({
imports: [
BrMaskerModule
],
})
`
`html`
`html`
`js
import { BrMaskerIonic3, BrMaskModel } from 'brmasker-ionic-3';
...
constructor(public brMaskerIonic3: BrMaskerIonic3) {}
...
protected createForm(): FormGroup {
return new FormGroup({
phone: new FormControl(this.createPhone())
});
}
private createPhone(): string {
const config: BrMaskModel = new BrMaskModel();
config.phone = true;
return this.brMaskerIonic3.writeCreateValue('99999999999', config);
}
`
* brmasker: BrMaskModel
`js,
BrMaskModel = {
mask: string;
len: number;
money: boolean;
decimal: number;
phone: boolean;
phoneNotDDD: boolean;
person: boolean;
percent:boolean;
type: 'alfa' | 'num' | 'all';
decimal: number = 2;
decimalCaracter: string = ;`
thousand: string;
userCaracters = false;
numberAndTousand = false;
}
| Name | type | info |
| ------ | ------ | ------ |
| mask | string | Optional |
| len | string | Optional |
| money | boolean | Optional |
| decimal| number | Optional for 'money', default '2' |
| phone | boolean | Optional |
| phoneNotDDD | boolean | Optional |
| person | boolean | Optional |
| percent | boolean | Optional |
| type | string | Optional default 'all' |
| decimalCaracter | string | Optional default ',' |
| decimal | number | Optional default '2' |
| thousand | string | Optional |
| userCaracters | boolean | Optional default false |false
| numberAndTousand | boolean | Optional default |
`html`
`html`
`html`
`html`
`html`
`html`
`html`
html
`
$3
`html
`$3
`html
`
$3
`html
`$3
`html
`$3
`html
`$3
`html
`$3
`html
`Characters
- . / ( ) , * + @ # $ & % :$3
`html
[brmasker]="{mask:'00/00/0000', len:10}"
`
$3
`html
[brmasker]="{mask:'00.000-000', len:10}"
`$3
`html
[brmasker]="{mask:'000.000.000-00', len:14}"
`$3
`html
[brmasker]="{mask:'00.000.000/0000-00', len:18}"
`$3
`html
[brmasker]="{mask:'(00) 0000-0000', len:14}"
`$3
`html
[brmasker]="{mask:'(00) 00000-0000', len:15}"
`Build for developer
$3
$3
`sh
npm run build
`$3
`sh
npm publish
`use in services
import module
BrMaskerModule and service import BrMaskerIonicServices3`js
import { BrMaskModel } from 'brmasker-ionic-3';...
@NgModule({
imports: [
BrMaskerModule
],
})
...
import { Injectable } from '@angular/core';
import { BrMaskerIonicServices3, BrMaskServicesModel } from 'brmasker-ionic-3';
@Injectable()
export class Util {
constructor(private brMasker: BrMaskerIonicServices3) { }
mascaraCPFCNPJ(valor: string) {
return this.brMasker.writeValuePerson(valor);
}
}
``
writeCreateValue(value: string, config: BrMaskServicesModel): stringwriteValuePercent(value: string): string
writeValuePerson(value: string): string
writeValueMoney(value: string, config: BrMaskServicesModel = new BrMaskServicesModel()): string
writeValueNumberAndThousand(value: string, config: BrMaskServicesModel = new BrMaskServicesModel()): string
writeValueusingSpecialCharacters(value: string, config: BrMaskServicesModel = new BrMaskServicesModel()): string
`
Changelog
$3
- add phoneNotDDD
$3
- fix numberAndTousand for number null
$3
- fix exports
$3
- fix publish
$3
- add services for mask
$3
- add thousand in number
$3
- fix tag
$3
- adding special character shape
$3
- Remove DevDependencies for fix bugs
$3
- New mask for money, add thousand
$3
- Refactored moneyMask so it includes a leading 0 for when we have only
$3
- Create a writeCreateValue for initial value
- Change name model from
BrModel to BrMaskModel$3
- Add decimal in money mask
$3
- Fix mask type caracter
$3
- Fix mask caracter
:`- Fix mask pool
- Replace percent symbol
- percent mask #pull #23
- fix(events): ionic has changed event names #pull #22
- Updating devdependencies
- fix number in phone and person
- fix compiler project for npm
- Suport reactive form