UNPKG

@koalarx/ui

Version:

Koala UI is a modern and accessible component library designed to speed up interface development in Angular projects. With simple integration and clear documentation, you can easily build robust and visually appealing applications.

38 lines (33 loc) 2.33 kB
import { validateCpf } from '@koalarx/utils/KlString'; import * as i0 from '@angular/core'; import { inject, effect, Component } from '@angular/core'; import { AppConfig } from '@koalarx/ui/core/config'; import { InputFieldBase } from '@koalarx/ui/shared/components/input-field'; import { InputText } from '@koalarx/ui/shared/components/input-field/input-text'; function CPFValidator(control) { if (control.value && !validateCpf(control.value)) { return { cpfInvalid: true }; } return null; } class InputCpf extends InputFieldBase { translations = inject(AppConfig).translation.form; constructor() { super(); effect(() => { const control = this.control(); control.addValidators(CPFValidator); }); } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: InputCpf, deps: [], target: i0.ɵɵFactoryTarget.Component }); static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.0.6", type: InputCpf, isStandalone: true, selector: "kl-input-cpf", usesInheritance: true, ngImport: i0, template: "<kl-input-text\n [control]=\"control()\"\n [label]=\"label()\"\n [placeholder]=\"placeholder()\"\n mask=\"000.000.000-00\">\n\n <ng-container errors>\n @if (control().errors?.['cpfInvalid']) {\n <div class=\"error-message\">{{ translations.invalidCPF }}</div>\n }\n </ng-container>\n</kl-input-text>\n", dependencies: [{ kind: "component", type: InputText, selector: "kl-input-text", inputs: ["mask"] }] }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: InputCpf, decorators: [{ type: Component, args: [{ selector: 'kl-input-cpf', imports: [InputText], template: "<kl-input-text\n [control]=\"control()\"\n [label]=\"label()\"\n [placeholder]=\"placeholder()\"\n mask=\"000.000.000-00\">\n\n <ng-container errors>\n @if (control().errors?.['cpfInvalid']) {\n <div class=\"error-message\">{{ translations.invalidCPF }}</div>\n }\n </ng-container>\n</kl-input-text>\n" }] }], ctorParameters: () => [] }); /** * Generated bundle index. Do not edit. */ export { CPFValidator, InputCpf }; //# sourceMappingURL=koalarx-ui-shared-components-input-field-input-cpf.mjs.map