UNPKG

trellis

Version:

Agentic State Engine — event-sourced causal graph with branching, decision traces, and realtime sync for AI-native applications

34 lines 1.62 kB
/** * Trellis Forms Vanilla — framework-free bindings + DOM glue. * * Import from `trellis/forms/vanilla`: * * const form = createVanillaForm(taskDescriptor); * const unbind = bindFormToDOM(form, document.querySelector('form'), { * title: '[name="title"]', * }, async (values) => createEntity(type, values)); * * @module trellis/forms/vanilla */ import type { AnyType } from '../../schema/define.js'; import type { FormDescriptor } from '../types.js'; import { type FieldBinding, type UseFormReturn } from '../core/index.js'; import type { FormState, FormValues } from '../core/types.js'; export type FormSchemaInput = AnyType | FormDescriptor; export interface VanillaForm extends UseFormReturn { field: (name: string) => FieldBinding; subscribe: (listener: (state: FormState) => void) => () => void; } /** Create a framework-free form core with a state-subscription surface. */ export declare function createVanillaForm(schema: FormSchemaInput, initialValues?: FormValues): VanillaForm; export interface DomBindOptions { /** Attribute name for per-field error text (`data-error-for="{name}"`). */ errorAttribute?: string; } /** * Bind a vanilla form to real DOM: two-way value sync via `input`/`blur`, * submit handling with validation, and error text rendered into * `[data-error-for]` elements. Returns an unbind function. */ export declare function bindFormToDOM(form: VanillaForm, formElement: HTMLFormElement, fieldSelectors: Record<string, string>, onSubmit?: (values: FormValues) => Promise<void>, options?: DomBindOptions): () => void; //# sourceMappingURL=index.d.ts.map