@texuli/forms
v0.18.0
Published
Schema-driven forms for Texuli: a closed form schema rendered with texuli components, multi-step flows, conditional logic on @texuli/core/expression, announced validation, drafts and autosave.
Maintainers
Readme
@texuli/forms
Schema-driven forms for Texuli, an MIT-licensed
Svelte 5 component library by Dailybot, Inc. (Small pieces. Infinite
possibilities.). A closed form schema (typed fields, sections, multi-step
flows, conditional logic and validation rules) becomes an accessible form
painted with texuli controls, with announced errors, drafts and autosave.
Agents emit the same schema as data through the catalog's schema-form id:
formats and validators are names, conditions are expressions of the closed
language in @texuli/core/expression, and no schema carries a regular
expression or code.
In the stack: layer L4, a domain package on the @texuli/core texels (the expression language) and the texuli components. The player paints it through its formHost seam.
Status: in development (pre-1.0).
@texuli/formsis published on npm as0.18.0, with provenance (first published as0.8.0; built in PLAN_010, ADR-015 in DECISIONS). Under 0.x a new minor (0.18.0) may contain breaking changes, so pin the exact version or use^0.18.0, which accepts only 0.18.x (see RELEASE).
It sits on layer L4 and depends on texuli and @texuli/core; svelte
(^5.57.2) is a peer dependency. The model (@texuli/forms/model) is
framework-free.
Install
npm install @texuli/formsIn the Texuli workspace, depend on it as "@texuli/forms": "workspace:*".
Import the token stylesheet once
(@texuli/tokens/base.css); SchemaForm imports its own CSS.
Quick start
<script lang="ts">
import { SchemaForm, validateFormSchema } from '@texuli/forms';
const result = validateFormSchema({
title: 'Request access',
submitLabel: 'Send request',
fields: [
{ name: 'email', type: 'email', label: 'Work email', required: true },
{
name: 'team',
type: 'select',
label: 'Team',
options: [
{ value: 'design', label: 'Design' },
{ value: 'engineering', label: 'Engineering' },
],
},
{
name: 'reason',
type: 'textarea',
label: 'Why do you need access?',
when: {
require: { op: 'eq', left: { op: 'field', name: 'team' }, right: { op: 'str', value: 'engineering' } },
},
},
],
});
</script>
{#if result.ok}
<SchemaForm form={result.form} onSubmit={async ({ values }) => ({ ok: true })} />
{/if}What's inside
| Subpath | What it holds | Docs |
| --- | --- | --- |
| . | SchemaForm, DEFAULT_SCHEMA_FORM_LABELS, the model's main entry points and FORMS_PACKAGE_VERSION | SchemaForm |
| ./model | The framework-free runtime: validateFormSchema, named formats, computeFormLogic, validateFormValues, createFormController, drafts | Model |
| ./controls | The static control registry (SCHEMA_FORM_CONTROLS) for server rendering; without it SchemaForm loads per-type controls on first use | Controls |
| ./builder | FormBuilder, a visual builder (palette, canvas with keyboard and pointer reorder, inspector, live preview, schema JSON), and its framework-free list helpers | Builder |
| ./host | The formHost adapter for @texuli/player (createFormPlayerHost) and the draft check | Host |
| ./styles.css | The layout stylesheet and its hooks | Styles |
Field types and rules
Fields: text, textarea, number, email, url (https, or http where the field
allows it), date, time, datetime, select (clearable while optional),
multiselect, checkbox, radio, switch, slider, file (the host uploads), tags,
color, password and otp (credential fields: kept out of drafts, and opt-in
for agent output) and custom (painted by the host, validated and submitted
with the rest). Date, time, datetime, slider, tags, file, color and radio
controls load per type on first use, with a static registry for server
rendering. Rules:
required, minLength and maxLength, min and max, step, minItems and
maxItems, a named format (email, url, phone, postal codes, digits, slug,
ISO dates, times, hex colors), a host validator by name (sync or async),
and cross-field rules as expressions. when.show, when.require and
when.enable are expressions over earlier fields; hidden and disabled
fields are neither validated nor submitted.
Accessibility
A named form landmark; every control is a texuli control with a visible
label, its description and its error linked (the Field rule); errors are
announced, an error summary takes focus and links to each field; each step
heading takes focus and is announced; the form is keyboard-complete; step
transitions go through texuli/motion and are instant under reduced
motion. The view test runs axe name and ARIA rules over every field type.
Security
Schemas from agents are validated at the untrusted tier: closed members,
named formats only (no agent regular expressions, so no backtracking),
help links through the URL policy, text as text (no HTML sinks), and
expressions that are closed data evaluated within the ADR-015 step limits.
Restored drafts are coerced field by field like any untrusted input.
Learn more
- SchemaForm
- Model
- Styles
- Builder
- Host
- Controls
- The expression language: core-expression
- Forms in blueprints (the
schema-formcatalog id, spec 0.8.0), painted by the player throughformHost:@texuli/catalog - Decisions: ADR-015 (one bounded expression language) and ADR-012 (spec evolution) in DECISIONS
- Source: github.com/DailybotHQ/texuli · Issues: github.com/DailybotHQ/texuli/issues
Contributing
Contributions are welcome; start at the GitHub repository.
License
MIT © Dailybot, Inc. Powered by Dailybot.
