This commit is contained in:
2026-01-23 20:35:40 +03:00
parent cf3b0e48ec
commit 66c151653e
137 changed files with 41495 additions and 0 deletions

View File

@@ -0,0 +1,54 @@
import { ReactNode } from 'react';
import { defaultLayoutConfig, type LayoutConfig } from '~/lib/layout-utils';
interface FormFieldProps {
children: ReactNode;
label?: string;
error?: string;
helperText?: string;
required?: boolean;
className?: string;
config?: Partial<LayoutConfig>;
htmlFor?: string;
}
export function FormField({
children,
label,
error,
helperText,
required = false,
className = '',
config = {},
htmlFor,
}: FormFieldProps) {
const layoutConfig = { ...defaultLayoutConfig, ...config };
return (
<div className={`${className}`} dir={layoutConfig.direction}>
{label && (
<label
htmlFor={htmlFor}
className={`block text-sm font-medium mb-2 ${error ? 'text-red-700' : 'text-gray-700'} ${layoutConfig.direction === 'rtl' ? 'text-right' : 'text-left'}`}
>
{label}
{required && <span className="text-red-500 mr-1">*</span>}
</label>
)}
{children}
{error && (
<p className={`mt-2 text-sm text-red-600 ${layoutConfig.direction === 'rtl' ? 'text-right' : 'text-left'}`}>
{error}
</p>
)}
{helperText && !error && (
<p className={`mt-2 text-sm text-gray-500 ${layoutConfig.direction === 'rtl' ? 'text-right' : 'text-left'}`}>
{helperText}
</p>
)}
</div>
);
}