UNPKG

ngx-br

Version:
1,538 lines (1,490 loc) 38.8 kB
import { Pipe, NgModule, Input, Component, EventEmitter, forwardRef, Output, Directive, ElementRef, HostListener } from '@angular/core'; import { NG_VALUE_ACCESSOR, FormsModule } from '@angular/forms'; import { CommonModule } from '@angular/common'; import { NgxCurrencyModule } from 'ngx-currency'; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ const telefoneFixoPattern = '(99) 9999-9999'; const telefoneCelularPattern = '(99) 99999-9999'; const horaPattern = '99:99'; const cpfPattern = '999.999.999-99'; const cnpjPattern = '99.999.999/9999-99'; const cepPattern = '99999-999'; const cepPlaceholder = '00000-000'; const cnpjPlaceholder = '00.000.000/0000-00'; const cpfPlaceholder = '000.000.000-00'; const pesoPlaceholder = '0,00 kg'; const dinheiroPlaceholder = 'R$ 0,00'; const percentualPlaceholder = '0%'; const horaPlaceholder = 'HH:MM'; const dinheiroPatternConfig = { precision: 2, separator: ',', delimiter: '.', unit: 'R$', zeroCents: false, }; const percentualPatternConfig = { precision: 1, separator: ',', delimiter: ',', suffixUnit: '%', zeroCents: false, }; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ const vanillaMasker = require('vanilla-masker'); class CpfPipe { /** * @param {?} value * @return {?} */ transform(value) { if (!value) { return ''; } return vanillaMasker.toPattern(value, cpfPattern); } } CpfPipe.decorators = [ { type: Pipe, args: [{ name: 'cpf', },] }, ]; /** @nocollapse */ CpfPipe.ctorParameters = () => []; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ const vanillaMasker$1 = require('vanilla-masker'); class CnpjPipe { /** * @param {?} value * @return {?} */ transform(value) { if (!value) { return ''; } return vanillaMasker$1.toPattern(value, cnpjPattern); } } CnpjPipe.decorators = [ { type: Pipe, args: [{ name: 'cnpj', },] }, ]; /** @nocollapse */ CnpjPipe.ctorParameters = () => []; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ const vanillaMasker$2 = require('vanilla-masker'); const CPF_LENGTH = 11; class CpfCnpjPipe { /** * @param {?} value * @return {?} */ transform(value) { if (!value) { return ''; } if (value.length > CPF_LENGTH) { return vanillaMasker$2.toPattern(value, cnpjPattern); } return vanillaMasker$2.toPattern(value, cpfPattern); } } CpfCnpjPipe.decorators = [ { type: Pipe, args: [{ name: 'cpfOuCnpj', },] }, ]; /** @nocollapse */ CpfCnpjPipe.ctorParameters = () => []; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ const vanillaMasker$3 = require('vanilla-masker'); class TelefonePipe { /** * @param {?} value * @return {?} */ transform(value) { if (!value) { return ''; } const /** @type {?} */ telefonePattern = value.toString().length === 11 ? telefoneCelularPattern : telefoneFixoPattern; return vanillaMasker$3.toPattern(value, telefonePattern); } } TelefonePipe.decorators = [ { type: Pipe, args: [{ name: 'telefone', },] }, ]; /** @nocollapse */ TelefonePipe.ctorParameters = () => []; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ class NgxBrPipesModule { } NgxBrPipesModule.decorators = [ { type: NgModule, args: [{ imports: [], declarations: [ CpfPipe, CnpjPipe, CpfCnpjPipe, TelefonePipe ], exports: [ CpfPipe, CnpjPipe, CpfCnpjPipe, TelefonePipe ], providers: [ CpfPipe, CnpjPipe, CpfCnpjPipe, TelefonePipe ] },] }, ]; /** @nocollapse */ NgxBrPipesModule.ctorParameters = () => []; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ const vanillaMasker$4 = require('vanilla-masker'); /** * @abstract */ class ValueAccessorBase { constructor() { this.disabled = false; this.onChange = () => { }; this.onTouched = () => { }; } /** * @return {?} */ get value() { return this.innerValue; } /** * @param {?} value * @return {?} */ set value(value) { this.innerValue = value; this.onChange(value); this.onTouched(); } /** * @param {?} value * @return {?} */ writeValue(value) { if (!this.pattern) { this.innerValue = value; } else { this.innerValue = this.applyPattern(value); } } /** * @param {?} value * @return {?} */ applyPattern(value) { if (!value) { return ''; } if (typeof this.pattern === 'string') { return vanillaMasker$4.toPattern(value, this.pattern); } if (typeof this.pattern === 'function') { return vanillaMasker$4.toPattern(value, this.pattern(value)); } return vanillaMasker$4.toMoney(value, this.pattern); } /** * @param {?} fn * @return {?} */ registerOnChange(fn) { this.onChange = fn; } /** * @param {?} fn * @return {?} */ registerOnTouched(fn) { this.onTouched = fn; } /** * @param {?} isDisabled * @return {?} */ setDisabledState(isDisabled) { this.disabled = isDisabled; } /** * @return {?} */ touch() { this.onTouched.forEach(f => f()); } /** * @param {?} value * @return {?} */ notifyChanges(value) { value = this.transform(value); this.onChange(value); this.onTouched(); } } ValueAccessorBase.propDecorators = { "disabled": [{ type: Input },], }; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ const CPF_PROVIDER = { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => CpfComponent), multi: true, }; class CpfComponent extends ValueAccessorBase { constructor() { super(...arguments); this.pattern = cpfPattern; this.placeholder = cpfPlaceholder; this.blur = new EventEmitter(); } /** * @param {?} value * @return {?} */ transform(value) { return value ? value.replace(/[^\d]/g, '').trim().slice(0, 11) : value; } /** * @param {?} event * @return {?} */ blurEvt(event) { this.blur.emit(event); } } CpfComponent.decorators = [ { type: Component, args: [{ selector: 'cpf', template: `<input cpfMask type="text" class="form-control" maxlength="14" [id]="id" [placeholder]="placeholder" [disabled]="disabled" [(ngModel)]="value" (ngModelChange)="notifyChanges($event)" (blur)="blurEvt($event)"> `, styles: [``], providers: [CPF_PROVIDER], },] }, ]; /** @nocollapse */ CpfComponent.ctorParameters = () => []; CpfComponent.propDecorators = { "placeholder": [{ type: Input },], "id": [{ type: Input },], "blur": [{ type: Output },], }; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ const vanillaMasker$5 = require('vanilla-masker'); class CpfMaskDirective { /** * @param {?} element */ constructor(element) { this.element = element; this.nativeElement = this.element.nativeElement; vanillaMasker$5(this.nativeElement).maskPattern(cpfPattern); } } CpfMaskDirective.decorators = [ { type: Directive, args: [{ selector: '[cpfMask]', },] }, ]; /** @nocollapse */ CpfMaskDirective.ctorParameters = () => [ { type: ElementRef, }, ]; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ class CpfComponentContainer { constructor() { this.requiredMsg = 'Este campo é obrigatório'; this.cpfMsg = 'CPF Inválido'; } /** * @return {?} */ shouldShowErrors() { return this.control && !this.control.valid && !this.control.pristine && this.control.touched && !!this.control.errors; } } CpfComponentContainer.decorators = [ { type: Component, args: [{ selector: 'cpf-container', template: ` <ng-content></ng-content> <span *ngIf="shouldShowErrors()" style="color: #f05050"> <span *ngIf="control.hasError('required')">{{requiredMsg}}</span> <span *ngIf="!control.hasError('required') && control.hasError('cpf')">{{cpfMsg}}</span> </span> `, },] }, ]; /** @nocollapse */ CpfComponentContainer.ctorParameters = () => []; CpfComponentContainer.propDecorators = { "control": [{ type: Input },], "requiredMsg": [{ type: Input },], "cpfMsg": [{ type: Input },], }; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ class CpfModule { } CpfModule.decorators = [ { type: NgModule, args: [{ imports: [ CommonModule, FormsModule ], declarations: [ CpfComponent, CpfMaskDirective, CpfComponentContainer ], exports: [ CpfComponent, CpfMaskDirective, CpfComponentContainer ] },] }, ]; /** @nocollapse */ CpfModule.ctorParameters = () => []; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ const CNPJ_PROVIDER = { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => CnpjComponent), multi: true, }; class CnpjComponent extends ValueAccessorBase { constructor() { super(...arguments); this.pattern = cnpjPattern; this.placeholder = cnpjPlaceholder; this.blur = new EventEmitter(); } /** * @param {?} value * @return {?} */ transform(value) { return value ? value.replace(/[^\d]/g, '').trim().slice(0, 14) : value; } /** * @param {?} event * @return {?} */ blurEvt(event) { this.blur.emit(event); } } CnpjComponent.decorators = [ { type: Component, args: [{ selector: 'cnpj', template: `<input cnpjMask class="form-control" type="text" maxlength="18" [id]="id" [placeholder]="placeholder" [disabled]="disabled" [(ngModel)]="value" (ngModelChange)="notifyChanges($event)" (blur)="blurEvt($event)"> `, styles: [``], providers: [CNPJ_PROVIDER] },] }, ]; /** @nocollapse */ CnpjComponent.ctorParameters = () => []; CnpjComponent.propDecorators = { "placeholder": [{ type: Input },], "id": [{ type: Input },], "blur": [{ type: Output },], }; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ const vanillaMasker$6 = require('vanilla-masker'); class CnpjMaskDirective { /** * @param {?} element */ constructor(element) { this.element = element; this.nativeElement = this.element.nativeElement; vanillaMasker$6(this.nativeElement).maskPattern(cnpjPattern); } } CnpjMaskDirective.decorators = [ { type: Directive, args: [{ selector: '[cnpjMask]', },] }, ]; /** @nocollapse */ CnpjMaskDirective.ctorParameters = () => [ { type: ElementRef, }, ]; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ class CnpjComponentContainer { constructor() { this.requiredMsg = 'Este campo é obrigatório'; this.cnpjMsg = 'CNPJ Inválido'; } /** * @return {?} */ shouldShowErrors() { return this.control && !this.control.valid && !this.control.pristine && this.control.touched && !!this.control.errors; } } CnpjComponentContainer.decorators = [ { type: Component, args: [{ selector: 'cnpj-container', template: ` <ng-content></ng-content> <span *ngIf="shouldShowErrors()" style="color: #f05050"> <span *ngIf="control.hasError('required')">{{requiredMsg}}</span> <span *ngIf="!control.hasError('required') && control.hasError('cnpj')">{{cnpjMsg}}</span> </span> `, },] }, ]; /** @nocollapse */ CnpjComponentContainer.ctorParameters = () => []; CnpjComponentContainer.propDecorators = { "control": [{ type: Input },], "requiredMsg": [{ type: Input },], "cnpjMsg": [{ type: Input },], }; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ class CnpjModule { } CnpjModule.decorators = [ { type: NgModule, args: [{ imports: [ CommonModule, FormsModule ], declarations: [ CnpjComponent, CnpjMaskDirective, CnpjComponentContainer ], exports: [ CnpjComponent, CnpjMaskDirective, CnpjComponentContainer ] },] }, ]; /** @nocollapse */ CnpjModule.ctorParameters = () => []; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ const DINHEIRO_PROVIDER = { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => DinheiroComponent), multi: true, }; class DinheiroComponent extends ValueAccessorBase { /** * @param {?} elementRef */ constructor(elementRef) { super(); this.elementRef = elementRef; this.placeholder = dinheiroPlaceholder; this.maxLength = 15; this.blur = new EventEmitter(); } /** * @param {?} event * @return {?} */ blurEvt(event) { this.blur.emit(event); } /** * @param {?} value * @return {?} */ transform(value) { return value; } /** * @param {?} event * @return {?} */ onKeydown(event) { if (event.ctrlKey && event.keyCode === 65) { console.log(this.elementRef); } } } DinheiroComponent.decorators = [ { type: Component, args: [{ selector: 'dinheiro', template: `<input currencyMask class="form-control" maxlength="{{maxLength}}" [id]="id" [disabled]="disabled" [placeholder]="placeholder" [ngStyle]="style" [options]="{ prefix: 'R$ ', thousands: '.', decimal: ',', allowNegative: false }" [(ngModel)]="value" (keydown)="onKeydown($event)" (ngModelChange)="notifyChanges($event)" (blur)="blurEvt($event)"> `, styles: [``], providers: [DINHEIRO_PROVIDER] },] }, ]; /** @nocollapse */ DinheiroComponent.ctorParameters = () => [ { type: ElementRef, }, ]; DinheiroComponent.propDecorators = { "style": [{ type: Input },], "placeholder": [{ type: Input },], "id": [{ type: Input },], "maxLength": [{ type: Input },], "blur": [{ type: Output },], }; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ const vanillaMasker$7 = require('vanilla-masker'); class DinheiroMaskDirective { /** * @param {?} element */ constructor(element) { this.element = element; this.nativeElement = this.element.nativeElement; vanillaMasker$7(this.nativeElement).maskMoney(dinheiroPatternConfig); } } DinheiroMaskDirective.decorators = [ { type: Directive, args: [{ selector: '[dinheiroMask]', },] }, ]; /** @nocollapse */ DinheiroMaskDirective.ctorParameters = () => [ { type: ElementRef, }, ]; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ class DinheiroModule { } DinheiroModule.decorators = [ { type: NgModule, args: [{ imports: [ CommonModule, FormsModule, NgxCurrencyModule ], declarations: [ DinheiroComponent, DinheiroMaskDirective, ], exports: [ DinheiroComponent, DinheiroMaskDirective ] },] }, ]; /** @nocollapse */ DinheiroModule.ctorParameters = () => []; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ class Estado { /** * @param {?} sigla * @param {?} descricao */ constructor(sigla, descricao) { this.sigla = sigla; this.descricao = descricao; } } /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ const ESTADOS_PROVIDER = { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => EstadosComponent), multi: true, }; class EstadosComponent extends ValueAccessorBase { constructor() { super(...arguments); this.placeholder = 'Selecione'; this.estados = [ new Estado('AC', 'Acre'), new Estado('AL', 'Alagoas'), new Estado('AP', 'Amapá'), new Estado('AM', 'Amazonas'), new Estado('BA', 'Bahia'), new Estado('CE', 'Ceará'), new Estado('DF', 'Distrito Federal'), new Estado('ES', 'Espírito Santo'), new Estado('GO', 'Goiás'), new Estado('MA', 'Maranhão'), new Estado('MT', 'Mato Grosso'), new Estado('MS', 'Mato Grosso do Sul'), new Estado('MG', 'Minas Gerais'), new Estado('PA', 'Pará'), new Estado('PB', 'Paraíba'), new Estado('PR', 'Paraná'), new Estado('PE', 'Pernambuco'), new Estado('PI', 'Piauí'), new Estado('RJ', 'Rio de Janeiro'), new Estado('RN', 'Rio Grande do Norte'), new Estado('RS', 'Rio Grande do Sul'), new Estado('RO', 'Rondônia'), new Estado('RR', 'Roraima'), new Estado('SC', 'Santa Catarina'), new Estado('SP', 'São Paulo'), new Estado('SE', 'Sergipe'), new Estado('TO', 'Tocantins'), ]; } /** * @param {?} T * @return {?} */ transform(T) { return undefined; } } EstadosComponent.decorators = [ { type: Component, args: [{ selector: 'estados', template: `<select class="form-control" [(ngModel)]="value" [id]="id" [disabled]="disabled"> <option value="null" disabled selected>{{placeholder}}</option> <option *ngFor="let estado of estados" [ngValue]="estado.sigla">{{estado.descricao}}</option> </select> `, styles: [``], providers: [ESTADOS_PROVIDER] },] }, ]; /** @nocollapse */ EstadosComponent.ctorParameters = () => []; EstadosComponent.propDecorators = { "placeholder": [{ type: Input },], "id": [{ type: Input },], }; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ class EstadosModule { } EstadosModule.decorators = [ { type: NgModule, args: [{ imports: [ CommonModule, FormsModule ], declarations: [ EstadosComponent ], exports: [ EstadosComponent ] },] }, ]; /** @nocollapse */ EstadosModule.ctorParameters = () => []; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ const vanillaMasker$8 = require('vanilla-masker'); const HORA_PROVIDER = { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => HoraComponent), multi: true, }; class HoraComponent extends ValueAccessorBase { constructor() { super(...arguments); this.pattern = horaPattern; this.placeholder = horaPlaceholder; this.blur = new EventEmitter(); } /** * @param {?} event * @return {?} */ blurEvt(event) { let /** @type {?} */ value = event.target.value; if (value) { value = value.replace(/[^\d]/g, '').padEnd(4, '0'); this.value = vanillaMasker$8.toPattern(value, '99:99'); } this.blur.emit(event); } /** * @param {?} value * @return {?} */ transform(value) { return value ? value.replace(/[^\d]/g, '').trim().slice(0, 5) : value; } } HoraComponent.decorators = [ { type: Component, args: [{ selector: 'hora', template: `<input horaMask class="form-control text-right" maxlength="5" [id]="id" [disabled]="disabled" [placeholder]="placeholder" [(ngModel)]="value" (ngModelChange)="notifyChanges($event)" (blur)="blurEvt($event)"> `, styles: [``], providers: [HORA_PROVIDER] },] }, ]; /** @nocollapse */ HoraComponent.ctorParameters = () => []; HoraComponent.propDecorators = { "id": [{ type: Input },], "placeholder": [{ type: Input },], "blur": [{ type: Output },], }; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ const vanillaMasker$9 = require('vanilla-masker'); class HoraMaskDirective { /** * @param {?} element */ constructor(element) { this.element = element; this.nativeElement = this.element.nativeElement; vanillaMasker$9(this.nativeElement).maskPattern(horaPattern); } } HoraMaskDirective.decorators = [ { type: Directive, args: [{ selector: '[horaMask]', },] }, ]; /** @nocollapse */ HoraMaskDirective.ctorParameters = () => [ { type: ElementRef, }, ]; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ class HoraModule { } HoraModule.decorators = [ { type: NgModule, args: [{ imports: [ CommonModule, FormsModule ], declarations: [ HoraComponent, HoraMaskDirective ], exports: [ HoraComponent, HoraMaskDirective ] },] }, ]; /** @nocollapse */ HoraModule.ctorParameters = () => []; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ const PERCENTUAL_PROVIDER = { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => PercentualComponent), multi: true, }; class PercentualComponent extends ValueAccessorBase { constructor() { super(...arguments); this.maxLength = 10; this.placeholder = percentualPlaceholder; this.blur = new EventEmitter(); } /** * @param {?} event * @return {?} */ blurEvt(event) { this.blur.emit(event); } /** * @param {?} value * @return {?} */ transform(value) { return value; } } PercentualComponent.decorators = [ { type: Component, args: [{ selector: 'percentual', template: `<input currencyMask class="form-control" maxlength="{{maxLength}}" [id]="id" [disabled]="disabled" [placeholder]="placeholder" [ngStyle]="style" [options]="{ suffix: ' %', prefix: '', thousands: '.', decimal: ',', allowNegative: true }" [(ngModel)]="value" (ngModelChange)="notifyChanges($event)" (blur)="blurEvt($event)"> `, styles: [``], providers: [PERCENTUAL_PROVIDER] },] }, ]; /** @nocollapse */ PercentualComponent.ctorParameters = () => []; PercentualComponent.propDecorators = { "style": [{ type: Input },], "maxLength": [{ type: Input },], "placeholder": [{ type: Input },], "id": [{ type: Input },], "blur": [{ type: Output },], }; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ const vanillaMasker$10 = require('vanilla-masker'); class PercentualMaskDirective { /** * @param {?} element */ constructor(element) { this.element = element; this.nativeElement = this.element.nativeElement; vanillaMasker$10(this.nativeElement).maskMoney(percentualPatternConfig); } } PercentualMaskDirective.decorators = [ { type: Directive, args: [{ selector: '[percentualMask]', },] }, ]; /** @nocollapse */ PercentualMaskDirective.ctorParameters = () => [ { type: ElementRef, }, ]; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ class PercentualModule { } PercentualModule.decorators = [ { type: NgModule, args: [{ imports: [ CommonModule, FormsModule, NgxCurrencyModule ], declarations: [ PercentualComponent, PercentualMaskDirective ], exports: [ PercentualComponent, PercentualMaskDirective ] },] }, ]; /** @nocollapse */ PercentualModule.ctorParameters = () => []; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ const PESO_PROVIDER = { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => PesoComponent), multi: true, }; class PesoComponent extends ValueAccessorBase { constructor() { super(...arguments); this.maxLength = 10; this.placeholder = pesoPlaceholder; this.blur = new EventEmitter(); } /** * @param {?} event * @return {?} */ blurEvt(event) { this.blur.emit(event); } /** * @param {?} value * @return {?} */ transform(value) { return value; } } PesoComponent.decorators = [ { type: Component, args: [{ selector: 'peso', template: `<input currencyMask class="form-control" placeholder="{{placeholder}}" maxlength="{{maxLength}}" [id]="id" [disabled]="disabled" [placeholder]="placeholder" [ngStyle]="style" [options]="{ suffix: ' kg', prefix: '', thousands: '.', decimal: ',', allowNegative: false }" [(ngModel)]="value" (ngModelChange)="notifyChanges($event)" (blur)="blurEvt($event)"> `, styles: [``], providers: [PESO_PROVIDER] },] }, ]; /** @nocollapse */ PesoComponent.ctorParameters = () => []; PesoComponent.propDecorators = { "style": [{ type: Input },], "maxLength": [{ type: Input },], "placeholder": [{ type: Input },], "id": [{ type: Input },], "blur": [{ type: Output },], }; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ class PesoModule { } PesoModule.decorators = [ { type: NgModule, args: [{ imports: [ CommonModule, FormsModule, NgxCurrencyModule ], declarations: [ PesoComponent ], exports: [ PesoComponent ] },] }, ]; /** @nocollapse */ PesoModule.ctorParameters = () => []; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ const TELEFONE_PROVIDER = { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => TelefoneComponent), multi: true, }; class TelefoneComponent extends ValueAccessorBase { constructor() { super(...arguments); this.pattern = (value) => { return value.toString().length === 11 ? telefoneCelularPattern : telefoneFixoPattern; }; this.placeholder = telefoneFixoPattern; this.blur = new EventEmitter(); } /** * @param {?} value * @return {?} */ transform(value) { return value ? value.replace(/[^\d]/g, '').trim().slice(0, 11) : value; } /** * @param {?} event * @return {?} */ blurEvt(event) { this.blur.emit(event); } } TelefoneComponent.decorators = [ { type: Component, args: [{ selector: 'telefone', template: `<input telefoneMask class="form-control" maxlength="16" [id]="id" [disabled]="disabled" [placeholder]="placeholder" [(ngModel)]="value" (ngModelChange)="notifyChanges($event)"> `, styles: [``], providers: [TELEFONE_PROVIDER] },] }, ]; /** @nocollapse */ TelefoneComponent.ctorParameters = () => []; TelefoneComponent.propDecorators = { "placeholder": [{ type: Input },], "id": [{ type: Input },], "blur": [{ type: Output },], }; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ /** * @param {?} value * @return {?} */ function removeNonDigitValues(value) { return value ? value.replace(/[^\d]/g, '').trim() : value; } /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ const vanillaMasker$11 = require('vanilla-masker'); class TelefoneMaskDirective { /** * @param {?} element */ constructor(element) { this.element = element; this.nativeElement = this.element.nativeElement; } /** * @param {?} event * @return {?} */ onKeyup(event) { const /** @type {?} */ telefonePattern = removeNonDigitValues(this.nativeElement.value).length === 11 ? telefoneCelularPattern : telefoneFixoPattern; this.nativeElement.value = vanillaMasker$11.toPattern(this.nativeElement.value, telefonePattern); } } TelefoneMaskDirective.decorators = [ { type: Directive, args: [{ selector: '[telefoneMask]', },] }, ]; /** @nocollapse */ TelefoneMaskDirective.ctorParameters = () => [ { type: ElementRef, }, ]; TelefoneMaskDirective.propDecorators = { "onKeyup": [{ type: HostListener, args: ['keyup', ['$event'],] },], }; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ class TelefoneModule { } TelefoneModule.decorators = [ { type: NgModule, args: [{ imports: [ CommonModule, FormsModule ], declarations: [ TelefoneComponent, TelefoneMaskDirective ], exports: [ TelefoneComponent, TelefoneMaskDirective ] },] }, ]; /** @nocollapse */ TelefoneModule.ctorParameters = () => []; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ const CEP_PROVIDER = { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => CepComponent), multi: true, }; class CepComponent extends ValueAccessorBase { constructor() { super(...arguments); this.pattern = cepPattern; this.placeholder = cepPlaceholder; this.blur = new EventEmitter(); } /** * @param {?} event * @return {?} */ blurEvt(event) { this.blur.emit(event); } /** * @param {?} value * @return {?} */ transform(value) { return value ? value.replace(/[^\d]/g, '').trim().slice(0, 8) : value; } } CepComponent.decorators = [ { type: Component, args: [{ selector: 'cep', template: `<input cepMask class="form-control" maxlength="9" [id]="id" [placeholder]="placeholder" [disabled]="disabled" [(ngModel)]="value" (ngModelChange)="notifyChanges($event)" (blur)="blurEvt($event)"> `, styles: [``], providers: [CEP_PROVIDER] },] }, ]; /** @nocollapse */ CepComponent.ctorParameters = () => []; CepComponent.propDecorators = { "id": [{ type: Input },], "placeholder": [{ type: Input },], "blur": [{ type: Output },], }; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ const vanillaMasker$12 = require('vanilla-masker'); class CepMaskDirective { /** * @param {?} element */ constructor(element) { this.element = element; this.nativeElement = this.element.nativeElement; vanillaMasker$12(this.nativeElement).maskPattern(cepPattern); } } CepMaskDirective.decorators = [ { type: Directive, args: [{ selector: '[cepMask]', },] }, ]; /** @nocollapse */ CepMaskDirective.ctorParameters = () => [ { type: ElementRef, }, ]; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ class CepModule { } CepModule.decorators = [ { type: NgModule, args: [{ imports: [ CommonModule, FormsModule ], declarations: [ CepComponent, CepMaskDirective ], exports: [ CepComponent, CepMaskDirective ] },] }, ]; /** @nocollapse */ CepModule.ctorParameters = () => []; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ class NgxBrComponentsModule { } NgxBrComponentsModule.decorators = [ { type: NgModule, args: [{ imports: [ CpfModule, CepModule, CnpjModule, DinheiroModule, EstadosModule, HoraModule, PercentualModule, PesoModule, TelefoneModule, ], exports: [ CpfModule, CepModule, CnpjModule, DinheiroModule, EstadosModule, HoraModule, PercentualModule, PesoModule, TelefoneModule, ] },] }, ]; /** @nocollapse */ NgxBrComponentsModule.ctorParameters = () => []; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ const CPF = require('cpf_cnpj').CPF; /** * @return {?} */ function cpfValidationFn() { return (control) => { const /** @type {?} */ value = control.value; if (value && !CPF.isValid(value)) { return { cpf: true, }; } return null; }; } /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ const CNPJ = require('cpf_cnpj').CNPJ; /** * @return {?} */ function cnpjValidationFn() { return (control) => { const /** @type {?} */ value = control.value; if (value && !CNPJ.isValid(value)) { return { cnpj: true, }; } return null; }; } /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ /** * @return {?} */ function dinheiroValidationFn() { return (control) => { const /** @type {?} */ value = control.value; return value && value !== '0.00' && '0,00' ? null : { dinheiroRequired: true }; }; } /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ /** * @return {?} */ function percentualValidationFn() { return (control) => { const /** @type {?} */ value = control.value; return value && value !== '0.0' ? null : { percentualRequired: true }; }; } /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ /** * @return {?} */ function horaValidationFn() { return (control) => { const /** @type {?} */ value = control.value; if (!value) { return null; } const /** @type {?} */ isValid = new RegExp('^([0-1]?[0-9]|2[0-3]):([0-5][0-9])?$').test(value); if (!isValid) { return { hora: true, }; } return null; }; } /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ class NgxBrValidators { } NgxBrValidators.cpf = cpfValidationFn; NgxBrValidators.cnpj = cnpjValidationFn; NgxBrValidators.hora = horaValidationFn; NgxBrValidators.dinheiroRequired = dinheiroValidationFn; NgxBrValidators.percentualRequired = percentualValidationFn; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ class NgxBrModule { /** * @return {?} */ static forRoot() { return { ngModule: NgxBrModule, providers: [] }; } } NgxBrModule.decorators = [ { type: NgModule, args: [{ imports: [ NgxBrComponentsModule, NgxBrPipesModule ], exports: [ NgxBrComponentsModule, NgxBrPipesModule ] },] }, ]; /** @nocollapse */ NgxBrModule.ctorParameters = () => []; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ /** * Generated bundle index. Do not edit. */ export { NgxBrModule, NgxBrPipesModule, CnpjPipe, CpfCnpjPipe, CpfPipe, TelefonePipe, NgxBrComponentsModule, CepModule, CepMaskDirective, CepComponent, CnpjModule, CnpjComponent, CnpjMaskDirective, CnpjComponentContainer, CpfModule, CpfComponent, CpfComponentContainer, CpfMaskDirective, DinheiroModule, DinheiroComponent, DinheiroMaskDirective, EstadosModule, EstadosComponent, Estado, HoraModule, HoraComponent, HoraMaskDirective, PercentualModule, PercentualComponent, PercentualMaskDirective, PesoModule, PesoComponent, TelefoneModule, TelefoneComponent, TelefoneMaskDirective, NgxBrValidators, cpfValidationFn, cnpjValidationFn, percentualValidationFn, dinheiroValidationFn, horaValidationFn, ValueAccessorBase }; //# sourceMappingURL=ngx-br.js.map