UNPKG

ngx-br

Version:
1,476 lines (1,475 loc) 45.4 kB
import * as tslib_1 from "tslib"; 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 */ var telefoneFixoPattern = '(99) 9999-9999'; var telefoneCelularPattern = '(99) 99999-9999'; var horaPattern = '99:99'; var cpfPattern = '999.999.999-99'; var cnpjPattern = '99.999.999/9999-99'; var cepPattern = '99999-999'; var cepPlaceholder = '00000-000'; var cnpjPlaceholder = '00.000.000/0000-00'; var cpfPlaceholder = '000.000.000-00'; var pesoPlaceholder = '0,00 kg'; var dinheiroPlaceholder = 'R$ 0,00'; var percentualPlaceholder = '0%'; var horaPlaceholder = 'HH:MM'; var dinheiroPatternConfig = { precision: 2, separator: ',', delimiter: '.', unit: 'R$', zeroCents: false, }; var percentualPatternConfig = { precision: 1, separator: ',', delimiter: ',', suffixUnit: '%', zeroCents: false, }; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var vanillaMasker = require('vanilla-masker'); var CpfPipe = /** @class */ (function () { function CpfPipe() { } /** * @param {?} value * @return {?} */ CpfPipe.prototype.transform = function (value) { if (!value) { return ''; } return vanillaMasker.toPattern(value, cpfPattern); }; return CpfPipe; }()); CpfPipe.decorators = [ { type: Pipe, args: [{ name: 'cpf', },] }, ]; /** @nocollapse */ CpfPipe.ctorParameters = function () { return []; }; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var vanillaMasker$1 = require('vanilla-masker'); var CnpjPipe = /** @class */ (function () { function CnpjPipe() { } /** * @param {?} value * @return {?} */ CnpjPipe.prototype.transform = function (value) { if (!value) { return ''; } return vanillaMasker$1.toPattern(value, cnpjPattern); }; return CnpjPipe; }()); CnpjPipe.decorators = [ { type: Pipe, args: [{ name: 'cnpj', },] }, ]; /** @nocollapse */ CnpjPipe.ctorParameters = function () { return []; }; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var vanillaMasker$2 = require('vanilla-masker'); var CPF_LENGTH = 11; var CpfCnpjPipe = /** @class */ (function () { function CpfCnpjPipe() { } /** * @param {?} value * @return {?} */ CpfCnpjPipe.prototype.transform = function (value) { if (!value) { return ''; } if (value.length > CPF_LENGTH) { return vanillaMasker$2.toPattern(value, cnpjPattern); } return vanillaMasker$2.toPattern(value, cpfPattern); }; return CpfCnpjPipe; }()); CpfCnpjPipe.decorators = [ { type: Pipe, args: [{ name: 'cpfOuCnpj', },] }, ]; /** @nocollapse */ CpfCnpjPipe.ctorParameters = function () { return []; }; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var vanillaMasker$3 = require('vanilla-masker'); var TelefonePipe = /** @class */ (function () { function TelefonePipe() { } /** * @param {?} value * @return {?} */ TelefonePipe.prototype.transform = function (value) { if (!value) { return ''; } var /** @type {?} */ telefonePattern = value.toString().length === 11 ? telefoneCelularPattern : telefoneFixoPattern; return vanillaMasker$3.toPattern(value, telefonePattern); }; return TelefonePipe; }()); TelefonePipe.decorators = [ { type: Pipe, args: [{ name: 'telefone', },] }, ]; /** @nocollapse */ TelefonePipe.ctorParameters = function () { return []; }; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var NgxBrPipesModule = /** @class */ (function () { function NgxBrPipesModule() { } return 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 = function () { return []; }; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var vanillaMasker$4 = require('vanilla-masker'); /** * @abstract */ var ValueAccessorBase = /** @class */ (function () { function ValueAccessorBase() { this.disabled = false; this.onChange = function () { }; this.onTouched = function () { }; } Object.defineProperty(ValueAccessorBase.prototype, "value", { /** * @return {?} */ get: function () { return this.innerValue; }, /** * @param {?} value * @return {?} */ set: function (value) { this.innerValue = value; this.onChange(value); this.onTouched(); }, enumerable: true, configurable: true }); /** * @param {?} value * @return {?} */ ValueAccessorBase.prototype.writeValue = function (value) { if (!this.pattern) { this.innerValue = value; } else { this.innerValue = this.applyPattern(value); } }; /** * @param {?} value * @return {?} */ ValueAccessorBase.prototype.applyPattern = function (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 {?} */ ValueAccessorBase.prototype.registerOnChange = function (fn) { this.onChange = fn; }; /** * @param {?} fn * @return {?} */ ValueAccessorBase.prototype.registerOnTouched = function (fn) { this.onTouched = fn; }; /** * @param {?} isDisabled * @return {?} */ ValueAccessorBase.prototype.setDisabledState = function (isDisabled) { this.disabled = isDisabled; }; /** * @return {?} */ ValueAccessorBase.prototype.touch = function () { this.onTouched.forEach(function (f) { return f(); }); }; /** * @param {?} value * @return {?} */ ValueAccessorBase.prototype.notifyChanges = function (value) { value = this.transform(value); this.onChange(value); this.onTouched(); }; return ValueAccessorBase; }()); ValueAccessorBase.propDecorators = { "disabled": [{ type: Input },], }; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var CPF_PROVIDER = { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(function () { return CpfComponent; }), multi: true, }; var CpfComponent = /** @class */ (function (_super) { tslib_1.__extends(CpfComponent, _super); function CpfComponent() { var _this = _super.apply(this, tslib_1.__spread(arguments)) || this; _this.pattern = cpfPattern; _this.placeholder = cpfPlaceholder; _this.blur = new EventEmitter(); return _this; } /** * @param {?} value * @return {?} */ CpfComponent.prototype.transform = function (value) { return value ? value.replace(/[^\d]/g, '').trim().slice(0, 11) : value; }; /** * @param {?} event * @return {?} */ CpfComponent.prototype.blurEvt = function (event) { this.blur.emit(event); }; return CpfComponent; }(ValueAccessorBase)); CpfComponent.decorators = [ { type: Component, args: [{ selector: 'cpf', template: "<input\n cpfMask\n type=\"text\"\n class=\"form-control\"\n maxlength=\"14\"\n [id]=\"id\"\n [placeholder]=\"placeholder\"\n [disabled]=\"disabled\"\n [(ngModel)]=\"value\"\n (ngModelChange)=\"notifyChanges($event)\"\n (blur)=\"blurEvt($event)\">\n", styles: [""], providers: [CPF_PROVIDER], },] }, ]; /** @nocollapse */ CpfComponent.ctorParameters = function () { return []; }; CpfComponent.propDecorators = { "placeholder": [{ type: Input },], "id": [{ type: Input },], "blur": [{ type: Output },], }; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var vanillaMasker$5 = require('vanilla-masker'); var CpfMaskDirective = /** @class */ (function () { /** * @param {?} element */ function CpfMaskDirective(element) { this.element = element; this.nativeElement = this.element.nativeElement; vanillaMasker$5(this.nativeElement).maskPattern(cpfPattern); } return CpfMaskDirective; }()); CpfMaskDirective.decorators = [ { type: Directive, args: [{ selector: '[cpfMask]', },] }, ]; /** @nocollapse */ CpfMaskDirective.ctorParameters = function () { return [ { type: ElementRef, }, ]; }; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var CpfComponentContainer = /** @class */ (function () { function CpfComponentContainer() { this.requiredMsg = 'Este campo é obrigatório'; this.cpfMsg = 'CPF Inválido'; } /** * @return {?} */ CpfComponentContainer.prototype.shouldShowErrors = function () { return this.control && !this.control.valid && !this.control.pristine && this.control.touched && !!this.control.errors; }; return CpfComponentContainer; }()); CpfComponentContainer.decorators = [ { type: Component, args: [{ selector: 'cpf-container', template: "\n <ng-content></ng-content>\n <span *ngIf=\"shouldShowErrors()\" style=\"color: #f05050\">\n <span *ngIf=\"control.hasError('required')\">{{requiredMsg}}</span>\n <span *ngIf=\"!control.hasError('required') && control.hasError('cpf')\">{{cpfMsg}}</span>\n </span>\n ", },] }, ]; /** @nocollapse */ CpfComponentContainer.ctorParameters = function () { return []; }; CpfComponentContainer.propDecorators = { "control": [{ type: Input },], "requiredMsg": [{ type: Input },], "cpfMsg": [{ type: Input },], }; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var CpfModule = /** @class */ (function () { function CpfModule() { } return CpfModule; }()); CpfModule.decorators = [ { type: NgModule, args: [{ imports: [ CommonModule, FormsModule ], declarations: [ CpfComponent, CpfMaskDirective, CpfComponentContainer ], exports: [ CpfComponent, CpfMaskDirective, CpfComponentContainer ] },] }, ]; /** @nocollapse */ CpfModule.ctorParameters = function () { return []; }; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var CNPJ_PROVIDER = { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(function () { return CnpjComponent; }), multi: true, }; var CnpjComponent = /** @class */ (function (_super) { tslib_1.__extends(CnpjComponent, _super); function CnpjComponent() { var _this = _super.apply(this, tslib_1.__spread(arguments)) || this; _this.pattern = cnpjPattern; _this.placeholder = cnpjPlaceholder; _this.blur = new EventEmitter(); return _this; } /** * @param {?} value * @return {?} */ CnpjComponent.prototype.transform = function (value) { return value ? value.replace(/[^\d]/g, '').trim().slice(0, 14) : value; }; /** * @param {?} event * @return {?} */ CnpjComponent.prototype.blurEvt = function (event) { this.blur.emit(event); }; return CnpjComponent; }(ValueAccessorBase)); CnpjComponent.decorators = [ { type: Component, args: [{ selector: 'cnpj', template: "<input\n cnpjMask\n class=\"form-control\"\n type=\"text\"\n maxlength=\"18\"\n [id]=\"id\"\n [placeholder]=\"placeholder\"\n [disabled]=\"disabled\"\n [(ngModel)]=\"value\"\n (ngModelChange)=\"notifyChanges($event)\"\n (blur)=\"blurEvt($event)\">\n", styles: [""], providers: [CNPJ_PROVIDER] },] }, ]; /** @nocollapse */ CnpjComponent.ctorParameters = function () { return []; }; CnpjComponent.propDecorators = { "placeholder": [{ type: Input },], "id": [{ type: Input },], "blur": [{ type: Output },], }; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var vanillaMasker$6 = require('vanilla-masker'); var CnpjMaskDirective = /** @class */ (function () { /** * @param {?} element */ function CnpjMaskDirective(element) { this.element = element; this.nativeElement = this.element.nativeElement; vanillaMasker$6(this.nativeElement).maskPattern(cnpjPattern); } return CnpjMaskDirective; }()); CnpjMaskDirective.decorators = [ { type: Directive, args: [{ selector: '[cnpjMask]', },] }, ]; /** @nocollapse */ CnpjMaskDirective.ctorParameters = function () { return [ { type: ElementRef, }, ]; }; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var CnpjComponentContainer = /** @class */ (function () { function CnpjComponentContainer() { this.requiredMsg = 'Este campo é obrigatório'; this.cnpjMsg = 'CNPJ Inválido'; } /** * @return {?} */ CnpjComponentContainer.prototype.shouldShowErrors = function () { return this.control && !this.control.valid && !this.control.pristine && this.control.touched && !!this.control.errors; }; return CnpjComponentContainer; }()); CnpjComponentContainer.decorators = [ { type: Component, args: [{ selector: 'cnpj-container', template: "\n <ng-content></ng-content>\n <span *ngIf=\"shouldShowErrors()\" style=\"color: #f05050\">\n <span *ngIf=\"control.hasError('required')\">{{requiredMsg}}</span>\n <span *ngIf=\"!control.hasError('required') && control.hasError('cnpj')\">{{cnpjMsg}}</span>\n </span>\n ", },] }, ]; /** @nocollapse */ CnpjComponentContainer.ctorParameters = function () { return []; }; CnpjComponentContainer.propDecorators = { "control": [{ type: Input },], "requiredMsg": [{ type: Input },], "cnpjMsg": [{ type: Input },], }; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var CnpjModule = /** @class */ (function () { function CnpjModule() { } return CnpjModule; }()); CnpjModule.decorators = [ { type: NgModule, args: [{ imports: [ CommonModule, FormsModule ], declarations: [ CnpjComponent, CnpjMaskDirective, CnpjComponentContainer ], exports: [ CnpjComponent, CnpjMaskDirective, CnpjComponentContainer ] },] }, ]; /** @nocollapse */ CnpjModule.ctorParameters = function () { return []; }; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var DINHEIRO_PROVIDER = { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(function () { return DinheiroComponent; }), multi: true, }; var DinheiroComponent = /** @class */ (function (_super) { tslib_1.__extends(DinheiroComponent, _super); /** * @param {?} elementRef */ function DinheiroComponent(elementRef) { var _this = _super.call(this) || this; _this.elementRef = elementRef; _this.placeholder = dinheiroPlaceholder; _this.maxLength = 15; _this.blur = new EventEmitter(); return _this; } /** * @param {?} event * @return {?} */ DinheiroComponent.prototype.blurEvt = function (event) { this.blur.emit(event); }; /** * @param {?} value * @return {?} */ DinheiroComponent.prototype.transform = function (value) { return value; }; /** * @param {?} event * @return {?} */ DinheiroComponent.prototype.onKeydown = function (event) { if (event.ctrlKey && event.keyCode === 65) { console.log(this.elementRef); } }; return DinheiroComponent; }(ValueAccessorBase)); DinheiroComponent.decorators = [ { type: Component, args: [{ selector: 'dinheiro', template: "<input\n currencyMask\n class=\"form-control\"\n maxlength=\"{{maxLength}}\"\n [id]=\"id\"\n [disabled]=\"disabled\"\n [placeholder]=\"placeholder\"\n [ngStyle]=\"style\"\n [options]=\"{ prefix: 'R$ ', thousands: '.', decimal: ',', allowNegative: false }\"\n [(ngModel)]=\"value\"\n (keydown)=\"onKeydown($event)\"\n (ngModelChange)=\"notifyChanges($event)\"\n (blur)=\"blurEvt($event)\">\n", styles: [""], providers: [DINHEIRO_PROVIDER] },] }, ]; /** @nocollapse */ DinheiroComponent.ctorParameters = function () { return [ { 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 */ var vanillaMasker$7 = require('vanilla-masker'); var DinheiroMaskDirective = /** @class */ (function () { /** * @param {?} element */ function DinheiroMaskDirective(element) { this.element = element; this.nativeElement = this.element.nativeElement; vanillaMasker$7(this.nativeElement).maskMoney(dinheiroPatternConfig); } return DinheiroMaskDirective; }()); DinheiroMaskDirective.decorators = [ { type: Directive, args: [{ selector: '[dinheiroMask]', },] }, ]; /** @nocollapse */ DinheiroMaskDirective.ctorParameters = function () { return [ { type: ElementRef, }, ]; }; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var DinheiroModule = /** @class */ (function () { function DinheiroModule() { } return DinheiroModule; }()); DinheiroModule.decorators = [ { type: NgModule, args: [{ imports: [ CommonModule, FormsModule, NgxCurrencyModule ], declarations: [ DinheiroComponent, DinheiroMaskDirective, ], exports: [ DinheiroComponent, DinheiroMaskDirective ] },] }, ]; /** @nocollapse */ DinheiroModule.ctorParameters = function () { return []; }; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var Estado = /** @class */ (function () { /** * @param {?} sigla * @param {?} descricao */ function Estado(sigla, descricao) { this.sigla = sigla; this.descricao = descricao; } return Estado; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var ESTADOS_PROVIDER = { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(function () { return EstadosComponent; }), multi: true, }; var EstadosComponent = /** @class */ (function (_super) { tslib_1.__extends(EstadosComponent, _super); function EstadosComponent() { var _this = _super.apply(this, tslib_1.__spread(arguments)) || this; _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'), ]; return _this; } /** * @param {?} T * @return {?} */ EstadosComponent.prototype.transform = function (T) { return undefined; }; return EstadosComponent; }(ValueAccessorBase)); EstadosComponent.decorators = [ { type: Component, args: [{ selector: 'estados', template: "<select\n class=\"form-control\"\n [(ngModel)]=\"value\"\n [id]=\"id\"\n [disabled]=\"disabled\">\n <option value=\"null\" disabled selected>{{placeholder}}</option>\n <option *ngFor=\"let estado of estados\" [ngValue]=\"estado.sigla\">{{estado.descricao}}</option>\n</select>\n", styles: [""], providers: [ESTADOS_PROVIDER] },] }, ]; /** @nocollapse */ EstadosComponent.ctorParameters = function () { return []; }; EstadosComponent.propDecorators = { "placeholder": [{ type: Input },], "id": [{ type: Input },], }; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var EstadosModule = /** @class */ (function () { function EstadosModule() { } return EstadosModule; }()); EstadosModule.decorators = [ { type: NgModule, args: [{ imports: [ CommonModule, FormsModule ], declarations: [ EstadosComponent ], exports: [ EstadosComponent ] },] }, ]; /** @nocollapse */ EstadosModule.ctorParameters = function () { return []; }; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var vanillaMasker$8 = require('vanilla-masker'); var HORA_PROVIDER = { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(function () { return HoraComponent; }), multi: true, }; var HoraComponent = /** @class */ (function (_super) { tslib_1.__extends(HoraComponent, _super); function HoraComponent() { var _this = _super.apply(this, tslib_1.__spread(arguments)) || this; _this.pattern = horaPattern; _this.placeholder = horaPlaceholder; _this.blur = new EventEmitter(); return _this; } /** * @param {?} event * @return {?} */ HoraComponent.prototype.blurEvt = function (event) { var /** @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 {?} */ HoraComponent.prototype.transform = function (value) { return value ? value.replace(/[^\d]/g, '').trim().slice(0, 5) : value; }; return HoraComponent; }(ValueAccessorBase)); HoraComponent.decorators = [ { type: Component, args: [{ selector: 'hora', template: "<input\n horaMask\n class=\"form-control text-right\"\n maxlength=\"5\"\n [id]=\"id\"\n [disabled]=\"disabled\"\n [placeholder]=\"placeholder\"\n [(ngModel)]=\"value\"\n (ngModelChange)=\"notifyChanges($event)\"\n (blur)=\"blurEvt($event)\">\n", styles: [""], providers: [HORA_PROVIDER] },] }, ]; /** @nocollapse */ HoraComponent.ctorParameters = function () { return []; }; HoraComponent.propDecorators = { "id": [{ type: Input },], "placeholder": [{ type: Input },], "blur": [{ type: Output },], }; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var vanillaMasker$9 = require('vanilla-masker'); var HoraMaskDirective = /** @class */ (function () { /** * @param {?} element */ function HoraMaskDirective(element) { this.element = element; this.nativeElement = this.element.nativeElement; vanillaMasker$9(this.nativeElement).maskPattern(horaPattern); } return HoraMaskDirective; }()); HoraMaskDirective.decorators = [ { type: Directive, args: [{ selector: '[horaMask]', },] }, ]; /** @nocollapse */ HoraMaskDirective.ctorParameters = function () { return [ { type: ElementRef, }, ]; }; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var HoraModule = /** @class */ (function () { function HoraModule() { } return HoraModule; }()); HoraModule.decorators = [ { type: NgModule, args: [{ imports: [ CommonModule, FormsModule ], declarations: [ HoraComponent, HoraMaskDirective ], exports: [ HoraComponent, HoraMaskDirective ] },] }, ]; /** @nocollapse */ HoraModule.ctorParameters = function () { return []; }; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var PERCENTUAL_PROVIDER = { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(function () { return PercentualComponent; }), multi: true, }; var PercentualComponent = /** @class */ (function (_super) { tslib_1.__extends(PercentualComponent, _super); function PercentualComponent() { var _this = _super.apply(this, tslib_1.__spread(arguments)) || this; _this.maxLength = 10; _this.placeholder = percentualPlaceholder; _this.blur = new EventEmitter(); return _this; } /** * @param {?} event * @return {?} */ PercentualComponent.prototype.blurEvt = function (event) { this.blur.emit(event); }; /** * @param {?} value * @return {?} */ PercentualComponent.prototype.transform = function (value) { return value; }; return PercentualComponent; }(ValueAccessorBase)); PercentualComponent.decorators = [ { type: Component, args: [{ selector: 'percentual', template: "<input\n currencyMask\n class=\"form-control\"\n maxlength=\"{{maxLength}}\"\n [id]=\"id\"\n [disabled]=\"disabled\"\n [placeholder]=\"placeholder\"\n [ngStyle]=\"style\"\n [options]=\"{ suffix: ' %', prefix: '', thousands: '.', decimal: ',', allowNegative: true }\"\n [(ngModel)]=\"value\"\n (ngModelChange)=\"notifyChanges($event)\"\n (blur)=\"blurEvt($event)\">\n", styles: [""], providers: [PERCENTUAL_PROVIDER] },] }, ]; /** @nocollapse */ PercentualComponent.ctorParameters = function () { return []; }; 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 */ var vanillaMasker$10 = require('vanilla-masker'); var PercentualMaskDirective = /** @class */ (function () { /** * @param {?} element */ function PercentualMaskDirective(element) { this.element = element; this.nativeElement = this.element.nativeElement; vanillaMasker$10(this.nativeElement).maskMoney(percentualPatternConfig); } return PercentualMaskDirective; }()); PercentualMaskDirective.decorators = [ { type: Directive, args: [{ selector: '[percentualMask]', },] }, ]; /** @nocollapse */ PercentualMaskDirective.ctorParameters = function () { return [ { type: ElementRef, }, ]; }; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var PercentualModule = /** @class */ (function () { function PercentualModule() { } return PercentualModule; }()); PercentualModule.decorators = [ { type: NgModule, args: [{ imports: [ CommonModule, FormsModule, NgxCurrencyModule ], declarations: [ PercentualComponent, PercentualMaskDirective ], exports: [ PercentualComponent, PercentualMaskDirective ] },] }, ]; /** @nocollapse */ PercentualModule.ctorParameters = function () { return []; }; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var PESO_PROVIDER = { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(function () { return PesoComponent; }), multi: true, }; var PesoComponent = /** @class */ (function (_super) { tslib_1.__extends(PesoComponent, _super); function PesoComponent() { var _this = _super.apply(this, tslib_1.__spread(arguments)) || this; _this.maxLength = 10; _this.placeholder = pesoPlaceholder; _this.blur = new EventEmitter(); return _this; } /** * @param {?} event * @return {?} */ PesoComponent.prototype.blurEvt = function (event) { this.blur.emit(event); }; /** * @param {?} value * @return {?} */ PesoComponent.prototype.transform = function (value) { return value; }; return PesoComponent; }(ValueAccessorBase)); PesoComponent.decorators = [ { type: Component, args: [{ selector: 'peso', template: "<input\n currencyMask\n class=\"form-control\"\n placeholder=\"{{placeholder}}\"\n maxlength=\"{{maxLength}}\"\n [id]=\"id\"\n [disabled]=\"disabled\"\n [placeholder]=\"placeholder\"\n [ngStyle]=\"style\"\n [options]=\"{ suffix: ' kg', prefix: '', thousands: '.', decimal: ',', allowNegative: false }\"\n [(ngModel)]=\"value\"\n (ngModelChange)=\"notifyChanges($event)\"\n (blur)=\"blurEvt($event)\">\n", styles: [""], providers: [PESO_PROVIDER] },] }, ]; /** @nocollapse */ PesoComponent.ctorParameters = function () { return []; }; 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 */ var PesoModule = /** @class */ (function () { function PesoModule() { } return PesoModule; }()); PesoModule.decorators = [ { type: NgModule, args: [{ imports: [ CommonModule, FormsModule, NgxCurrencyModule ], declarations: [ PesoComponent ], exports: [ PesoComponent ] },] }, ]; /** @nocollapse */ PesoModule.ctorParameters = function () { return []; }; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var TELEFONE_PROVIDER = { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(function () { return TelefoneComponent; }), multi: true, }; var TelefoneComponent = /** @class */ (function (_super) { tslib_1.__extends(TelefoneComponent, _super); function TelefoneComponent() { var _this = _super.apply(this, tslib_1.__spread(arguments)) || this; _this.pattern = function (value) { return value.toString().length === 11 ? telefoneCelularPattern : telefoneFixoPattern; }; _this.placeholder = telefoneFixoPattern; _this.blur = new EventEmitter(); return _this; } /** * @param {?} value * @return {?} */ TelefoneComponent.prototype.transform = function (value) { return value ? value.replace(/[^\d]/g, '').trim().slice(0, 11) : value; }; /** * @param {?} event * @return {?} */ TelefoneComponent.prototype.blurEvt = function (event) { this.blur.emit(event); }; return TelefoneComponent; }(ValueAccessorBase)); TelefoneComponent.decorators = [ { type: Component, args: [{ selector: 'telefone', template: "<input\n telefoneMask\n class=\"form-control\"\n maxlength=\"16\"\n [id]=\"id\"\n [disabled]=\"disabled\"\n [placeholder]=\"placeholder\"\n [(ngModel)]=\"value\"\n (ngModelChange)=\"notifyChanges($event)\">\n", styles: [""], providers: [TELEFONE_PROVIDER] },] }, ]; /** @nocollapse */ TelefoneComponent.ctorParameters = function () { return []; }; 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 */ var vanillaMasker$11 = require('vanilla-masker'); var TelefoneMaskDirective = /** @class */ (function () { /** * @param {?} element */ function TelefoneMaskDirective(element) { this.element = element; this.nativeElement = this.element.nativeElement; } /** * @param {?} event * @return {?} */ TelefoneMaskDirective.prototype.onKeyup = function (event) { var /** @type {?} */ telefonePattern = removeNonDigitValues(this.nativeElement.value).length === 11 ? telefoneCelularPattern : telefoneFixoPattern; this.nativeElement.value = vanillaMasker$11.toPattern(this.nativeElement.value, telefonePattern); }; return TelefoneMaskDirective; }()); TelefoneMaskDirective.decorators = [ { type: Directive, args: [{ selector: '[telefoneMask]', },] }, ]; /** @nocollapse */ TelefoneMaskDirective.ctorParameters = function () { return [ { type: ElementRef, }, ]; }; TelefoneMaskDirective.propDecorators = { "onKeyup": [{ type: HostListener, args: ['keyup', ['$event'],] },], }; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var TelefoneModule = /** @class */ (function () { function TelefoneModule() { } return TelefoneModule; }()); TelefoneModule.decorators = [ { type: NgModule, args: [{ imports: [ CommonModule, FormsModule ], declarations: [ TelefoneComponent, TelefoneMaskDirective ], exports: [ TelefoneComponent, TelefoneMaskDirective ] },] }, ]; /** @nocollapse */ TelefoneModule.ctorParameters = function () { return []; }; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var CEP_PROVIDER = { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(function () { return CepComponent; }), multi: true, }; var CepComponent = /** @class */ (function (_super) { tslib_1.__extends(CepComponent, _super); function CepComponent() { var _this = _super.apply(this, tslib_1.__spread(arguments)) || this; _this.pattern = cepPattern; _this.placeholder = cepPlaceholder; _this.blur = new EventEmitter(); return _this; } /** * @param {?} event * @return {?} */ CepComponent.prototype.blurEvt = function (event) { this.blur.emit(event); }; /** * @param {?} value * @return {?} */ CepComponent.prototype.transform = function (value) { return value ? value.replace(/[^\d]/g, '').trim().slice(0, 8) : value; }; return CepComponent; }(ValueAccessorBase)); CepComponent.decorators = [ { type: Component, args: [{ selector: 'cep', template: "<input\n cepMask\n class=\"form-control\"\n maxlength=\"9\"\n [id]=\"id\"\n [placeholder]=\"placeholder\"\n [disabled]=\"disabled\"\n [(ngModel)]=\"value\"\n (ngModelChange)=\"notifyChanges($event)\"\n (blur)=\"blurEvt($event)\">\n", styles: [""], providers: [CEP_PROVIDER] },] }, ]; /** @nocollapse */ CepComponent.ctorParameters = function () { return []; }; CepComponent.propDecorators = { "id": [{ type: Input },], "placeholder": [{ type: Input },], "blur": [{ type: Output },], }; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var vanillaMasker$12 = require('vanilla-masker'); var CepMaskDirective = /** @class */ (function () { /** * @param {?} element */ function CepMaskDirective(element) { this.element = element; this.nativeElement = this.element.nativeElement; vanillaMasker$12(this.nativeElement).maskPattern(cepPattern); } return CepMaskDirective; }()); CepMaskDirective.decorators = [ { type: Directive, args: [{ selector: '[cepMask]', },] }, ]; /** @nocollapse */ CepMaskDirective.ctorParameters = function () { return [ { type: ElementRef, }, ]; }; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var CepModule = /** @class */ (function () { function CepModule() { } return CepModule; }()); CepModule.decorators = [ { type: NgModule, args: [{ imports: [ CommonModule, FormsModule ], declarations: [ CepComponent, CepMaskDirective ], exports: [ CepComponent, CepMaskDirective ] },] }, ]; /** @nocollapse */ CepModule.ctorParameters = function () { return []; }; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var NgxBrComponentsModule = /** @class */ (function () { function NgxBrComponentsModule() { } return 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 = function () { return []; }; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var CPF = require('cpf_cnpj').CPF; /** * @return {?} */ function cpfValidationFn() { return function (control) { var /** @type {?} */ value = control.value; if (value && !CPF.isValid(value)) { return { cpf: true, }; } return null; }; } /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var CNPJ = require('cpf_cnpj').CNPJ; /** * @return {?} */ function cnpjValidationFn() { return function (control) { var /** @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 function (control) { var /** @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 function (control) { var /** @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 function (control) { var /** @type {?} */ value = control.value; if (!value) { return null; } var /** @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 */ var NgxBrValidators = /** @class */ (function () { function NgxBrValidators() { } return 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 */ var NgxBrModule = /** @class */ (function () { function NgxBrModule() { } /** * @return {?} */ NgxBrModule.forRoot = function () { return { ngModule: NgxBrModule, providers: [] }; }; return NgxBrModule; }()); NgxBrModule.decorators = [ { type: NgModule, args: [{ imports: [ NgxBrComponentsModule, NgxBrPipesModule ], exports: [ NgxBrComponentsModule, NgxBrPipesModule ] },] }, ]; /** @nocollapse */ NgxBrModule.ctorParameters = function () { return []; }; /** * @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