feat(renderer): add shadcn input primitive

This commit is contained in:
2026-06-05 17:06:36 +05:30
parent d22d616727
commit 66e2b56221
2 changed files with 39 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
import * as React from "react"
import { cn } from "@/lib/utils"
export interface InputProps
extends React.InputHTMLAttributes<HTMLInputElement> {}
const Input = React.forwardRef<HTMLInputElement, InputProps>(
({ className, type, ...props }, ref) => {
return (
<input
type={type}
className={cn(
"h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
className
)}
ref={ref}
{...props}
/>
)
}
)
Input.displayName = "Input"
export { Input }
+14
View File
@@ -0,0 +1,14 @@
import { describe, it, expect, vi } from 'vitest';
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { Input } from '@/components/ui/input';
describe('Input', () => {
it('renders and accepts typing', async () => {
const onChange = vi.fn();
render(<Input aria-label="name" onChange={onChange} />);
const input = screen.getByLabelText(/name/i);
await userEvent.type(input, 'a');
expect(onChange).toHaveBeenCalled();
});
});