Open History to see the last commit
1import { useCommitOnBlur } from "~/hooks/useCommitOnBlur";
2import { Input, type InputProps } from "./input";
3
4export type DraftInputProps = Omit<InputProps, "value" | "onChange" | "defaultValue"> & {
5 readonly value: string;
6 readonly onCommit: (next: string) => void;
7 readonly normalizeDraft?: (previous: string, next: string) => string;
8};
9
10/** Commit drafts without settings-wide rerenders or server round trips per keystroke. */
11export function DraftInput({ value, onCommit, normalizeDraft, ...rest }: DraftInputProps) {
12 const bag = useCommitOnBlur(value, onCommit, normalizeDraft);
13 return <Input {...rest} {...bag} />;
14}