- Backend (NestJS): 82 suites, 641 tests passing; 0 ESLint errors; 0 tsc errors. Hardened SSL cert/key matching, SSRF IP pinning, and eBank validation. - Admin Panel (Vite/React): 48 suites, 300 tests passing; 0 ESLint errors; 0 tsc errors. Full coverage across all pages and settings. - Storefront (Next.js): 62 suites, 368 tests passing; 0 ESLint errors; 0 tsc errors. - Fixed unmount lifecycle guards, promise error handling, and component edge cases.
53 lines
1.8 KiB
TypeScript
53 lines
1.8 KiB
TypeScript
import { ChevronDown } from 'lucide-react';
|
|
import React,{ forwardRef } from 'react';
|
|
|
|
export interface SelectOption {
|
|
value: string | number;
|
|
label: string;
|
|
disabled?: boolean;
|
|
}
|
|
|
|
export interface SelectProps extends React.SelectHTMLAttributes<HTMLSelectElement> {
|
|
options?: SelectOption[];
|
|
error?: string;
|
|
children?: React.ReactNode;
|
|
}
|
|
|
|
export const Select = forwardRef<HTMLSelectElement, SelectProps>(
|
|
({ className = '', error, options, children, disabled, ...props }, ref) => {
|
|
return (
|
|
<div className="w-full relative font-vazir">
|
|
<select
|
|
ref={ref}
|
|
disabled={disabled}
|
|
className={`w-full bg-white border font-vazir text-sm transition-all duration-200 outline-none appearance-none pr-4 pl-10 py-2.5 rounded-xl shadow-xs cursor-pointer
|
|
${error ? 'border-red-400 focus:border-red-500 focus:ring-2 focus:ring-red-500/20' : 'border-gray-200 focus:border-purple-500 focus:ring-2 focus:ring-purple-500/20'}
|
|
${disabled ? 'bg-gray-50 text-gray-400 cursor-not-allowed border-gray-200' : 'text-gray-900 hover:border-gray-300'}
|
|
${className}`}
|
|
{...props}
|
|
>
|
|
{options
|
|
? options.map((opt) => (
|
|
<option key={opt.value} value={opt.value} disabled={opt.disabled}>
|
|
{opt.label}
|
|
</option>
|
|
))
|
|
: children}
|
|
</select>
|
|
<div className="absolute left-3.5 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none">
|
|
<ChevronDown className="w-4 h-4" />
|
|
</div>
|
|
{error && (
|
|
<p className="mt-1 text-xs text-red-500 font-medium flex items-center gap-1 animate-in fade-in duration-200">
|
|
<span>•</span>
|
|
{error}
|
|
</p>
|
|
)}
|
|
</div>
|
|
);
|
|
}
|
|
);
|
|
|
|
Select.displayName = 'Select';
|
|
export default Select;
|