UNPKG

@sixbell-telco/sdk

Version:

A collection of reusable components designed for use in Sixbell Telco Angular projects

1 lines 6.16 kB
{"version":3,"file":"sixbell-telco-sdk-components-forms-form-error.mjs","sources":["../../../projects/sdk/components/forms/form-error/src/form-error.component.ts","../../../projects/sdk/components/forms/form-error/src/form-error.component.html","../../../projects/sdk/components/forms/form-error/sixbell-telco-sdk-components-forms-form-error.ts"],"sourcesContent":["import { Component, computed, input } from '@angular/core';\nimport { FormControl, FormGroup } from '@angular/forms';\nimport { TranslatePipe } from '@ngx-translate/core';\nimport { TypographyDirective } from '@sixbell-telco/sdk/directives/typography';\n\n@Component({\n\tselector: 'st-form-errors',\n\timports: [TypographyDirective, TranslatePipe],\n\ttemplateUrl: './form-error.component.html',\n})\nexport class FormErrorsComponent {\n\t// Main properties\n\tparentForm = input.required<FormGroup>();\n\tformField = input.required<string>();\n\n\tformControl = computed(() => this.parentForm().get(this.formField()) as FormControl);\n\tcustomError = computed(() => {\n\t\tconst errors = this.formControl()?.errors;\n\t\tconst keys = Object.keys(errors || {});\n\n\t\tif (keys.length > 0) {\n\t\t\treturn this.formControl().getError(keys[0]);\n\t\t}\n\n\t\treturn null;\n\t});\n\n\t// Custom messages\n\tisRequired = input<string | undefined>(undefined);\n\tisMinLength = input<string | undefined>(undefined);\n\tisMaxLength = input<string | undefined>(undefined);\n\tisMin = input<string | undefined>(undefined);\n\tisMax = input<string | undefined>(undefined);\n\tisPattern = input<string | undefined>(undefined);\n\tisEmail = input<string | undefined>(undefined);\n}\n","<div\n\t[class]=\"\n\t\t!(formControl()?.errors && (formControl().dirty || formControl().touched))\n\t\t\t? 'text-error ease-ease-out-back invisible flex items-center justify-start px-1 opacity-0 transition-opacity duration-300 select-none'\n\t\t\t: 'text-error ease-ease-out-back visible flex items-center justify-start px-1 opacity-100 transition-opacity duration-300 select-none'\n\t\"\n>\n\t<span typography [tyVariant]=\"'body-xs'\" [tyColor]=\"'inherit'\" [tyFontWeight]=\"'normal'\">\n\t\t@if (formControl()?.errors && (formControl().dirty || formControl().touched)) {\n\t\t\t@if (formControl().getError('required')) {\n\t\t\t\t{{ isRequired() ?? 'sdk.formErrors.validation.required' | translate }}\n\t\t\t} @else if (formControl().getError('minlength')) {\n\t\t\t\t{{ isMinLength() ?? 'sdk.formErrors.validation.minLength' | translate: { min: formControl().getError('minlength').requiredLength } }}\n\t\t\t} @else if (formControl().getError('maxlength')) {\n\t\t\t\t{{ isMaxLength() ?? 'sdk.formErrors.validation.maxLength' | translate: { max: formControl().getError('maxlength').requiredLength } }}\n\t\t\t} @else if (formControl().getError('min')) {\n\t\t\t\t{{ isMin() ?? 'sdk.formErrors.validation.min' | translate: { min: formControl().getError('min').min } }}\n\t\t\t} @else if (formControl().getError('max')) {\n\t\t\t\t{{ isMax() ?? 'sdk.formErrors.validation.max' | translate: { max: formControl().getError('max').max } }}\n\t\t\t} @else if (formControl().getError('pattern')) {\n\t\t\t\t{{ isPattern() ?? 'sdk.formErrors.validation.pattern' | translate }}\n\t\t\t} @else if (formControl().getError('email')) {\n\t\t\t\t{{ isEmail() ?? 'sdk.formErrors.validation.email' | translate }}\n\t\t\t} @else if (customError()) {\n\t\t\t\t{{ customError() | translate }}\n\t\t\t}\n\t\t} @else {\n\t\t\t{{ 'sdk.formErrors.validation.unhandledError' | translate }}\n\t\t}\n\t</span>\n</div>\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;MAUa,mBAAmB,CAAA;;AAE/B,IAAA,UAAU,GAAG,KAAK,CAAC,QAAQ,EAAa;AACxC,IAAA,SAAS,GAAG,KAAK,CAAC,QAAQ,EAAU;AAEpC,IAAA,WAAW,GAAG,QAAQ,CAAC,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,EAAE,CAAgB,CAAC;AACpF,IAAA,WAAW,GAAG,QAAQ,CAAC,MAAK;QAC3B,MAAM,MAAM,GAAG,IAAI,CAAC,WAAW,EAAE,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