Nasaq
Components

SchemaRepeater

A Repeater whose rows are generated from a field schema (text, number, select, switch, date, nested repeater) with built-in validation in English and Arabic.

PreviewOpen ↗

Code

const fields: SchemaField[] = [  { key: "name", type: "text", label: "Name", required: true, width: "half" },  { key: "qty", type: "number", label: "Quantity", min: 1, integer: true, width: "half" },  { key: "kind", type: "select", label: "Kind", options: [{ value: "a", label: "A" }] },];<SchemaRepeater fields={fields} label="Items" titleKey="name" min={1} max={10} onValidate={(r) => setValid(r.valid)} />

Form Builders · beta

Live examples and controls: SchemaRepeater in the lab.

Install

npx shadcn@latest add https://docs.nasaqui.com/r/schema-repeater.json

Describe a row as a list of fields and get a full add / remove / duplicate / reorder / collapse form, with validation. The value is plain JSON, the same shape you validate on the server (validateRows is exported and has no React dependency).

When to use

  • Line items, contacts, rules, hosts: rows of standard inputs.

When not to use

  • Rows with custom layout or components: use Repeater.

Import

import { SchemaRepeater, type SchemaField } from "@fadymondy/nasaq/web";

Quick start

const fields: SchemaField[] = [
  { key: "name", type: "text", label: "Name", required: true, width: "half" },
  { key: "qty", type: "number", label: "Quantity", min: 1, integer: true, width: "half" },
  { key: "kind", type: "select", label: "Kind", options: [{ value: "a", label: "A" }] },
];

<SchemaRepeater fields={fields} label="Items" titleKey="name" min={1} max={10} onValidate={(r) => setValid(r.valid)} />

Field types

typevaluenotable options
textstringinputType, multiline, ltr, minLength, maxLength, pattern, patternMessage
numbernumber | nullmin, max, step, integer, unit
selectstring | nulloptions, placeholder
switchboolean
dateISO YYYY-MM-DD | nullmin, max
repeaterSchemaRow[]fields, min, max, titleKey, addLabel (nested, any depth)

All fields accept key, label, description, required, width ("full" or "half"), hidden(row) and validate(value, row).

API

PropTypeDescription
fieldsSchemaField[]The row schema.
value, defaultValue, onValueChangeSchemaRow[]The rows.
min, max, label, titleKey, rowTitleLimits and row headings.
showErrorsbooleanReveal every error (after a failed submit). Otherwise a field shows its error once edited.
errorsRowErrors[]Server errors by row and field key.
onValidate(SchemaValidation) => voidCalled when the issue count or list message changes.
messages, labelsOverride validation messages and repeater strings.
reorderable, duplicable, collapsible, defaultCollapsed, disabled, addLabel, emptyPassed to Repeater.

Accessibility

Errors render in FieldError tied to the input; the row header shows an issue count badge; the row-count message is role="alert".

RTL

Built-in messages have Arabic text. Email, URL, tel and ltr text inputs stay left-to-right.

On this page