Packages

React inside Phoenix LiveView — async code splitting, client-side props diffing, and zero-config component discovery.

Retired package: Release invalid - Not production-ready, LiveView 1.0.x compatibility issue

Current section

Files

Jump to
react_phx assets dist useLiveForm.d.ts
Raw

assets/dist/useLiveForm.d.ts

export interface FormField {
value: any;
errors: string[];
errorMessage: string | undefined;
isDirty: boolean;
isTouched: boolean;
inputProps: {
name: string;
id: string;
value: any;
checked?: boolean;
onChange: (e: React.ChangeEvent<HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement>) => void;
onBlur: () => void;
"aria-invalid": boolean;
};
}
export interface UseLiveFormReturn {
field: (path: string) => FormField;
submit: () => void;
isDirty: boolean;
isValid: boolean;
}
interface ServerForm {
id: string;
name: string;
action: string | null;
errors: Record<string, string[]>;
data: Record<string, any>;
params?: Record<string, any>;
fields: string[];
}
/**
* Build a Phoenix-style nested form field name.
*
* Examples:
* buildFieldName("user", "email") => "user[email]"
* buildFieldName("user", "profile.email") => "user[profile][email]"
* buildFieldName("user", "tags[0]") => "user[tags][0]"
*/
export declare function buildFieldName(formName: string, path: string): string;
/**
* Build a form field ID from the form ID and a dotted/bracketed path.
*
* Examples:
* buildFieldId("user", "email") => "user_email"
* buildFieldId("user", "profile.email") => "user_profile_email"
* buildFieldId("user", "tags[0]") => "user_tags_0"
*/
export declare function buildFieldId(formId: string, path: string): string;
export declare function useLiveForm(serverForm: ServerForm, options?: {
changeEvent?: string;
submitEvent?: string;
}): UseLiveFormReturn;
export {};