--- /** * DEFAULT INPUT COMPONENT */ import type { InputType } from '@astro-reactive/common'; import type { FormControl } from '../../core/form-control'; export interface Props { control: FormControl; readOnly?: boolean; } const { control, readOnly } = Astro.props; const { validators = [] } = control; const hasError: boolean = control.errors?.length ? control.errors[0]?.category === 'error' : false; const hasWarn: boolean = control.errors?.length ? control.errors[0]?.category === 'warn' : false; const hasInfo: boolean = control.errors?.length ? control.errors[0]?.category === 'info' : false; // @ts-ignore const validatorAttributes: Record = validators.reduce((prev, val) => { const validator = typeof val === 'string' ? val : val.validator; const split: string[] = validator.split(':'); const label: string = `data-${split[0]}` || 'invalid'; const value: string | null = split.length > 1 ? split[1] ?? null : 'true'; const category = typeof val === 'string' ? 'error' : val.category || 'error'; const categoryLabel: string = `data-${split[0]}-category`; return { ...prev, [label]: value, [categoryLabel]: category, }; }, {}); ---