(props: ButtonProps & { children?: ReactNode })
| 301 | type ButtonProps = React.ComponentProps<"button"> & VariantProps<typeof buttonVariants>; |
| 302 | |
| 303 | function SubmitButton(props: ButtonProps & { children?: ReactNode }) { |
| 304 | const { state, meta, actions } = useSecretForm(); |
| 305 | const { children, disabled, onClick, ...rest } = props; |
| 306 | const submitting = state.status.kind === "submitting"; |
| 307 | return ( |
| 308 | <Button |
| 309 | {...rest} |
| 310 | onClick={(e) => { |
| 311 | onClick?.(e); |
| 312 | if (!e.defaultPrevented) void actions.submit(); |
| 313 | }} |
| 314 | disabled={disabled || !meta.canSubmit} |
| 315 | > |
| 316 | {submitting ? "Saving…" : children} |
| 317 | </Button> |
| 318 | ); |
| 319 | } |
| 320 | |
| 321 | // --------------------------------------------------------------------------- |
| 322 | // Reveal-eye icon (used by ValueField when `revealable`) |
nothing calls this directly
no test coverage detected