@haneinfo/form

中文文档
0.7.1发布于 2026/11/17UNLICENSEDTypeScriptCommonJS近 30 天下载 5717

Dynamic structure mechanism: Form definitions (kind Form) with fields, conditions, formulas and subforms, registered with @haneinfo/definition-registry.

原始使用文档
文档目录3 节
  1. Date comparisons
  2. Draft validation (draft 202610-8b3e)
  3. Localized labels (draft 202610-a8d3)

Date comparisons

GT/GTE/LT/LTE compare numbers, valid calendar dates (YYYY-MM-DD), or timezone-qualified datetimes (YYYY-MM-DDTHH:mm:ss with optional fractional seconds and Z or +/-HH:mm). Both operands must have the same category. Dates use calendar order; datetimes compare UTC instants at millisecond precision. Invalid dates, mixed categories and empty operands yield false. EQ/NEQ/IN retain strict scalar equality; matching instants with different textual offsets are still unequal for those operators.

Draft validation (draft 202610-8b3e)

Implemented from draft decision 202610-8b3e; the decision remains draft. fillForm(spec, values, { requireRequired: false }) skips only required checks. Omission or true retains full validation. The registered Form prepareData accepts the same optional plugin-api PrepareDataOptions; upgrade Form, definition-registry (which forwards it), state-machine and plugin-api contract 1.18.0 together. Visible required fields, dynamically enabled required fields and required subform columns all follow the option. Form has no separate requiredWhen declaration: conditional required behavior uses required with visibleWhen/disabledWhen. Type, option, numeric/row bounds, patterns, dates, formula evaluation and conditional visibility retain their existing checks. test_fill_form keeps full validation and gains no client draft parameter. State-machine selects draft mode only for INITIAL data edits, while every transition validates required fields. No schema or widget changes.

Localized labels (draft 202610-a8d3)

Draft implementation; the decision remains draft. Field label, description and option label (at every depth, subform columns included) accept a plain string, unchanged, or a locale map such as { "zh-TW": "借用人", "en": "Borrower" } (plugin-api LocalizedText). The JSON Schema embeds plugin-api's localizedTextJsonSchema ($defs/label: 1–200 code points; $defs/description: up to 2,000); semantic validation adds INVALID_LOCALIZED_TEXT for whitespace-only translations. Every translation is a draft free-text path (/label/*, /description/*, /options/*/label/*), so drafts wrap each one as $userContent. localizeFormSpec(spec, locale?) / localizeFormField return copies with one string per text (default zh-TW); outputs use them so clients never see a map. Fill diagnostics use the default locale. validation.message and placeholder stay strings. Requires plugin API 1.26.0.

版本与发布记录

@haneinfo/form 共发布 30 个版本,首次发布于 2026/10/19;过去 12 个月发布了 30 个版本。

版本发布日期距今
0.7.1latest2026/11/17今天
0.7.02026/11/161 天前
0.6.22026/11/0412 天前
0.6.12026/10/2918 天前
0.6.02026/10/2721 天前
0.5.02026/10/2523 天前

关于 @haneinfo/form 的常见问题

@haneinfo/form 是什么?

Dynamic structure mechanism: Form definitions (kind Form) with fields, conditions, formulas and subforms, registered with @haneinfo/definition-registry.

如何安装 @haneinfo/form?

在项目目录运行 npm install @haneinfo/form,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:zod(^4.4.0)、@nestjs/core(^11.0.0 || ^12.0.0)、@nestjs/common(^11.0.0 || ^12.0.0)、@haneinfo/common(^0.3.4 || ^0.4.0 || ^0.5.0 || ^0.6.0 || ^0.7.0)、@haneinfo/commands(^0.0.0 || ^0.1.0)、@haneinfo/plugin-host-nest(^2.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@haneinfo/form 支持 TypeScript 吗?

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

@haneinfo/form 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@haneinfo/form 可以商用吗?

@haneinfo/form 使用 UNLICENSED 许可。作者声明为 UNLICENSED,即不授予公开使用许可(与公共领域的 Unlicense 不同)。使用前需获得作者授权。以上为概括,不构成法律意见,请以许可原文为准。

@haneinfo/form 的下载量有多少?

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

@haneinfo/form 还在维护吗?

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