UpdateButton
Patches the current record with a fixed data payload. mutationMode defaults to undoable.
Installation
pnpm dlx shadcn@latest add @chelone/update-buttonPatches the current record with a fixed data payload. mutationMode defaults to undoable.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| className | string | — | |
| confirmColor | "primary" | "warning" | — | |
| confirmContent | ReactNode | — | |
| confirmTitle | ReactNode | — | |
| contentTranslateOptions | object | — | |
| data | Partial<LooseRecord> | — | The fields to patch onto the record. |
| icon | ReactNode | — | |
| label | string | — | |
| mutationMode | MutationMode | — | `"undoable"` (default) patches the record now with an Undo notification and no dialog; the server call is deferred until the Undo window closes. `"pessimistic"` and `"optimistic"` ask for confirmation first, and `"optimistic"` closes the dialog on confirm. |
| onClick | MouseEventHandler<HTMLButtonElement> | — | |
| onError | (error: unknown) => void | — | Receives the error of a failed confirmed update. |
| onSuccess | (data: LooseRecord) => void | — | Receives the updated record. Runs only for a confirmed update, not for an undoable one. |
| record | LooseRecord | — | |
| ref | Ref<HTMLButtonElement> | — | |
| resource | string | — | |
| titleTranslateOptions | object | — | |
| variant | "link" | "default" | "destructive" | "outline" | "secondary" | "ghost" | — |