@bpmn-io/form-js

中文文档
2.2.0发布于 2026/11/06SEE LICENSE IN LICENSETypeScriptESM + CJS近 30 天下载 5.7万

View and edit forms - powered by bpmn.io

原始使用文档
文档目录7 节
  1. Usage
  2. Display a form
  3. Create and edit a form
  4. Create and simulate a form with input and output data
  5. Retrieve schema variables from a form
  6. Resources
  7. License

@bpmn-io/form-js

CI

View, edit and simulate JSON-based forms.

Usage

This library exports a form viewer, editor and playground.

Display a form

Renders a form based on a form schema and existing data:

import { Form } from '@bpmn-io/form-js';

const schema = {
  type: 'default',
  components: [
    {
      key: 'creditor',
      label: 'Creditor',
      type: 'textfield',
      validate: {
        required: true,
      },
    },
  ],
};

const data = {
  creditor: 'John Doe Company',
};

const form = new Form({
  container: document.querySelector('#form'),
});

await form.importSchema(schema, data);

form.on('submit', (event) => {
  console.log(event.data, event.errors);
});

See viewer documentation for further details.

Create and edit a form

Create a new form or edit an exsting one:

import { FormEditor } from '@bpmn-io/form-js';

const formEditor = new FormEditor({
  container: document.querySelector('#form-editor'),
});

await formEditor.importSchema(schema);

See editor documentation for further details.

Create and simulate a form with input and output data

Create and simulate a form with input and output data:

import { FormPlayground } from '@bpmn-io/form-js';

const schema = {
  type: 'default',
  components: [
    {
      key: 'creditor',
      label: 'Creditor',
      type: 'textfield',
      validate: {
        required: true,
      },
    },
  ],
};

const data = {
  creditor: 'John Doe Company',
};

const formPlayground = new FormPlayground({
  container: document.querySelector('#form-playground'),
  schema,
  data,
});

See playground documentation for further details.

Retrieve schema variables from a form

Use the getSchemaVariables util to retrieve the variables defined in a form schema. This is useful to gather what data is consumed and produced by a form.

import { getSchemaVariables } from '@bpmn-io/form-js';

const variables = getSchemaVariables(schema);

console.log('Schema variables', variables);

It is also possible to distinct between input and output variables:

import { getSchemaVariables } from '@bpmn-io/form-js';

const outputVariables = getSchemaVariables(schema, { inputs: false });
const inputVariables = getSchemaVariables(schema, { outputs: false });

Resources

License

Use under the terms of the bpmn.io license.

版本与发布记录

@bpmn-io/form-js 共发布 146 个版本,首次发布于 2021/02/24;过去 12 个月发布了 23 个版本。

版本发布日期距今
2.2.0latest2026/11/062 天前
2.1.12026/10/011 个月前
2.1.02026/09/281 个月前
2.0.22026/09/281 个月前
2.0.12026/09/251 个月前
2.0.02026/09/181 个月前

其他发布通道:backports → 1.15.5,alpha → 2.0.0-alpha.0。

关于 @bpmn-io/form-js 的常见问题

@bpmn-io/form-js 是什么?

View and edit forms - powered by bpmn.io

如何安装 @bpmn-io/form-js?

在项目目录运行 npm install @bpmn-io/form-js,或使用 pnpm add / yarn add / bun add。

@bpmn-io/form-js 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@bpmn-io/form-js 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@bpmn-io/form-js 可以商用吗?

@bpmn-io/form-js 使用 SEE LICENSE IN LICENSE 许可。许可条款写在包内的独立文件中,请阅读该文件确认可否商用。以上为概括,不构成法律意见,请以许可原文为准。

@bpmn-io/form-js 的下载量有多少?

根据 npm 官方下载统计,@bpmn-io/form-js 在 2026/10/09 – 2026/11/07 这 30 天内被下载 57,197 次,日均约 1,907 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@bpmn-io/form-js 还在维护吗?

最新版本 2.2.0 发布于 2026/11/06(2 天前);至今共发布 146 个版本,其中过去 12 个月发布了 23 个;首次发布于 2021/02/24。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。