UNPKG

@mitcsutt/kiln-forms

Version:

Kiln forms: typed React forms on TanStack Form, in component or JSON schema mode, rendered through kiln-ui

34 lines (33 loc) • 1.74 kB
import { type ButtonProps } from '@mitcsutt/kiln-ui'; import { type AnyKitForm } from '../../../runtime/formRuntime.js'; export interface SubmitButtonProps extends Omit<ButtonProps, 'type' | 'form' | 'asChild' | 'loading' | 'disabled'> { /** Defaults to the form in context. Required for a button outside `<Form>`. */ form?: AnyKitForm; /** The `id` of the `<Form>` to submit from outside it (native `form` attribute). */ formId?: string; /** Stays `aria-disabled` (with a spoken reason) until something changed. */ requireChanges?: boolean; /** Meta passed to `onSubmit` for this button (`form.handleSubmit(meta)`). */ submitMeta?: unknown; } /** * Submits the form. Never disabled, so everyone can reach it and hear why it's waiting. * * @remarks * `SubmitButton` is a `Button` with `type="submit"` that knows the form's state. It shows a * spinner while submitting. It's **never `disabled`**: when it can't act (while submitting, after * a locking submit, or with `requireChanges` before anything has changed) it's `aria-disabled`, * ignores presses, and carries a visually hidden reason. A disabled button can't be focused, so * keyboard and screen reader users would never find out why they can't go on. * * @example In a schema * ```json * { "content": "submit", "label": "Book ticket" } * ``` * * @privateRemarks * The submit button. **Never `disabled`** (§11.6): while submitting, locked, or blocked by * `requireChanges` it is `aria-disabled` and ignores clicks; an invalid form still submits so * errors show and focus moves. */ export declare const SubmitButton: import("react").ForwardRefExoticComponent<SubmitButtonProps & import("react").RefAttributes<HTMLButtonElement>>;