first commit

This commit is contained in:
Stefan Hacker
2026-01-29 01:16:54 +01:00
commit e209e9bbca
12105 changed files with 2480672 additions and 0 deletions
+46
View File
@@ -0,0 +1,46 @@
import { SelectHTMLAttributes, forwardRef } from 'react';
interface SelectProps extends SelectHTMLAttributes<HTMLSelectElement> {
label?: string;
error?: string;
options: { value: string | number; label: string }[];
placeholder?: string;
}
const Select = forwardRef<HTMLSelectElement, SelectProps>(
({ className = '', label, error, options, id, placeholder = 'Bitte wählen...', ...props }, ref) => {
const selectId = id || props.name;
// Wenn keine Breitenklasse in className, dann w-full als Standard
const hasWidthClass = /\bw-\d+\b|\bw-\[|\bflex-/.test(className);
return (
<div className={hasWidthClass ? className : 'w-full'}>
{label && (
<label htmlFor={selectId} className="block text-sm font-medium text-gray-700 mb-1">
{label}
</label>
)}
<select
ref={ref}
id={selectId}
className={`block w-full px-3 py-2 border rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 ${
error ? 'border-red-500' : 'border-gray-300'
}`}
{...props}
>
<option value="">{placeholder}</option>
{options.map((opt) => (
<option key={opt.value} value={opt.value}>
{opt.label}
</option>
))}
</select>
{error && <p className="mt-1 text-sm text-red-600">{error}</p>}
</div>
);
}
);
Select.displayName = 'Select';
export default Select;