Quick start

The engine has zero runtime dependencies — no antd, no form library. It holds the values itself. To swap in your own UI library, you only need to touch one file: src/engine/fields/registry.tsx.

npm install
npm run dev        # open the Playground
npm run test:unit  # 44 pure-logic unit tests
npm run build      # type check + production build

A minimal working example

This one schema already shows three things: a required text field, a switch, and a field that only appears when the switch is on and must then be filled in.

import { DynamicForm, useFormEngine } from './engine';

const schema = {
  title: '最小示例',
  nodes: [
    { name: 'name', widget: 'text', title: '姓名',
      rules: { required: true, maxLength: 20 } },
    { name: 'married', widget: 'switch', title: '已婚',
      defaultValue: false },
    { name: 'spouseName', widget: 'text', title: '配偶姓名',
      visibleWhen: { field: 'married', op: 'truthy' },
      rules: { required: true } },
  ],
};

function Demo() {
  const form = useFormEngine(schema);
  return (
    <DynamicForm
      schema={schema}
      values={form.values}
      errors={form.errors}
      onChange={form.handleChange}
      onFieldBlur={form.handleFieldBlur}
    />
  );
}

Look at the visibleWhen on spouseName: when the switch is off, the field isn't just hidden — it's skipped by validation and left out of the submit payload.