SEAM’s form layer is built around a single composable pattern: aDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/TheSerchCp/SEAM/llms.txt
Use this file to discover all available pages before exploring further.
fields array drives Form, which delegates each entry to the correct low-level component (InputField, SelectField, or TextareaField). Every component returns an HTML string. Validation is handled separately by FormValidator, a class that binds to a rendered form element by ID and applies a declarative schema on each user interaction.
Form
Form accepts an id, a fields array, and an optional actions HTML string for submit/cancel buttons. It inspects each field’s type property and routes rendering to the appropriate sub-component.
Supported field types
type value | Rendered as |
|---|---|
text | InputField with type="text" |
email | InputField with type="email" |
password | InputField with type="password" |
number | InputField with type="number" |
date | InputField with type="date" |
select | SelectField |
textarea | TextareaField |
Props
The
id attribute written onto the <form> element. Used by FormValidator and FormData to reference the form.Array of field descriptor objects. Each object is spread directly into the corresponding sub-component, so any prop accepted by
InputField, SelectField, or TextareaField can be placed here alongside the required type key.Optional HTML string rendered inside a flex column container below the fields. Typically contains a submit button.
Real-world example — Add User form (from users.page.js)
The following fields array is passed directly to FormModal, which internally calls Form:
InputField
InputField renders a single <input> element with a label, success/error state icons, and an inline error message container. All visual states are driven entirely by props — no JavaScript is needed to switch states at render time.
Props
HTML input type. Any value accepted by the
<input type> attribute is valid (text, email, password, number, date, etc.).Written to both the
id and name attributes of the <input>. Also used to derive the IDs of the error and icon elements ({name}-error, {name}-error-icon, {name}-success-icon).Text shown in the
<label> element above the input. If empty, no label is rendered.Placeholder text passed directly to the
<input>.Pre-filled value for edit forms.
Adds the HTML
required attribute and renders a red asterisk next to the label.Adds the HTML
disabled attribute and applies muted styling.When
true, reserves space for an error message paragraph (<p id="{name}-error">) and the icon slots. Set this whenever the field will be managed by FormValidator.If non-empty, immediately renders the field in error state with the border tinted red and the error message visible.
If
true (and no error is present), renders the field with an emerald border and a check icon.Usage
SelectField
SelectField renders a fully custom dropdown that replaces the native <select>. It stores the chosen value in a hidden <input> so FormData and FormValidator work without any special handling. Both single and multi-select modes are supported.
After injecting
SelectField HTML into the DOM you must call initSelectFields() to activate the dropdown logic. FormModal and ComponentInitializer both do this automatically.Props
Written to the hidden
<input name> attribute and used to derive all element IDs.Text shown above the trigger button.
Array of
{ value: string | number, label: string } objects that populate the dropdown list.Pre-selected value(s). Pass a comma-separated string or an array when
multiple is true.Text shown in the trigger button when nothing is selected.
Enables multi-select mode. Selected items are displayed as dismissible badges below the trigger. The hidden input stores values as a comma-separated string.
Adds
required to the hidden input and renders a red asterisk next to the label.Disables the trigger button.
Reserves space for an inline error message. Required when
FormValidator manages the field.Immediately renders the field in error state.
Extra CSS classes added to the outermost wrapper
<div>.Global helpers
Two functions are exposed onwindow for programmatic error management:
TextareaField
TextareaField renders a resizable <textarea> with label, inline validation, and an optional live character counter.
Props
Written to both the
id and name attributes of the <textarea>.Text shown in the
<label> element above the textarea.Placeholder text.
Pre-filled content for edit forms.
Number of visible text rows.
Adds the HTML
required attribute and a red asterisk.Disables the textarea.
Reserves the error message slot for
FormValidator integration.Immediately renders an error state.
Adds the HTML
maxlength attribute and automatically enables the character counter.Forces the character counter to appear even without a
maxLength.The character counter is updated by a single delegated
input listener registered once on document. It looks for a [data-char-count-for="{name}"] element and updates its text on every keystroke.FormValidator
FormValidator is a class that binds to a rendered <form> element and validates its fields against a declarative schema. It reacts to input and focusout events, writes inline error messages to the DOM, and can toggle a submit button’s disabled state automatically.
Constructor
The
id attribute of the <form> element to bind to.A map of field names to rule objects. See Schema rules below.
The
id of a submit button. When provided, FormValidator keeps the button disabled until every field in the schema passes validation.Validate a field every time its value changes.
Validate a field when it loses focus.
Suffix appended to a field’s
name to locate its error <p> element in the DOM (e.g. email → email-error).Methods
Binds event listeners to the form. Call this once after the form HTML has been injected into the DOM. Calling it again on the same instance is a no-op.
Imperatively validates all fields in the schema, writes error messages for any that fail, and returns
true if the entire form is valid.Clears all inline error messages without validating.
Schema rules
Each field name maps to a rules object. Rules are evaluated in declaration order and validation stops at the first failure.| Rule | Parameter | Description |
|---|---|---|
required | true | Field must be non-empty after trimming. |
minLength | number | Trimmed length must be at least n characters. |
maxLength | number | Trimmed length must be at most n characters. |
email | true | Must match /^[^\s@]+@[^\s@]+\.[^\s@]+$/. |
password | true | Min 8 chars, at least one uppercase, one lowercase, one digit. |
text | true | Only letters, spaces, accents, and ñ/Ñ. |
match | "fieldName" | Value must equal the value of the named sibling field (e.g. confirm-password). |
custom | (val, formData) => true | string | Arbitrary function; return true for valid or an error string. |
Real-world example — USER_SCHEMA from users.page.js
custom rule so that confirmPassword is only required when a new password has been entered:
Attaching the validator manually
Validators (primitives)
The three low-level validators used byFormValidator are also exported for direct use:
ComponentInitializer
A thin utility that callsinitSelectFields() after a delay, ensuring any SelectField elements that were just rendered into the DOM are properly activated.