Files
workshop-manager/src/components/ui/InlineAddItem.tsx
Froidefond Julien db7a0cef96
All checks were successful
Deploy with Docker Compose / deploy (push) Successful in 2m57s
refactor(ui): unify low-level controls and expand design system
2026-03-03 15:50:15 +01:00

60 lines
1.5 KiB
TypeScript

import { ReactNode } from 'react';
import { InlineFormActions } from './InlineFormActions';
interface InlineAddItemProps {
value: string;
onChange: (value: string) => void;
onSubmit: () => void;
onCancel: () => void;
isPending: boolean;
placeholder?: string;
rows?: number;
extra?: ReactNode;
submitColorClass?: string;
className?: string;
}
export function InlineAddItem({
value,
onChange,
onSubmit,
onCancel,
isPending,
placeholder,
rows = 2,
extra,
submitColorClass,
className = '',
}: InlineAddItemProps) {
return (
<div className={`rounded-lg border border-border bg-card p-2 shadow-sm ${className}`}>
<textarea
autoFocus
value={value}
onChange={(e) => onChange(e.target.value)}
onKeyDown={(e) => {
if (e.key === 'Enter' && !e.shiftKey) {
e.preventDefault();
onSubmit();
} else if (e.key === 'Escape') {
onCancel();
}
}}
placeholder={placeholder}
className="w-full resize-none rounded border-0 bg-transparent p-1 text-sm text-foreground placeholder:text-muted focus:outline-none focus:ring-0"
rows={rows}
disabled={isPending}
/>
{extra}
<InlineFormActions
onCancel={onCancel}
onSubmit={onSubmit}
isPending={isPending}
disabled={!value.trim()}
submitColorClass={submitColorClass}
className="mt-1"
/>
</div>
);
}