From a52c87ea5a6bbc22091ca6895977b085ef60b6f8 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 06:29:03 +0000 Subject: [PATCH 1/5] feat(plugin-form): a multi file / image field takes the whole row in the form auto-layout Claude-Session: https://claude.ai/code/session_01WGufzgwLiKcfujYUug7sPs Co-Authored-By: Claude --- ui/packages/plugin-form/README.md | 5 +- .../__tests__/multiFileFullRow-34668.test.tsx | 234 ++++++++++++++++++ ui/packages/plugin-form/src/autoLayout.ts | 52 +++- 3 files changed, 285 insertions(+), 6 deletions(-) create mode 100644 ui/packages/plugin-form/src/__tests__/multiFileFullRow-34668.test.tsx diff --git a/ui/packages/plugin-form/README.md b/ui/packages/plugin-form/README.md index ccc706983bb..91cef3e4301 100644 --- a/ui/packages/plugin-form/README.md +++ b/ui/packages/plugin-form/README.md @@ -564,7 +564,10 @@ the fourth column is the `full` dialog's. Every count is a container-query grid, so it is an upper bound: the form draws as many columns as its container is wide enough for, and one column below the `@md` tier (a phone, a narrow drawer). Wide field kinds (textarea, rich text, -markdown, html, an inline `grid`) and `span: 'full'` fields take the whole row. +markdown, html, an inline `grid`), `file` / `image` fields whose object field +declares `multiple: true`, and `span: 'full'` fields take the whole row — the +detail view widens multi-file fields by the same rule. A single file or image +keeps one cell, and an authored `span` / `colSpan` is drawn as written. The grid is applied to the field container **inside** the form, never wrapped around the `
` (which would put the whole form in cell 1 and leave the other diff --git a/ui/packages/plugin-form/src/__tests__/multiFileFullRow-34668.test.tsx b/ui/packages/plugin-form/src/__tests__/multiFileFullRow-34668.test.tsx new file mode 100644 index 00000000000..e9a94589d63 --- /dev/null +++ b/ui/packages/plugin-form/src/__tests__/multiFileFullRow-34668.test.tsx @@ -0,0 +1,234 @@ +/** + * ObjectUI + * Copyright (c) 2024-present ObjectStack Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +/** + * objectstack-ai/objectstack#34668 — in the form auto-layout a `file` / + * `image` field whose OBJECT field declares `multiple: true` takes the whole + * row, on the dialog and on every page host alike, mirroring plugin-detail's + * `isWideDetailField`. A single file or image keeps one cell, an authored + * `span` / `colSpan` is drawn as written, and `multiple` on any other type + * (a multi-value select) changes nothing. + * + * jsdom evaluates no container query, so a count per row is read from the + * classes the real form renderer draws: at each tier, the grid tracks in force + * over the field's span in force (the reading `dialogContainerColumns-34607` + * uses). A row of 1 at every tier is the whole row. + */ + +import React from 'react'; +import { describe, it, expect, vi, afterEach } from 'vitest'; +import { render, waitFor, cleanup, screen } from '@testing-library/react'; +import type { FormField } from '@object-ui/types'; +import { registerAllFields } from '@object-ui/fields'; +import '@object-ui/components'; +import { ModalForm } from '../ModalForm'; +import { ObjectForm } from '../ObjectForm'; +import { applyAutoColSpan, resolveColSpan, sectionedGridLayout } from '../autoLayout'; + +registerAllFields(); + +afterEach(() => cleanup()); + +const PLAIN = Array.from({ length: 12 }, (_, i) => `f${i}`); + +/** + * Seventeen fields, no layout declared: twelve plain ones, a multi image, a + * multi file, a single image, a single file and a multi-value select. + */ +const DEAL = { + name: 'deal', + fields: { + ...Object.fromEntries(PLAIN.map((n) => [n, { type: 'text', label: `Field ${n}` }])), + gallery: { type: 'image', label: 'Gallery', multiple: true }, + attachments: { type: 'file', label: 'Attachments', multiple: true }, + logo: { type: 'image', label: 'Logo' }, + contract: { type: 'file', label: 'Contract' }, + tags: { type: 'select', label: 'Tags', multiple: true, options: [{ label: 'A', value: 'a' }] }, + }, +}; + +const ds = (): any => ({ + getObjectSchema: vi.fn().mockResolvedValue(DEAL), + findOne: vi.fn().mockResolvedValue({}), + find: vi.fn().mockResolvedValue({ data: [] }), + create: vi.fn(), + update: vi.fn(), +}); + +const base = (extra: Record) => + ({ type: 'object-form', objectName: 'deal', mode: 'create', fields: Object.keys(DEAL.fields), ...extra }) as any; + +async function settle(name: string) { + await waitFor(() => expect(document.body.querySelector(`[data-field="${name}"]`)).not.toBeNull()); +} + +async function openDialog(extra: Record = {}) { + render(); + await settle('gallery'); +} + +async function openPage(extra: Record = {}) { + render(); + await settle('gallery'); +} + +function readField(name: string): { grid: string[]; span: string[] } { + const cell = document.body.querySelector(`[data-field="${name}"]`); + if (!cell) throw new Error(`field not rendered: ${name}`); + const tokens = (el: Element | null) => (el?.getAttribute('class') || '').split(/\s+/).filter(Boolean); + return { + grid: tokens(cell.parentElement).filter((t) => /(^|:)grid-cols-/.test(t)), + span: tokens(cell).filter((t) => /(^|:)col-span-/.test(t)), + }; +} + +const TIERS = ['@md', '@2xl', '@4xl'] as const; + +/** Fields per row at `@md` / `@2xl` / `@4xl`: tracks in force / span in force. */ +function ladder(name: string): number[] { + const read = readField(name); + return TIERS.map((tier) => { + const upTo = TIERS.slice(0, TIERS.indexOf(tier) + 1); + const inForce = (list: string[], stem: string) => { + let v: number | undefined; + for (const t of upTo) { + const hit = list.find((c) => c.startsWith(`${t}:${stem}`)); + if (hit) v = Number(hit.split('-').pop()); + } + return v; + }; + return (inForce(read.grid, 'grid-cols-') ?? 1) / (inForce(read.span, 'col-span-') ?? 1); + }); +} + +const WHOLE_ROW = [1, 1, 1]; +const SECTIONS = [ + { name: 'a', label: 'A', fields: [...PLAIN.slice(0, 6), 'gallery', 'logo'] }, + { name: 'b', label: 'B', fields: [...PLAIN.slice(6), 'attachments', 'contract', 'tags'] }, +]; + +describe('#34668 acceptance 1 — a multi file / image field takes the whole row in the dialog', () => { + it('flat create dialog (three wide): multi image and multi file take the row at every tier', async () => { + await openDialog(); + expect(ladder('f0')).toEqual([2, 3, 3]); + expect(ladder('gallery')).toEqual(WHOLE_ROW); + expect(ladder('attachments')).toEqual(WHOLE_ROW); + }); + + it("a full dialog (four wide): still the whole row", async () => { + await openDialog({ modalSize: 'full' }); + expect(ladder('f0')).toEqual([2, 3, 4]); + expect(ladder('gallery')).toEqual(WHOLE_ROW); + expect(ladder('attachments')).toEqual(WHOLE_ROW); + }); + + it('undeclared sections in the dialog: the whole row', async () => { + await openDialog({ sections: SECTIONS }); + expect(ladder('gallery')).toEqual(WHOLE_ROW); + expect(ladder('attachments')).toEqual(WHOLE_ROW); + }); + + it('a mixed-density dialog (twelve-track grid): the whole row', async () => { + await openDialog({ sections: [{ ...SECTIONS[0], columns: 2 }, SECTIONS[1]] }); + expect(readField('gallery').grid).toContain('@md:grid-cols-12'); + expect(ladder('gallery')).toEqual(WHOLE_ROW); + expect(ladder('attachments')).toEqual(WHOLE_ROW); + }); +}); + +describe('#34668 acceptance 1 — the page hosts take the same rule', () => { + it('ObjectForm sectioned page: the whole row, beside two-per-row plain fields', async () => { + await openPage({ sections: SECTIONS }); + expect(ladder('f0')).toEqual([2, 2, 2]); + expect(ladder('gallery')).toEqual(WHOLE_ROW); + expect(ladder('attachments')).toEqual(WHOLE_ROW); + expect(ladder('logo')).toEqual([2, 2, 2]); + }); + + it('ObjectForm flat page: the multi fields span the whole inferred grid, the single ones one cell', async () => { + await openPage(); + // Seventeen fields infer four columns on the page's viewport grid. + const full = readField('gallery').span; + expect(full.some((c) => c.endsWith('col-span-4'))).toBe(true); + expect(readField('attachments').span).toEqual(full); + expect(readField('logo').span.some((c) => c.endsWith('col-span-4'))).toBe(false); + }); + + it('TabbedForm: the whole row', async () => { + await openPage({ formType: 'tabbed', sections: SECTIONS }); + await waitFor(() => expect(screen.queryByTestId('form-tab:b')).not.toBeNull()); + expect(ladder('gallery')).toEqual(WHOLE_ROW); + expect(ladder('logo')).toEqual([2, 2, 2]); + }); + + it('WizardForm: the whole row on its step', async () => { + await openPage({ formType: 'wizard', sections: SECTIONS }); + expect(ladder('gallery')).toEqual(WHOLE_ROW); + expect(ladder('logo')).toEqual([2, 2, 2]); + }); +}); + +describe('#34668 acceptance 2 — single files, authored widths and other multi types are unchanged', () => { + it('a single image and a single file keep one cell; a multi-value select keeps one cell', async () => { + await openDialog(); + expect(ladder('logo')).toEqual([2, 3, 3]); + expect(ladder('contract')).toEqual([2, 3, 3]); + expect(ladder('tags')).toEqual([2, 3, 3]); + }); + + it("an authored colSpan: 1 keeps a multi image in one cell; span: 'full' still widens a single file", async () => { + await openDialog({ + sections: [ + { name: 'a', label: 'A', fields: [...PLAIN.slice(0, 6), { field: 'gallery', colSpan: 1 }, 'logo'] }, + { name: 'b', label: 'B', fields: [...PLAIN.slice(6), 'attachments', { field: 'contract', span: 'full' }, 'tags'] }, + ], + }); + expect(ladder('gallery')).toEqual([2, 3, 3]); + expect(ladder('contract')).toEqual(WHOLE_ROW); + expect(ladder('attachments')).toEqual(WHOLE_ROW); + }); +}); + +describe('#34668 the rule, at the layout helpers', () => { + const ff = (type: string, objectField?: Record, extra: Partial = {}): FormField => + ({ name: 'x', label: 'X', type, ...(objectField ? { field: objectField } : {}), ...extra }) as FormField; + + it('both spellings of file / image widen when the object field declares multiple: true', () => { + for (const t of ['field:image', 'field:file', 'image', 'file']) { + expect(resolveColSpan(ff(t, { type: 'image', multiple: true }), 3)).toBe(3); + expect(resolveColSpan(ff(t, { type: 'image' }), 3)).toBe(1); + expect(resolveColSpan(ff(t, { type: 'image', multiple: false }), 3)).toBe(1); + } + }); + + it('only the object field is read: a FormField-level multiple, or no object field, keeps one cell', () => { + expect(resolveColSpan(ff('field:image', undefined, { multiple: true }), 3)).toBe(1); + expect(resolveColSpan(ff('field:image', { type: 'image' }, { multiple: true }), 3)).toBe(1); + }); + + it('multiple on another type changes nothing', () => { + expect(resolveColSpan(ff('field:select', { type: 'select', multiple: true }), 3)).toBe(1); + expect(resolveColSpan(ff('field:lookup', { type: 'lookup', multiple: true }), 3)).toBe(1); + }); + + it('an authored span / colSpan wins', () => { + const multi = { type: 'image', multiple: true }; + expect(resolveColSpan(ff('field:image', multi, { colSpan: 1 }), 3)).toBe(1); + expect(resolveColSpan(ff('field:image', multi, { colSpan: 2 }), 3)).toBe(2); + expect(applyAutoColSpan([ff('field:image', multi)], 4)[0].colSpan).toBe(4); + }); + + it('the twelve-track grid gives the multi field all twelve twelfths, an authored colSpan its own', () => { + const grid = sectionedGridLayout(undefined, [2, 3]); + expect(grid.fieldContainerClass).toContain('@md:grid-cols-12'); + const multi = { type: 'file', multiple: true }; + expect(grid.layOut([ff('field:file', multi)], 3)[0].colSpan).toBe(12); + expect(grid.layOut([ff('field:file', { type: 'file' })], 3)[0].colSpan).toBe(4); + expect(grid.layOut([ff('field:file', multi, { colSpan: 1 })], 3)[0].colSpan).toBe(4); + }); +}); diff --git a/ui/packages/plugin-form/src/autoLayout.ts b/ui/packages/plugin-form/src/autoLayout.ts index 6c11ba90453..808ab16b389 100644 --- a/ui/packages/plugin-form/src/autoLayout.ts +++ b/ui/packages/plugin-form/src/autoLayout.ts @@ -94,6 +94,47 @@ export function isWideFieldType(type: string): boolean { return WIDE_FIELD_TYPES.has(type); } +/** + * The upload types that take the whole row when their object field declares + * `multiple: true` — the multi-capable upload types `@objectstack/spec` + * declares (`file`, `image`), in the two spellings {@link WIDE_FIELD_TYPES} + * carries: the bare spec name and the widget id `mapFieldTypeToFormType` maps + * it to. + * + * Kept OUT of `WIDE_FIELD_TYPES` on purpose: the type alone does not make the + * field wide. One file is one short name or one thumbnail and fits a cell; a + * list of them is cut short or wraps its thumbnails in one cell of a 3- or + * 4-wide grid. So {@link isWideFieldType} keeps answering on the type alone. + * + * A parallel copy of plugin-detail's `MULTI_FILE_FIELD_TYPES` / + * `isWideDetailField`, not an import: the two plugins do not depend on each + * other, and the detail rule and this one read the same declaration. + */ +const MULTI_FILE_FIELD_TYPES = new Set(['file', 'image', 'field:file', 'field:image']); + +/** + * Does this form field take the whole row by default (the `span: 'auto'` rule)? + * + * A wide type (see {@link isWideFieldType}), or a `file` / `image` field whose + * OBJECT field declares `multiple: true` — the rule plugin-detail's + * `isWideDetailField` applies to the detail view, so a multi-file field reads + * wide on both surfaces. + * + * `multiple` is read off the object-field definition the object-bound form + * paths stash on the FormField (`FormField.field`), and nothing else, as the + * detail rule reads it off the object schema: it is the field's declaration. + * A field with no stashed object field (an inline member, a form mounted + * without an object) keeps the type-only answer. + * + * Only the default: an authored `span: 'full'` or `colSpan` is decided before + * this is asked, so the author's width still wins. + */ +function isWideFormField(field: FormField): boolean { + if (!field.type) return false; + if (isWideFieldType(field.type)) return true; + return MULTI_FILE_FIELD_TYPES.has(field.type) && field.field?.multiple === true; +} + /** * Check if an object field type is auto-generated (formula, summary, auto_number). */ @@ -146,7 +187,8 @@ function clampGrid(n: number | undefined): number { * `__tests__/spanFullTierLadder-9244.test.tsx` for the leg that can. * * 2. legacy `colSpan` → honoured but CLAMPED to the grid (never overflows). - * 3. wide widget type → whole row (textarea/markdown/… — the `span:'auto'` default). + * 3. wide widget type → whole row (textarea/markdown/… — the `span:'auto'` default), + * and a `file` / `image` field whose object field declares `multiple: true`. * 4. section density → grid / sectionColumns, so `sectionColumns` fields fill a row. * * `sectionColumns` defaults to the grid width, i.e. one field per cell (the flat @@ -169,8 +211,8 @@ export function resolveColSpan( return Math.min(Math.max(1, Math.floor(field.colSpan)), grid); } - // `span: 'auto'` (or unset): wide widgets take the whole row. - if (field.type && isWideFieldType(field.type)) return grid; + // `span: 'auto'` (or unset): wide widgets, and multi-file uploads, take the whole row. + if (isWideFormField(field)) return grid; // Otherwise fill the section's density: N per row → grid/N cells each. const secCols = Math.min(Math.max(1, Math.floor(sectionColumns || grid)), grid); @@ -434,7 +476,7 @@ export interface SectionedGridLayout { * row, and a `columns: 3` section on a 4-wide grid spanned 1 cell, FOUR per * row (`Math.round(grid / sectionColumns)`). The grid becomes * {@link TWELVE_TRACK_GRID_COLS} and each field spans twelfths of the row: - * 1. `span: 'full'`, or a wide widget type → 12, the whole row; + * 1. `span: 'full'`, or a wide widget type or multi-file upload → 12, the whole row; * 2. an authored `colSpan` → that many of its SECTION's columns, clamped * to them (it keeps winning over the density); * 3. otherwise → 12 / the section's columns. @@ -497,7 +539,7 @@ function twelfthsFor(field: FormField, sectionColumns: number): number { const cells = Math.min(Math.max(1, Math.floor(field.colSpan)), sectionColumns); return (12 * cells) / sectionColumns; } - if (field.type && isWideFieldType(field.type)) return 12; + if (isWideFormField(field)) return 12; return 12 / sectionColumns; } From f261912b6faf98420ad8dc44238cc743a562c763 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 06:44:58 +0000 Subject: [PATCH 2/5] test(plugin-form): pin the multi-file full row on field groups and applyAutoLayout; add changeset Claude-Session: https://claude.ai/code/session_01WGufzgwLiKcfujYUug7sPs Co-Authored-By: Claude --- .changeset/34668-form-multi-file-full-row.md | 16 ++++++++ .../__tests__/multiFileFullRow-34668.test.tsx | 37 ++++++++++++++++++- 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 .changeset/34668-form-multi-file-full-row.md diff --git a/.changeset/34668-form-multi-file-full-row.md b/.changeset/34668-form-multi-file-full-row.md new file mode 100644 index 00000000000..58418717052 --- /dev/null +++ b/.changeset/34668-form-multi-file-full-row.md @@ -0,0 +1,16 @@ +--- +'@object-ui/plugin-form': patch +--- + +feat(plugin-form): a `file` / `image` field whose object field declares `multiple: true` takes the whole row in the form auto-layout + +Clause-②: no +Metadata-protocol: none + +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. + +- **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. +- **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. +- **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. + +No metadata key is added and no export changes. `isWideFieldType` still answers on the type alone. diff --git a/ui/packages/plugin-form/src/__tests__/multiFileFullRow-34668.test.tsx b/ui/packages/plugin-form/src/__tests__/multiFileFullRow-34668.test.tsx index e9a94589d63..f143af7de6d 100644 --- a/ui/packages/plugin-form/src/__tests__/multiFileFullRow-34668.test.tsx +++ b/ui/packages/plugin-form/src/__tests__/multiFileFullRow-34668.test.tsx @@ -28,7 +28,7 @@ import { registerAllFields } from '@object-ui/fields'; import '@object-ui/components'; import { ModalForm } from '../ModalForm'; import { ObjectForm } from '../ObjectForm'; -import { applyAutoColSpan, resolveColSpan, sectionedGridLayout } from '../autoLayout'; +import { applyAutoColSpan, applyAutoLayout, resolveColSpan, sectionedGridLayout } from '../autoLayout'; registerAllFields(); @@ -133,6 +133,29 @@ describe('#34668 acceptance 1 — a multi file / image field takes the whole row expect(ladder('attachments')).toEqual(WHOLE_ROW); }); + it("the object's fieldGroups in the dialog: the whole row", async () => { + const grouped = { + ...DEAL, + fieldGroups: [ + { key: 'main', label: 'Main' }, + { key: 'files', label: 'Files' }, + ], + fields: Object.fromEntries( + Object.entries(DEAL.fields).map(([k, f], i) => [k, { ...f, group: i < 8 ? 'main' : 'files' }]), + ), + }; + render( + , + ); + await settle('gallery'); + expect(ladder('f0')).toEqual([2, 3, 3]); + expect(ladder('gallery')).toEqual(WHOLE_ROW); + expect(ladder('logo')).toEqual([2, 3, 3]); + }); + it('a mixed-density dialog (twelve-track grid): the whole row', async () => { await openDialog({ sections: [{ ...SECTIONS[0], columns: 2 }, SECTIONS[1]] }); expect(readField('gallery').grid).toContain('@md:grid-cols-12'); @@ -223,6 +246,18 @@ describe('#34668 the rule, at the layout helpers', () => { expect(applyAutoColSpan([ff('field:image', multi)], 4)[0].colSpan).toBe(4); }); + it('applyAutoLayout (the flat drawer and page path) widens it on the inferred grid', () => { + const fields = [ + ...PLAIN.map((n) => ff('field:text', { type: 'text' }, { name: n })), + ff('field:image', { type: 'image', multiple: true }, { name: 'gallery' }), + ff('field:image', { type: 'image' }, { name: 'logo' }), + ]; + const out = applyAutoLayout(fields, { fields: {} }, undefined, 'create'); + expect(out.columns).toBe(3); + expect(out.fields.find((f) => f.name === 'gallery')?.colSpan).toBe(3); + expect(out.fields.find((f) => f.name === 'logo')?.colSpan).toBeUndefined(); + }); + it('the twelve-track grid gives the multi field all twelve twelfths, an authored colSpan its own', () => { const grid = sectionedGridLayout(undefined, [2, 3]); expect(grid.fieldContainerClass).toContain('@md:grid-cols-12'); From ed2ed090aa050cf5bd2997379181d844ecdf2f31 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 07:45:07 +0000 Subject: [PATCH 3/5] docs(spec): FormField.span says a multi file / image field takes the full column count under 'auto' Claude-Session: https://claude.ai/code/session_01WGufzgwLiKcfujYUug7sPs Co-Authored-By: Claude --- .changeset/34668-form-multi-file-full-row.md | 3 +++ packages/spec/src/ui/view.zod.ts | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.changeset/34668-form-multi-file-full-row.md b/.changeset/34668-form-multi-file-full-row.md index 58418717052..bfd41745d8d 100644 --- a/.changeset/34668-form-multi-file-full-row.md +++ b/.changeset/34668-form-multi-file-full-row.md @@ -1,5 +1,6 @@ --- '@object-ui/plugin-form': patch +'@objectstack/spec': patch --- feat(plugin-form): a `file` / `image` field whose object field declares `multiple: true` takes the whole row in the form auto-layout @@ -13,4 +14,6 @@ The form auto-layout now widens a multi-file field the way the detail view alrea - **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. - **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. +**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 author's explicit span wins. Description text only: the key, its values and its default are unchanged. + No metadata key is added and no export changes. `isWideFieldType` still answers on the type alone. diff --git a/packages/spec/src/ui/view.zod.ts b/packages/spec/src/ui/view.zod.ts index c5aff8384db..39d079a1a1e 100644 --- a/packages/spec/src/ui/view.zod.ts +++ b/packages/spec/src/ui/view.zod.ts @@ -4040,7 +4040,7 @@ const FormFieldBaseSchema = lazySchema(() => { * The read points (`resolveColSpan`, the wide-type list, the span ladder) * are recorded in `packages/spec/liveness/view.json`, row `form.sections`. */ - 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."), + 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 author's explicit span wins. '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."), /** Custom widget override — only needed when auto-inference is insufficient */ widget: z.string().optional().describe('Custom widget/component name (overrides type-based inference)'), From d48fa36dd0260757074d70dfdd2dbde1b12dc191 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 07:50:23 +0000 Subject: [PATCH 4/5] docs(spec): regenerate the view reference for the FormField.span text Claude-Session: https://claude.ai/code/session_01WGufzgwLiKcfujYUug7sPs Co-Authored-By: Claude --- content/docs/references/ui/view.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/content/docs/references/ui/view.mdx b/content/docs/references/ui/view.mdx index 457e7e603fe..1c6915e17a8 100644 --- a/content/docs/references/ui/view.mdx +++ b/content/docs/references/ui/view.mdx @@ -222,7 +222,7 @@ Column footer summary configuration | **required** | `boolean` | optional | Required override | | **hidden** | `boolean` | optional | Hidden override | | **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. | -| **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. | +| **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 author's explicit span wins. '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. | | **widget** | `string` | optional | Custom widget/component name (overrides type-based inference) | | **language** | `string` | optional | Code editor language (for type=code) | | **keyField** | `{ field?: string; label?: string \| Record; placeholder?: string \| Record; helpText?: string \| Record; … }` | 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 ` | **required** | `boolean` | optional | Required override | | **hidden** | `boolean` | optional | Hidden override | | **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. | -| **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. | +| **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 author's explicit span wins. '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. | | **widget** | `string` | optional | Custom widget/component name (overrides type-based inference) | | **language** | `string` | optional | Code editor language (for type=code) | | **keyField** | `{ field?: string; label?: string \| Record; placeholder?: string \| Record; helpText?: string \| Record; … }` | optional | Key column config for record-typed fields | From 31c82383f4c5bcc3679146c21b14374e82e9b644 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 09:16:35 +0000 Subject: [PATCH 5/5] docs(spec): FormField.span says an authored colSpan, not any explicit span, still wins over the 'auto' full row Claude-Session: https://claude.ai/code/session_01WGufzgwLiKcfujYUug7sPs Co-Authored-By: Claude --- .changeset/34668-form-multi-file-full-row.md | 2 +- content/docs/references/ui/view.mdx | 4 ++-- packages/spec/src/ui/view.zod.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.changeset/34668-form-multi-file-full-row.md b/.changeset/34668-form-multi-file-full-row.md index bfd41745d8d..5e25f66c9e0 100644 --- a/.changeset/34668-form-multi-file-full-row.md +++ b/.changeset/34668-form-multi-file-full-row.md @@ -14,6 +14,6 @@ The form auto-layout now widens a multi-file field the way the detail view alrea - **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. - **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. -**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 author's explicit span wins. Description text only: the key, its values and its default are unchanged. +**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. No metadata key is added and no export changes. `isWideFieldType` still answers on the type alone. diff --git a/content/docs/references/ui/view.mdx b/content/docs/references/ui/view.mdx index 1c6915e17a8..6d043ab1bbd 100644 --- a/content/docs/references/ui/view.mdx +++ b/content/docs/references/ui/view.mdx @@ -222,7 +222,7 @@ Column footer summary configuration | **required** | `boolean` | optional | Required override | | **hidden** | `boolean` | optional | Hidden override | | **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. | -| **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 author's explicit span wins. '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. | +| **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. | | **widget** | `string` | optional | Custom widget/component name (overrides type-based inference) | | **language** | `string` | optional | Code editor language (for type=code) | | **keyField** | `{ field?: string; label?: string \| Record; placeholder?: string \| Record; helpText?: string \| Record; … }` | 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 ` | **required** | `boolean` | optional | Required override | | **hidden** | `boolean` | optional | Hidden override | | **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. | -| **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 author's explicit span wins. '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. | +| **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. | | **widget** | `string` | optional | Custom widget/component name (overrides type-based inference) | | **language** | `string` | optional | Code editor language (for type=code) | | **keyField** | `{ field?: string; label?: string \| Record; placeholder?: string \| Record; helpText?: string \| Record; … }` | optional | Key column config for record-typed fields | diff --git a/packages/spec/src/ui/view.zod.ts b/packages/spec/src/ui/view.zod.ts index 39d079a1a1e..f36edc5ccd5 100644 --- a/packages/spec/src/ui/view.zod.ts +++ b/packages/spec/src/ui/view.zod.ts @@ -4040,7 +4040,7 @@ const FormFieldBaseSchema = lazySchema(() => { * The read points (`resolveColSpan`, the wide-type list, the span ladder) * are recorded in `packages/spec/liveness/view.json`, row `form.sections`. */ - 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 author's explicit span wins. '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."), + 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."), /** Custom widget override — only needed when auto-inference is insufficient */ widget: z.string().optional().describe('Custom widget/component name (overrides type-based inference)'),