import type { ComponentType, ReactNode } from "react"; import type { FormStateAdapter } from "../props/components/form.prop.js"; import type { SidebarLinkComponentProp } from "../props/components/layout.prop.js"; /** Structural shape of Inertia's `useForm` return that the adapter needs. */ export interface InertiaFormLike = Record> { /** Current form values (server-driven state). */ data: TData; /** Write a single field back (Inertia signature: `setData(key, value)`). */ setData(key: string, value: unknown): void; /** Server (Laravel FormRequest) validation errors, keyed by field name. */ errors: Partial>; /** True while a submit request is in flight. */ processing: boolean; reset?(): void; } /** * Wrap an Inertia `useForm()` object as a framework-agnostic {@link FormStateAdapter} so it drives * `FormRoot`/`FormFieldControl` with the SAME auto-binding as the react-hook-form path — no manual * `value`/`onChange`/`error`/`aria-invalid` per field, and `processing` flows to submit-button * loading via `useFormSubmitting()`. Server errors in `form.errors` surface on the matching * `FormFieldControl` and clear on correction (Inertia clears the error on `setData`). * * @example * ```tsx * import { FormRoot, FormFieldControl, useFormSubmitting } from "@godxjp/ui/form"; * import { inertiaAdapter } from "@godxjp/ui/inertia"; * import { useForm } from "@inertiajs/react"; * * const form = useForm({ email: "", password: "" }); * return ( * form.post("/login")}> * * {(field) => } * * * * ); * ``` */ export declare function inertiaAdapter>(form: InertiaFormLike): FormStateAdapter; /** * Lighter helper for consumers who compose `FormField` by hand rather than `FormRoot`. Returns the * exact props to spread onto a `FormField` + its control — `value`, `onChange`, `error`, `name` — * so no field is hand-wired. Use `inertiaAdapter` + `FormRoot` for the full auto-binding instead. * * @example * ```tsx * const form = useForm({ email: "" }); * const email = useInertiaField(form, "email"); * * * * ``` */ export declare function useInertiaField>(form: InertiaFormLike, name: string): { name: string; value: unknown; error: string | undefined; onChange: (event: { target: { value: unknown; }; }) => void; }; /** Structural shape of Inertia's `` that the Sidebar adapter needs. */ export interface InertiaLinkLike { href: string; className?: string; children?: ReactNode; } /** * Bind Inertia's `` as the Sidebar's row element. * * The LIBRARY still composes every row — the 16px icon slot, the label, the badge, `data-active` / * `aria-current`, the icon-only collapsed rail and its tooltip name — and hands it to the link as * `children`. The consumer supplies ONLY the element, so the class of production regression where a * consumer `renderItem` returned `{item.label}` and silently dropped every sidebar icon * is no longer expressible. * * A disabled row has no destination; Inertia's `Link` requires a string `href` and would visit `""`, * so the adapter renders an inert `` for that case while keeping the canonical row class and * `aria-disabled`. * * React Router / TanStack Router use `to` instead of `href` — use * `createSidebarLink(Link, "to")` from `@godxjp/ui/layout` for those. * * @example * ```tsx * import { Link } from "@inertiajs/react"; * import { Sidebar } from "@godxjp/ui/layout"; * import { inertiaSidebarLink } from "@godxjp/ui/inertia"; * * const NavLink = inertiaSidebarLink(Link); * * {unread} }, * ] }, * ]} * />; * ``` */ export declare function inertiaSidebarLink

(Link: ComponentType

): SidebarLinkComponentProp; /** Visit callbacks needed to connect Upload to an Inertia multipart endpoint. */ export interface InertiaUploadCallbacks { forceFormData: true; async: true; onProgress: (progress: { percentage?: number; } | undefined) => void; onSuccess: () => void; onError: (errors: Record) => void; onCancelToken: (token: { cancel: () => void; }) => void; onCancel: () => void; onNetworkError: (error: Error) => boolean; onHttpException: () => boolean; onFinish: () => void; } /** Bridge redirect-based Inertia uploads to Upload's progress/abort/retry lifecycle. */ export declare function inertiaUpload(send: (file: File, callbacks: InertiaUploadCallbacks) => void, errorMessage: string): NonNullable;