Skip to content

Commit a8aa6ab

Browse files
feat(plugin-form): a multi file / image field takes the whole row in the form auto-layout (#34698)
<!-- claude-projects-attribution: {"github_login":"os-support-ai"} --> _Requested by **Yibo Wang** · [project thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwBU5y97XtBcJ8qSLSR3B3Djd)_ Fixes #34668 repo:objectstack#3 · os-support-ai · session_01WGufzgwLiKcfujYUug7sPs Clause-②: no Metadata-protocol: none ## 维护者速读 - **改了什么**:表单自动排版里,对象字段声明 `multiple: true` 的文件 / 图片字段默认占整行;弹窗、整页表单、分页签表单、向导表单走同一条规则。单文件 / 单图仍占一格。 - **为什么改**:3 列的新建弹窗里,多图 / 多附件字段原来只占一格(测得每行 `[2, 3, 3]` 个,即与普通字段同宽)。详情页早已按同一判据让多文件字段占整行,这次表单与它对齐(裁定 6939109581「只放宽多文件附件」)。 - **风险与回滚**:只改默认宽度,不加元数据键、不改导出;spec 里 `FormField.span` 的说明文字同步改为如实描述(只改文字,不改键和取值);作者写了 `span: 'full'` 或 `colSpan` 的照写的来(显式 `span: 'auto'` 不收窄,`colSpan: 1` 才保持一格)。回滚即还原 `autoLayout.ts` 一个提交。 - **先看**:`ui/packages/plugin-form/src/autoLayout.ts`(新增 `isWideFormField`,`resolveColSpan` 与 `twelfthsFor` 改为问它);`ui/packages/plugin-form/src/__tests__/multiFileFullRow-34668.test.tsx`;`packages/spec/src/ui/view.zod.ts` 中 `FormField.span` 的一句说明。 - **两分钟验证**:`pnpm --dir ui exec vitest run packages/plugin-form/src/__tests__/multiFileFullRow-34668.test.tsx`,预期 17 passed。 - **需要你做的**:无,席位落地。 ## What changes - `ui/packages/plugin-form/src/autoLayout.ts`: a module-private `isWideFormField(field)` answers the `span: 'auto'` default. It returns true for a wide type (`isWideFieldType`, unchanged), and for a `file` / `image` field (bare or `field:` spelling) whose **object field** declares `multiple: true`. This is a parallel copy of plugin-detail's `MULTI_FILE_FIELD_TYPES` / `isWideDetailField`, with a docblock that points at it. plugin-form does not import from plugin-detail. - `resolveColSpan` (the CSS-grid path behind `applyAutoColSpan`, `applyAutoLayout` and `sectionFormLayout`) and `twelfthsFor` (the twelve-track path of `sectionedGridLayout`) now ask `isWideFormField` where they asked `isWideFieldType`. The precedence is unchanged: `span: 'full'`, then an authored `colSpan`, then the default. The author's width still wins. - **Where `multiple` is read.** It is read off the object-field definition that the object-bound builders stash on the FormField (`FormField.field`, set by `fromObjectSchema` and by `ObjectForm`'s flat builder). It is never read off `FormField.multiple`, which a form view entry can restate. This is the card's "只读对象字段的 `multiple`". Reading the stash means no caller had to change: every host that lays out through these helpers gets the rule, and the diff does not touch `ModalForm.tsx`, `DrawerForm.tsx`, `ObjectForm.tsx`, `TabbedForm.tsx` or `WizardForm.tsx`. - No change to `WIDE_FIELD_TYPES`, `isWideFieldType`'s signature or answer, or the package's `index.tsx` / `core.ts` exports. No metadata key is added. - `ui/packages/plugin-form/README.md`: the wide-kinds sentence names the multi-file rule. - `packages/spec/src/ui/view.zod.ts`: the `FormField.span` `.describe()` said that under `'auto'` "only textarea, markdown, html, richtext and repeater resolve to the full column count". That is no longer true, so it now reads "only textarea, markdown, html, richtext and repeater, plus a file or image field whose object field declares `multiple: true`, resolve to the full column count (…); an authored `colSpan` still wins over that default (`colSpan: 1` keeps such a field in one cell)." The colSpan clause was corrected in round 2: `resolveColSpan` and `twelfthsFor` check `span: 'full'`, then `colSpan`, then `isWideFormField` (which covers both the wide types and multi file / image). So an explicit `span: 'auto'` does not narrow any of them, and only an authored `colSpan` does. This is description text only: no schema, key, value or default changes, so `Clause-②: no` and `Metadata-protocol: none` stand (L1-a REWORK 6941942506, claim amendment 6941965048). Regenerated output: `content/docs/references/ui/view.mdx` (the `FormField` and `FormSection.fields` rows). The JSON Schema output is gitignored, and `check:authorable-surface` regenerates it and is green. - `.changeset/34668-form-multi-file-full-row.md`: `@object-ui/plugin-form` patch and `@objectstack/spec` patch (the description text). ## Tests New file `ui/packages/plugin-form/src/__tests__/multiFileFullRow-34668.test.tsx`, 17 tests. The rendered cases read per-row counts from the real form renderer's classes at `@md` / `@2xl` / `@4xl`, the same reading as `dialogContainerColumns-34607`. - Acceptance 1, dialog: flat create dialog (three wide), `full` dialog (four wide), undeclared sections, the object's `fieldGroups`, and a mixed-density (twelve-track) dialog. Multi image and multi file take the row (`[1, 1, 1]`). - Acceptance 1, page hosts: `ObjectForm` sectioned, `ObjectForm` flat (span equals the inferred grid width), `TabbedForm`, `WizardForm`. - Acceptance 2: single image, single file and multi-value select keep one cell (`[2, 3, 3]`). An authored `colSpan: 1` keeps a multi image in one cell. `span: 'full'` still widens a single file. - Helper layer: both spellings; only the object field is read (FormField-level `multiple` alone does not widen); `multiple` on select / lookup does nothing; authored `colSpan` wins; twelve-track twelfths; `applyAutoLayout`. - Acceptance 3: no existing pin was edited. Before this change, no existing test in the package pinned a file / image cell width (searched for `field:file` / `field:image` in the package's tests). The full package suite is green unedited (below). ## Acceptance notes - **View-level `multiple`.** A form view entry restating `multiple` over the object field changes the widget (`sectionFields` merges `fd.multiple`). It does not change the width, because the ruling reads the object field only. A view that turns a single-file object field into a multi-file widget therefore keeps one cell, and the author can widen it with `span: 'full'`. This follows the ruling and is recorded here, not changed. - **`video` / `audio`.** These map to the `field:file` widget. If their object field declared `multiple: true`, they would widen in the form but not in the detail view, which matches on the raw type. The spec's multi-capable types are select / lookup / file / image, so this is not reachable through validated metadata. No card filed. - **`ModalForm.tsx` docblock.** The `DIALOG_DEFAULT_COLUMNS` docblock lists the wide kinds via `isWideFieldType` and does not mention multi-file. It is still true as written. It was left alone because the file belongs to the sibling #34604 work. - **Studio designer.** app-shell's `ObjectFormDesigner` previews widths with `isWideFieldType` on the raw type, so its preview does not show the multi-file rule. Not a defect class under the card. Noted only. - **Unchanged inputs.** An inline `customFields` member, or a form mounted with no object schema, carries no stashed object field and keeps the type-only answer. ## Verification Head: `eba9da32`, a clean merge of `origin/main` f02f4f6 into `31c82383` (no hand resolution). Since `f261912b` the plugin-form code and tests in this PR are unchanged. The blocks after the spec block were taken on `f261912b`; the merge block was taken on `eba9da32`. <details><summary>After the origin/main merge (head eba9da3)</summary> ```text git merge --no-ff origin/main (f02f4f6, 18 commits): clean, no conflict incoming touched packages/spec and plugin-form's ModalForm.tsx / ObjectForm.tsx overlap-check: VERDICT clean exit 0 pnpm turbo run build --filter='@object-ui/plugin-form^...' --concurrency=2 lock VERDICT command-exit 0 pnpm --filter @objectstack/spec check:generated lock VERDICT command-exit 0: All 14 generated artifacts are up to date pnpm --filter @object-ui/plugin-form run type-check lock VERDICT command-exit 0 pnpm --dir ui exec vitest run --maxWorkers=2 packages/plugin-form/ lock VERDICT command-exit 0 Test Files 237 passed (237) Tests 2653 passed | 1 skipped (2654) ``` </details> <details><summary>Spec text (head 31c8238)</summary> ```text pnpm --filter @objectstack/spec check:generated --fix (rebuilds spec first) lock VERDICT command-exit 0 before: check:docs stale; after: gen:docs, check:docs re-check green the describe edit, the regenerated view.mdx (2 lines) and the changeset are in ONE commit, 31c8238 pnpm --filter @objectstack/spec check:generated (31c8238) lock VERDICT command-exit 0: All 14 generated artifacts are up to date dispatch-gates --commands on 31c8238: 115 families; --ran: 115 derived / 115 run / 0 NOT-MEASURED sequential batch: 108 exit 0. Seven non-zero in the batch, each exit 0 when re-run alone after the batch: exit 3 -> 0: lint check:doc-formula-expressions, lint check:doc-security-posture, spec check:skill-examples, check:docs-transcript-drift, check:dual-build-cjs-loads, check:lean-entry-closure exit 1 -> 0: spec check:generated (re-run under the lock) cause of the batch non-zeros: not measured (the worktree's dependency closure was not prebuilt) pnpm check:skill-frame-freshness exit 0; pnpm check:changeset-fixed exit 0 pnpm --dir ui run check:new-line-citations exit 0 (0 new citations) ui scripts vitest under the lock: Test Files 171 passed | 2 skipped, VERDICT command-exit 0 ``` Round 1: CI on `ed2ed090` failed `Type Check · source gates` (check:docs: `view.mdx` out of date; that commit carried the describe edit without the regenerated page). `d48fa36d` was green on every check. </details> <details><summary>New test file (17/17) and ablation</summary> ```text pnpm --dir ui exec vitest run --maxWorkers=2 packages/plugin-form/src/__tests__/multiFileFullRow-34668.test.tsx (head f261912) Test Files 1 passed (1) Tests 17 passed (17) os-verify-lock: VERDICT command-exit 0 Ablation (on the 15-test version of the file, commit a52c87e): the multi-file arm of isWideFormField replaced by `return false;` via node scripts/ablation-replace.mjs (the test imports ../autoLayout from src, so no dist leg) ablation-replace: ok mutation landed: anchor 1 -> 0, blob 808ab16 -> 59410cc1ad0c Tests 12 failed | 3 passed (15) (the 3 that stay green are the unchanged controls: single file / image and multi select keep one cell, FormField-level multiple alone does not widen, multiple on select / lookup does nothing) ablation-replace: ok restored: blob == HEAD (808ab16) and `git diff HEAD` is empty ``` Before / after for a `multiple: true` image in the 17-field create dialog (three wide), per row at @md / @2XL / @4XL: before (the ablated leg, which is origin/main's rule) `[2, 3, 3]`, one cell. After: `[1, 1, 1]`, the whole row. </details> <details><summary>Package suite and type-check</summary> ```text pnpm --dir ui exec vitest run --maxWorkers=2 packages/plugin-form/ (no existing test edited) Test Files 235 passed (235) Tests 2633 passed | 1 skipped (2634) os-verify-lock: VERDICT command-exit 0 (taken on a52c87e; the later commit f261912 adds only two tests to the new file and the changeset) pnpm --filter @object-ui/plugin-form run type-check (tsc --noEmit && tsc -p tsconfig.test.json; head f261912) os-verify-lock: VERDICT command-exit 0 tsconfig.test.json --listFilesOnly lists multiFileFullRow-34668.test.tsx: 1 hit ``` </details> <details><summary>Local gate subset (dispatch-gates --commands, narrowed by diff)</summary> ```text exit 0 node scripts/check-adr-0087-registration.mjs --base origin/main exit 0 node scripts/check-adr-0087-registration.mjs --self-test exit 0 node scripts/check-changeset-no-major.mjs --base origin/main exit 0 node scripts/check-closing-keyword-parity.mjs exit 0 node scripts/check-closing-keyword-parity.mjs --self-test exit 0 node scripts/check-comment-mask-corpus.mjs exit 0 node scripts/check-empty-changeset.mjs --base origin/main exit 0 node scripts/check-empty-changeset.mjs --self-test exit 0 node scripts/check-sdui-manifest.mjs exit 0 node scripts/check-sdui-manifest.mjs --self-test exit 0 node scripts/ci/snapshot-next.mjs --self-test exit 0 node scripts/pm/check-governed-queue-guard.mjs --self-test exit 0 node scripts/pm/release-rehearsal-clone.mjs --self-test exit 0 node scripts/release-pending-publish.mjs --self-test exit 0 pnpm --filter @objectstack/spec run check:duration-unit-keys exit 0 pnpm check:adr-anchors exit 0 pnpm check:changeset-gate-self-tests exit 0 pnpm check:closed-ceremony-text exit 0 pnpm check:cross-package-test-inputs exit 0 pnpm check:dispatcher-error-vocabulary exit 0 pnpm check:driver-memory-census exit 0 pnpm check:engine-double-contract exit 0 pnpm check:gitlink-declared exit 0 pnpm check:nul-bytes exit 0 pnpm check:published-files exit 0 pnpm check:query-options-erasure exit 0 pnpm check:refd-timer-probe exit 0 pnpm check:registry-log-declared exit 0 pnpm check:rest-log-spy-declared exit 0 pnpm check:skill-identifier-liveness exit 0 pnpm check:test-source-alias exit 0 pnpm check:tier-file-adoption exit 0 pnpm check:type-check-coverage exit 0 pnpm check:type-check-debt exit 0 pnpm check:undeclared-dep-imports exit 0 pnpm check:watch-hint-literal exit 0 pnpm check:where-matcher exit 0 pnpm check:changeset-fixed exit 0 pnpm --dir ui exec vitest run scripts/ (lock) exit 0 pnpm --dir ui run check:new-line-citations (VERDICT new-cross-file-line-citations: 0 new citation(s)) dispatch-gates --ran: 38 derived famil(ies) accounted for, 38 run, 0 NOT-MEASURED (head f261912) ``` Every other family (the wide-population and roster families, Type Check UI, Test UI, Lint UI, the full farm) is CI's. See the PR check-runs. </details> Overlap: `node scripts/pm/overlap-check.mjs` reported `VERDICT clean exit 0` (origin/main fecd2e9 merges cleanly; 0 open PR heads share a file). --- _Generated by [Claude Code](https://claude.ai/code/session_01WGufzgwLiKcfujYUug7sPs)_ <!-- signed: repo:objectstack#3 · os-support-ai · session_01WGufzgwLiKcfujYUug7sPs --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 07f2861 commit a8aa6ab

6 files changed

Lines changed: 342 additions & 9 deletions

File tree

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
'@object-ui/plugin-form': patch
3+
'@objectstack/spec': patch
4+
---
5+
6+
feat(plugin-form): a `file` / `image` field whose object field declares `multiple: true` takes the whole row in the form auto-layout
7+
8+
Clause-②: no
9+
Metadata-protocol: none
10+
11+
The form auto-layout now widens a multi-file field the way the detail view already does. A `file` or `image` field whose object field declares `multiple: true` takes the whole row by default, in every host that lays out a form: the form dialog (flat, sectioned, and the object's field groups), the full-page `ObjectForm` (flat and sectioned), `TabbedForm` and `WizardForm`. In a three- or four-column dialog its file names are no longer cut short, and its thumbnails no longer wrap inside one cell.
12+
13+
- **Single files stay one cell.** A `file` or `image` field without `multiple: true` keeps one cell, as before. A single file is one short name or one thumbnail.
14+
- **The author's width wins.** An authored `span: 'full'` or `colSpan` is drawn as written. A multi-image field the author gives `colSpan: 1` stays in one cell.
15+
- **Only the object field is read.** The rule reads `multiple` from the object field's own declaration, the same reading the detail view uses. `multiple` on any other type (a multi-value select, a multi lookup) changes nothing.
16+
17+
**The spec text says the same.** The `FormField.span` description in `@objectstack/spec` now names a `file` / `image` field whose object field declares `multiple: true` among the types `'auto'` sizes to the full column count, and says an authored `colSpan` still wins over that default (`colSpan: 1` keeps such a field in one cell). Description text only: the key, its values and its default are unchanged.
18+
19+
No metadata key is added and no export changes. `isWideFieldType` still answers on the type alone.

‎content/docs/references/ui/view.mdx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ Column footer summary configuration
222222
| **required** | `boolean` | optional | Required override |
223223
| **hidden** | `boolean` | optional | Hidden override |
224224
| **colSpan** | `integer` | optional | Absolute column span (1-4). The renderer clamps it to the form grid's current column count, so the cell starts at a real column boundary at every surface width and never overflows (`colSpan: 4` in a 3-column grid renders as 3); a `colSpan` within the column count renders as authored, and `colSpan: 1` emits no span class at all. |
225-
| **span** | `Enum<'auto' \| 'full'>` | optional (default: `"auto"`) | Relative field width. 'auto' (default — omit it): the renderer sizes the field from its widget type × the current column count — only textarea, markdown, html, richtext and repeater resolve to the full column count (repeater reaches it through the wide `field:grid` widget it maps to). 'full': resolves to the form grid's full column count. How far down the container-query tiers that span is emitted is the renderer's, not this key's: the renderer emits one clamped col-span class per multi-column tier (`@md:col-span-2 @2xl:col-span-3` for a 3-column grid), so the field takes the whole row at every multi-column tier, not just the widest. |
225+
| **span** | `Enum<'auto' \| 'full'>` | optional (default: `"auto"`) | Relative field width. 'auto' (default — omit it): the renderer sizes the field from its widget type × the current column count — only textarea, markdown, html, richtext and repeater, plus a file or image field whose object field declares `multiple: true`, resolve to the full column count (repeater reaches it through the wide `field:grid` widget it maps to); an authored `colSpan` still wins over that default (`colSpan: 1` keeps such a field in one cell). 'full': resolves to the form grid's full column count. How far down the container-query tiers that span is emitted is the renderer's, not this key's: the renderer emits one clamped col-span class per multi-column tier (`@md:col-span-2 @2xl:col-span-3` for a 3-column grid), so the field takes the whole row at every multi-column tier, not just the widest. |
226226
| **widget** | `string` | optional | Custom widget/component name (overrides type-based inference) |
227227
| **language** | `string` | optional | Code editor language (for type=code) |
228228
| **keyField** | `{ field?: string; label?: string \| Record<string, string>; placeholder?: string \| Record<string, string>; helpText?: string \| Record<string, string>; … }` | optional | Key column config for record-typed fields |
@@ -352,7 +352,7 @@ Form-view select option — the object-field option shape minus the per-option `
352352
| **required** | `boolean` | optional | Required override |
353353
| **hidden** | `boolean` | optional | Hidden override |
354354
| **colSpan** | `integer` | optional | Absolute column span (1-4). The renderer clamps it to the form grid's current column count, so the cell starts at a real column boundary at every surface width and never overflows (`colSpan: 4` in a 3-column grid renders as 3); a `colSpan` within the column count renders as authored, and `colSpan: 1` emits no span class at all. |
355-
| **span** | `Enum<'auto' \| 'full'>` | optional (default: `"auto"`) | Relative field width. 'auto' (default — omit it): the renderer sizes the field from its widget type × the current column count — only textarea, markdown, html, richtext and repeater resolve to the full column count (repeater reaches it through the wide `field:grid` widget it maps to). 'full': resolves to the form grid's full column count. How far down the container-query tiers that span is emitted is the renderer's, not this key's: the renderer emits one clamped col-span class per multi-column tier (`@md:col-span-2 @2xl:col-span-3` for a 3-column grid), so the field takes the whole row at every multi-column tier, not just the widest. |
355+
| **span** | `Enum<'auto' \| 'full'>` | optional (default: `"auto"`) | Relative field width. 'auto' (default — omit it): the renderer sizes the field from its widget type × the current column count — only textarea, markdown, html, richtext and repeater, plus a file or image field whose object field declares `multiple: true`, resolve to the full column count (repeater reaches it through the wide `field:grid` widget it maps to); an authored `colSpan` still wins over that default (`colSpan: 1` keeps such a field in one cell). 'full': resolves to the form grid's full column count. How far down the container-query tiers that span is emitted is the renderer's, not this key's: the renderer emits one clamped col-span class per multi-column tier (`@md:col-span-2 @2xl:col-span-3` for a 3-column grid), so the field takes the whole row at every multi-column tier, not just the widest. |
356356
| **widget** | `string` | optional | Custom widget/component name (overrides type-based inference) |
357357
| **language** | `string` | optional | Code editor language (for type=code) |
358358
| **keyField** | `{ field?: string; label?: string \| Record<string, string>; placeholder?: string \| Record<string, string>; helpText?: string \| Record<string, string>; … }` | optional | Key column config for record-typed fields |

‎packages/spec/src/ui/view.zod.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4040,7 +4040,7 @@ const FormFieldBaseSchema = lazySchema(() => {
40404040
* The read points (`resolveColSpan`, the wide-type list, the span ladder)
40414041
* are recorded in `packages/spec/liveness/view.json`, row `form.sections`.
40424042
*/
4043-
span: z.enum(['auto', 'full']).default('auto').describe("Relative field width. 'auto' (default — omit it): the renderer sizes the field from its widget type × the current column count — only textarea, markdown, html, richtext and repeater resolve to the full column count (repeater reaches it through the wide `field:grid` widget it maps to). 'full': resolves to the form grid's full column count. How far down the container-query tiers that span is emitted is the renderer's, not this key's: the renderer emits one clamped col-span class per multi-column tier (`@md:col-span-2 @2xl:col-span-3` for a 3-column grid), so the field takes the whole row at every multi-column tier, not just the widest."),
4043+
span: z.enum(['auto', 'full']).default('auto').describe("Relative field width. 'auto' (default — omit it): the renderer sizes the field from its widget type × the current column count — only textarea, markdown, html, richtext and repeater, plus a file or image field whose object field declares `multiple: true`, resolve to the full column count (repeater reaches it through the wide `field:grid` widget it maps to); an authored `colSpan` still wins over that default (`colSpan: 1` keeps such a field in one cell). 'full': resolves to the form grid's full column count. How far down the container-query tiers that span is emitted is the renderer's, not this key's: the renderer emits one clamped col-span class per multi-column tier (`@md:col-span-2 @2xl:col-span-3` for a 3-column grid), so the field takes the whole row at every multi-column tier, not just the widest."),
40444044

40454045
/** Custom widget override — only needed when auto-inference is insufficient */
40464046
widget: z.string().optional().describe('Custom widget/component name (overrides type-based inference)'),

‎ui/packages/plugin-form/README.md‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,10 @@ the fourth column is the `full` dialog's.
564564
Every count is a container-query grid, so it is an upper bound: the form draws
565565
as many columns as its container is wide enough for, and one column below the
566566
`@md` tier (a phone, a narrow drawer). Wide field kinds (textarea, rich text,
567-
markdown, html, an inline `grid`) and `span: 'full'` fields take the whole row.
567+
markdown, html, an inline `grid`), `file` / `image` fields whose object field
568+
declares `multiple: true`, and `span: 'full'` fields take the whole row — the
569+
detail view widens multi-file fields by the same rule. A single file or image
570+
keeps one cell, and an authored `span` / `colSpan` is drawn as written.
568571

569572
The grid is applied to the field container **inside** the form, never wrapped
570573
around the `<form>` (which would put the whole form in cell 1 and leave the other

0 commit comments

Comments
 (0)