From 977ccbb40b03a1b7c718852c8581e4ee4f5a2e45 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 9 Nov 2026 08:25:52 +0000 Subject: [PATCH 1/2] feat(app-shell): a row-table page block lists the rows a page api binding answers The sixth product-page block: rows from a list (or a whole hole naming one in the bound data), declared columns with path, label and a text, datetime or enum format, every row drawn, an empty label, and the binding's error panel for a list it cannot read. Its strict @object-ui/types arm lands with it, and the cli's known types are regenerated. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01QsR2jTx4LkMSXMTUGZuzQW --- .changeset/31856-row-table-block.md | 16 ++ content/docs/frontend/data-source.mdx | 9 +- content/docs/ui/pages.mdx | 2 +- ui/packages/app-shell/README.md | 29 ++- .../productBlocks-namespace-13301.test.tsx | 6 +- .../blocks/__tests__/rowTable-31856.test.tsx | 139 +++++++++++++ .../src/console/blocks/productBlocks.tsx | 188 +++++++++++++++++- ui/packages/app-shell/src/index.ts | 2 +- .../product-blocks-namespace-13301.test.ts | 3 +- ...tered-types-validate-ratchet-10859.test.ts | 7 +- .../cli/src/utils/known-schema-types.ts | 2 + .../product-block-arms-12197.test.ts | 53 ++++- .../src/__tests__/zod-mirror-parity.test.ts | 12 +- ui/packages/types/src/index.ts | 9 +- ui/packages/types/src/product-blocks.ts | 37 +++- ui/packages/types/src/zod/index.zod.ts | 2 + .../types/src/zod/product-blocks.zod.ts | 77 ++++++- 17 files changed, 567 insertions(+), 26 deletions(-) create mode 100644 .changeset/31856-row-table-block.md create mode 100644 ui/packages/app-shell/src/console/blocks/__tests__/rowTable-31856.test.tsx diff --git a/.changeset/31856-row-table-block.md b/.changeset/31856-row-table-block.md new file mode 100644 index 00000000000..5a1ed9d472c --- /dev/null +++ b/.changeset/31856-row-table-block.md @@ -0,0 +1,16 @@ +--- +'@object-ui/types': minor +'@object-ui/app-shell': patch +'@object-ui/cli': patch +--- + +feat(app-shell): a `row-table` page block lists the rows a page `api` binding answers, as a table + +Clause-②: yes (widening) +Metadata-protocol: added + +- **`@object-ui/app-shell`: the `row-table` block**, the sixth product-page block beside `hero`, `stat`, `usage-bar`, `checklist` and `tile-grid`, registered under the `app-shell` namespace with the bare `row-table` as its authorable key. `rows` is a list, or one whole `${…}` hole naming a list in the bound `data` (`rows: '${data.actors}'`); every row is drawn, with no cap. `columns` declares, in order, `{ path, label, format?, enum? }`: `path` is a dotted path into one row, `label` a string or an inline locale map, and `format` is `text` (the default, drawn as written), `datetime` (an instant in the viewer's display locale and time zone, through the `datetime` field cell's `formatDateTime`) or `enum` (the label `enum: { value: label }` names; a value the map does not name is drawn as written). A field the row lacks, `null` or empty draws `—`. An empty list draws `emptyLabel`, else the bundle's "No rows to display". A `rows` hole that resolves to anything but a list, or a column the block cannot draw, draws the binding's error panel, never the empty state. +- **`@object-ui/types`: its arm**, `RowTableBlockSchema` with `RowTableColumnSchema` (and the TS twins `RowTableBlockSchema`, `RowTableBlockProps`, `RowTableColumn`), a member of `ProductBlockComponentSchema`, so `objectui validate` claims the type. The arm is strict: an unknown `format`, an `enum` column with no label map, a label map on a column that is not `enum`, a `path` that is not a dotted path, an undeclared key and an empty `columns` are refused. The `dataSource` is the spec's `ElementApiDataSourceSchema`, by reference. +- **`@object-ui/cli`:** `known-schema-types.ts` regenerated with `row-table` and `app-shell:row-table`. + +No `@objectstack/spec` change: the type parses through `PageComponentSchema.type`'s open string arm, and `component-type-unknown` claims only colon namespaces. The SDUI manifest does not move (`@object-ui/app-shell` is not one of its registry modules). diff --git a/content/docs/frontend/data-source.mdx b/content/docs/frontend/data-source.mdx index aa09544ec15..dac3281245e 100644 --- a/content/docs/frontend/data-source.mdx +++ b/content/docs/frontend/data-source.mdx @@ -324,6 +324,9 @@ the same URL make one request, even when the entry's read settled first: Outside such a scope nothing is kept beyond the request in flight: a page that mounts again reads again. -The console's product-page blocks — `hero`, `stat`, `usage-bar`, `checklist` and -`tile-grid` — accept this binding in their arms; see the `@object-ui/app-shell` -README. +The console's product-page blocks — `hero`, `stat`, `usage-bar`, `checklist`, +`tile-grid` and `row-table` — accept this binding in their arms; see the +`@object-ui/app-shell` README. `row-table` draws every row of a list in the +answer as a table: `rows: '${data.actors}'` names the list, and each column +declares a `path` into one row, a `label`, and a `format` of `text`, `datetime` +or `enum`. diff --git a/content/docs/ui/pages.mdx b/content/docs/ui/pages.mdx index 8e3027adb2d..9e01f9ea5ff 100644 --- a/content/docs/ui/pages.mdx +++ b/content/docs/ui/pages.mdx @@ -399,7 +399,7 @@ The API binding's rules: - **Same-origin only.** `read.url` must open with a single `/`. An absolute URL of any scheme (`https:`, `mailto:`, `javascript:`, …), a protocol-relative `//host`, a backslash the browser reads as a slash, a space or control character, and a relative path such as `./home` are all refused when the page is parsed (`definePage()`, `os validate`, `os build`), with the reason. - **No credentials in metadata.** The console reads the endpoint with its own signed-in fetch, so the read block has no `headers`, and a credential key such as `headers`, `credentials` or `token` is refused. - **Reads only.** `read.method` is optional and accepts `GET` alone; there is no `write` block. -- **Rendered by the console.** The console reads the binding on every page element and binds the selected value as `data`: in the element's expression holes (`${data.used}`), in its `visibleWhen`, and in every element nested inside it. The console's generic `hero`, `stat`, `usage-bar`, `checklist` and `tile-grid` blocks are built to take it as their `dataSource`. While the read is in flight the element shows a loading panel, and a refused binding or a failed read shows an error panel instead. +- **Rendered by the console.** The console reads the binding on every page element and binds the selected value as `data`: in the element's expression holes (`${data.used}`), in its `visibleWhen`, and in every element nested inside it. The console's generic `hero`, `stat`, `usage-bar`, `checklist`, `tile-grid` and `row-table` blocks are built to take it as their `dataSource`; `row-table` lists the rows of an array in the answer as a table, with declared columns (`path`, `label`, and a `format` of `text`, `datetime` or `enum`). While the read is in flight the element shows a loading panel, and a refused binding or a failed read shows an error panel instead. #### Saved views and the object binding diff --git a/ui/packages/app-shell/README.md b/ui/packages/app-shell/README.md index d56a8c7881b..f467e773a18 100644 --- a/ui/packages/app-shell/README.md +++ b/ui/packages/app-shell/README.md @@ -503,7 +503,7 @@ See the full table in [ADR-0059](../../docs/adr/0059-action-params-shared-field- ## Product-page blocks -Five generic blocks for the pages a product composes as metadata (a product's +Six generic blocks for the pages a product composes as metadata (a product's welcome page, a CRM's sales home), registered by this package and named for what they draw. Each reads its props from the node's `properties`; copy is a string or an inline translation map (`{ en, "zh-CN" }`), resolved in the @@ -516,6 +516,7 @@ viewer's language. | `usage-bar` | how much of a limit is used | `label`, `used`, `limit?` (absent or `0` = unlimited: no bar), `unit?` | | `checklist` | steps that tick as they are done | `items: [{ label, done, action? }]`, `collapsedWhenDone?` (draw nothing once every step is done) | | `tile-grid` | the console home's launcher tiles | `items: [{ label, href, icon?, caption? }]`, `addTile?: { label, href }` | +| `row-table` | the rows a bound list holds, as a table | `rows` (a list, or a `${…}` hole naming one), `columns: [{ path, label, format?, enum? }]`, `emptyLabel?` | Any of them can carry the spec's API binding, and then read values from the answer through `${…}` holes: @@ -528,6 +529,32 @@ answer through `${…}` holes: } ``` +`row-table` draws every row, its columns in the order written. A column's +`path` is a dotted path into one row (`owner.name`), its `label` the heading, +and its `format` one of `text` (the default, drawn as written), `datetime` (an +instant in the viewer's display locale and time zone, the `datetime` field +cell's face) or `enum` (the label `enum: { value: label }` names; a value the +map does not name is drawn as written). A field the row lacks, `null` or empty +draws `—`; an empty list draws `emptyLabel` ("No rows to display" when +omitted). A `rows` hole that resolves to anything but a list, or a column the +block cannot draw, draws the binding's error panel instead of an empty table: + +```json +{ + "type": "row-table", + "dataSource": { "provider": "api", "read": { "url": "/api/v1/ai/actors" }, "path": "data" }, + "properties": { + "rows": "${data.actors}", + "columns": [ + { "path": "name", "label": { "en": "Name", "zh-CN": "名称" } }, + { "path": "status", "label": "Status", "format": "enum", "enum": { "active": "Active", "paused": "Paused" } }, + { "path": "lastRun.at", "label": "Last run", "format": "datetime" } + ], + "emptyLabel": { "en": "No agents yet" } + } +} +``` + The read, its loading and error states, and the `data` root are `SchemaRenderer`'s (see "Binding a page element to an API endpoint" in the data source guide). `ConnectedShell` keeps one open's reads (`ElementApiOpenScope`, diff --git a/ui/packages/app-shell/src/console/blocks/__tests__/productBlocks-namespace-13301.test.tsx b/ui/packages/app-shell/src/console/blocks/__tests__/productBlocks-namespace-13301.test.tsx index 5bba094a007..a6309e95027 100644 --- a/ui/packages/app-shell/src/console/blocks/__tests__/productBlocks-namespace-13301.test.tsx +++ b/ui/packages/app-shell/src/console/blocks/__tests__/productBlocks-namespace-13301.test.tsx @@ -39,7 +39,8 @@ const warnings = vi.hoisted(() => { import '../productBlocks'; -const HOME_BLOCKS = ['hero', 'stat', 'usage-bar', 'checklist', 'tile-grid'] as const; +// `row-table` (#31856) joined the five, registered the same way. +const HOME_BLOCKS = ['hero', 'stat', 'usage-bar', 'checklist', 'tile-grid', 'row-table'] as const; const DEPRECATED = /Registering component "([^"]+)" without a namespace is deprecated/; @@ -49,7 +50,7 @@ afterAll(() => { }); describe('console home blocks register under `app-shell` (objectui#13301)', () => { - it('logs no deprecation line for the five blocks when the module loads', () => { + it('logs no deprecation line for the blocks when the module loads', () => { const named = warnings.seen .map((line) => DEPRECATED.exec(line)?.[1]) .filter((type): type is string => Boolean(type)); @@ -94,6 +95,7 @@ describe('a page authoring the bare key still draws each block (objectui#13301)' ['usage-bar', { type: 'usage-bar', properties: { label: 'Storage', used: 256, limit: 1024 } }, 'Storage'], ['checklist', { type: 'checklist', properties: { items: [{ label: 'Create an environment', done: false }] } }, 'Create an environment'], ['tile-grid', { type: 'tile-grid', properties: { items: [{ label: 'CRM', href: '/apps/crm' }] } }, 'CRM'], + ['row-table', { type: 'row-table', properties: { rows: [{ name: 'Ada' }], columns: [{ path: 'name', label: 'Name' }] } }, 'Ada'], ]; it.each(pages)('`%s`', (_block, schema, text) => { diff --git a/ui/packages/app-shell/src/console/blocks/__tests__/rowTable-31856.test.tsx b/ui/packages/app-shell/src/console/blocks/__tests__/rowTable-31856.test.tsx new file mode 100644 index 00000000000..658df041603 --- /dev/null +++ b/ui/packages/app-shell/src/console/blocks/__tests__/rowTable-31856.test.tsx @@ -0,0 +1,139 @@ +/** + * 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. + */ + +/** + * `row-table` (#31856): the rows a page `api` binding answers, as a table, + * rendered through the real `SchemaRenderer` with the binding read through the + * host fetch on `SchemaRendererContext.apiFetch`. + */ + +import { afterEach, describe, expect, it, vi } from 'vitest'; +import { cleanup, render, screen, waitFor, within } from '@testing-library/react'; +import React from 'react'; +import { MemoryRouter } from 'react-router-dom'; +import { ComponentRegistry, formatDateTime, setDisplayTimeZone } from '@object-ui/core'; +import { I18nProvider } from '@object-ui/i18n'; +import { SchemaRenderer, SchemaRendererContext } from '@object-ui/react'; +import type { DeclaredNode } from '@object-ui/types'; +import '../productBlocks'; + +const ACTORS = { + success: true, + data: { + actors: [ + { name: 'Ada', status: 'active', lastRun: { at: '2026-11-09T08:30:00Z' } }, + { name: 'Grace', status: 'paused', lastRun: null }, + { name: 'Linus', status: 'retired' }, + ], + none: [], + summary: { count: 3 }, + }, +}; + +const BINDING = { provider: 'api', read: { url: '/api/v1/ai/actors' }, path: 'data' } as const; + +const COLUMNS = [ + { path: 'name', label: { en: 'Name', 'zh-CN': '名称' } }, + { path: 'status', label: 'Status', format: 'enum', enum: { active: { en: 'Active' }, paused: 'Paused' } }, + { path: 'lastRun.at', label: 'Last run', format: 'datetime' }, +]; + +function renderTable(properties: Record, bound = true) { + const apiFetch = vi.fn(async () => new Response(JSON.stringify(ACTORS), { status: 200 })); + const schema = { type: 'row-table', ...(bound ? { dataSource: BINDING } : {}), properties } as unknown as DeclaredNode; + render( + + + + + + + , + ); + return apiFetch; +} + +/** The cell texts of one body row. */ +function cells(row: number): string[] { + return within(screen.getByTestId(`row-table-row-${row}`)) + .getAllByRole('cell') + .map((cell) => cell.textContent ?? ''); +} + +afterEach(() => { + cleanup(); + setDisplayTimeZone(undefined); +}); + +describe('row-table (#31856)', () => { + it('registers with declared inputs and the API binding input', () => { + const config = ComponentRegistry.getConfig('row-table'); + const names = (config?.inputs ?? []).map((input) => input.name); + expect(names).toEqual(['rows', 'columns', 'emptyLabel', 'dataSource']); + for (const input of config?.inputs ?? []) expect(input.description, input.name).toBeTruthy(); + }); + + it('draws every row the binding answers, its columns in authored order', async () => { + const apiFetch = renderTable({ rows: '${data.actors}', columns: COLUMNS }); + await waitFor(() => expect(screen.getByTestId('row-table-row-2')).toBeInTheDocument()); + expect(apiFetch).toHaveBeenCalledTimes(1); + expect(screen.getAllByRole('columnheader').map((head) => head.textContent)).toEqual(['Name', 'Status', 'Last run']); + expect(cells(0)[0]).toBe('Ada'); + expect(cells(1)[0]).toBe('Grace'); + expect(cells(2)[0]).toBe('Linus'); + }); + + it('draws an enum value through its label map, and a value the map does not name as written', async () => { + renderTable({ rows: '${data.actors}', columns: COLUMNS }); + await waitFor(() => expect(screen.getByTestId('row-table-row-2')).toBeInTheDocument()); + expect(cells(0)[1]).toBe('Active'); + expect(cells(1)[1]).toBe('Paused'); + expect(cells(2)[1]).toBe('retired'); + }); + + it('draws a datetime as an instant in the display time zone', async () => { + setDisplayTimeZone('Asia/Tokyo'); + renderTable({ rows: '${data.actors}', columns: COLUMNS }); + await waitFor(() => expect(screen.getByTestId('row-table-row-0')).toBeInTheDocument()); + const shown = cells(0)[2]; + // The one date-display path, in the declared zone: 08:30Z is 17:30 in Tokyo. + expect(shown).toBe(formatDateTime('2026-11-09T08:30:00Z', { locale: 'en', style: 'compact' })); + expect(shown).toMatch(/17:30|5:30/); + expect(shown).not.toMatch(/08:30|8:30/); + }); + + it('draws "—" for a field the row lacks or holds null', async () => { + renderTable({ rows: '${data.actors}', columns: COLUMNS }); + await waitFor(() => expect(screen.getByTestId('row-table-row-2')).toBeInTheDocument()); + expect(cells(1)[2]).toBe('—'); + expect(cells(2)[2]).toBe('—'); + }); + + it('draws the authored empty label for an empty list, else the bundle\'s', async () => { + renderTable({ rows: '${data.none}', columns: COLUMNS, emptyLabel: { en: 'No agents yet' } }); + expect((await screen.findByTestId('row-table-empty')).textContent).toBe('No agents yet'); + cleanup(); + renderTable({ rows: [], columns: COLUMNS }, false); + expect(screen.getByTestId('row-table-empty').textContent).toBe('No rows to display'); + }); + + it('refuses a hole that resolves to a non-list with the error panel, never the empty state', async () => { + renderTable({ rows: '${data.summary}', columns: COLUMNS, emptyLabel: 'No agents yet' }); + const panel = await screen.findByTestId('row-table-datasource-error'); + expect(panel).toHaveAttribute('role', 'alert'); + expect(panel.textContent).toContain('rows resolved to an object'); + expect(screen.queryByTestId('row-table-empty')).toBeNull(); + }); + + it('refuses a column format it does not draw with the error panel', () => { + renderTable({ rows: [{ name: 'Ada' }], columns: [{ path: 'name', label: 'Name', format: 'currency' }] }, false); + const panel = screen.getByTestId('row-table-datasource-error'); + expect(panel.textContent).toContain('columns[0].format "currency"'); + expect(screen.queryByTestId('row-table-block')).toBeNull(); + }); +}); diff --git a/ui/packages/app-shell/src/console/blocks/productBlocks.tsx b/ui/packages/app-shell/src/console/blocks/productBlocks.tsx index 2f944edbf05..73c15d8c3a2 100644 --- a/ui/packages/app-shell/src/console/blocks/productBlocks.tsx +++ b/ui/packages/app-shell/src/console/blocks/productBlocks.tsx @@ -1,7 +1,7 @@ /** * Product-page blocks (objectui#12197) * - * Five generic SDUI blocks for the pages a product composes as metadata — + * Six generic SDUI blocks for the pages a product composes as metadata — * a product's welcome page, a CRM's sales home — named for what they draw * (ADR-0060 rule 2), never for the product that asked for them: * @@ -11,6 +11,7 @@ * - `usage-bar` — how much of a limit is used, as a bar. * - `checklist` — steps that tick as they are done. * - `tile-grid` — the console home's launcher tiles, as a block. + * - `row-table` — the rows a bound list holds, as a table (#31856). * * ## Props, and bound data * @@ -44,6 +45,11 @@ * - `tile-grid` draws the apps strip's tile (`../home/launcherTile.ts`, moved * out of `HomeAppsStrip` string for string), and leads with a router * `Link`, as the strip does. + * - `row-table` draws the `Table` primitives (`@object-ui/components`), reads + * each column's `path` with the binding's own path reader + * (`selectElementApiPath`), formats `datetime` through the one date-display + * path (`formatDateTime`, `@object-ui/core`, the `datetime` cell's face), + * and draws a list it cannot read with the binding's error panel. * * Types and arms: `@object-ui/types` `product-blocks.ts` / * `zod/product-blocks.zod.ts`. @@ -53,9 +59,27 @@ import * as React from 'react'; import { Link } from 'react-router-dom'; import { Check, CheckCircle2, Circle, Copy, Plus } from 'lucide-react'; -import { ComponentRegistry } from '@object-ui/core'; -import { SchemaRenderer, useConfigBagEvaluator } from '@object-ui/react'; -import { Badge, Button, Card, CardContent, Progress, cn } from '@object-ui/components'; +import { ComponentRegistry, formatDateTime, getDisplayTimeZone, subscribeDisplayTimeZone } from '@object-ui/core'; +import { + ElementDataSourceErrorPanel, + SchemaRenderer, + selectElementApiPath, + useConfigBagEvaluator, +} from '@object-ui/react'; +import { + Badge, + Button, + Card, + CardContent, + Progress, + Table, + TableBody, + TableCell, + TableHead, + TableHeader, + TableRow, + cn, +} from '@object-ui/components'; import { formatDisplayNumber, pickLocalized, useDisplayLocale, useObjectTranslation } from '@object-ui/i18n'; import type { DeclaredNode } from '@object-ui/types'; import { getIcon } from '../../utils/getIcon.js'; @@ -338,6 +362,150 @@ export function TileGridBlock({ schema, className }: BlockRendererProps) { ); } +// --------------------------------------------------------------------------- +// row-table +// --------------------------------------------------------------------------- + +/** The formats a `row-table` column draws; anything else is refused. */ +const ROW_TABLE_FORMATS = new Set(['text', 'datetime', 'enum']); + +/** One column, read from the props bag. */ +interface RowTableColumn { + path: string; + label: unknown; + format: 'text' | 'datetime' | 'enum'; + enum?: Record; +} + +/** What `rows` resolved to, named for the refusal sentence. */ +function kindOf(value: unknown): string { + if (value === undefined) return 'nothing'; + if (value === null) return 'null'; + if (typeof value === 'string') return `the text "${value}"`; + return Array.isArray(value) ? 'a list' : typeof value === 'object' ? 'an object' : `a ${typeof value}`; +} + +/** + * The block's rows and columns, or the one sentence saying why it cannot draw + * them. A list it cannot read is refused, never drawn as the empty state: an + * empty table would hide a hole that names the wrong member. + */ +export function readRowTable( + props: Record, +): { ok: true; rows: unknown[]; columns: RowTableColumn[] } | { ok: false; message: string } { + const rows = props.rows; + if (!Array.isArray(rows)) { + return { ok: false, message: `row-table: rows resolved to ${kindOf(rows)}, not a list of rows.` }; + } + const authored = props.columns; + if (!Array.isArray(authored) || authored.length === 0) { + return { ok: false, message: 'row-table: columns is not a list of at least one column.' }; + } + const columns: RowTableColumn[] = []; + for (const [index, column] of authored.entries()) { + const at = `row-table: columns[${index}]`; + if (!isRecord(column) || typeof column.path !== 'string' || column.path === '') { + return { ok: false, message: `${at} has no path.` }; + } + const format = column.format ?? 'text'; + if (typeof format !== 'string' || !ROW_TABLE_FORMATS.has(format)) { + return { ok: false, message: `${at}.format "${String(format)}" is not one of text, datetime, enum.` }; + } + if (format === 'enum' && !isRecord(column.enum)) { + return { ok: false, message: `${at} has format enum and no enum label map.` }; + } + columns.push({ + path: column.path, + label: column.label, + format: format as RowTableColumn['format'], + enum: isRecord(column.enum) ? column.enum : undefined, + }); + } + return { ok: true, rows, columns }; +} + +/** A cell's text: `—` for a field the row lacks, `null` or `''`. */ +function rowTableCell( + row: unknown, + column: RowTableColumn, + language: string, + locale: string | undefined, +): string { + const selected = selectElementApiPath(row, column.path); + const value = selected.found ? selected.value : undefined; + if (value === undefined || value === null || value === '') return '—'; + if (column.format === 'datetime') { + return typeof value === 'string' || typeof value === 'number' + ? formatDateTime(value, { locale, style: 'compact' }) + : '—'; + } + if (column.format === 'enum' && (typeof value === 'string' || typeof value === 'number')) { + const key = String(value); + if (column.enum && Object.prototype.hasOwnProperty.call(column.enum, key)) { + const label = pickLocalized(column.enum[key], language); + if (label) return label; + } + return key; + } + return typeof value === 'object' ? JSON.stringify(value) : String(value); +} + +export function RowTableBlock({ schema, className }: BlockRendererProps) { + const props = propsOf(schema); + const { t, language } = useObjectTranslation(); + const locale = useDisplayLocale(); + // A datetime cell is an instant in the display zone: draw again when the + // host declares another one. + React.useSyncExternalStore(subscribeDisplayTimeZone, getDisplayTimeZone, getDisplayTimeZone); + const read = readRowTable(props); + if (!read.ok) { + return ( + + ); + } + const { rows, columns } = read; + if (rows.length === 0) { + return ( +

+ {pickLocalized(props.emptyLabel, language) || t('table.noRows', { defaultValue: 'No rows to display' })} +

+ ); + } + return ( +
+ + + + {columns.map((column, index) => ( + + {pickLocalized(column.label, language)} + + ))} + + + + {rows.map((row, rowIndex) => ( + + {columns.map((column, index) => ( + + {rowTableCell(row, column, language, locale)} + + ))} + + ))} + +
+
+ ); +} + // --------------------------------------------------------------------------- // Registrations // --------------------------------------------------------------------------- @@ -419,3 +587,15 @@ ComponentRegistry.register('tile-grid', TileGridBlock, { API_BINDING_INPUT, ], }); + +ComponentRegistry.register('row-table', RowTableBlock, { + namespace: 'app-shell', + label: 'Row table', + category: 'content', + inputs: [ + { name: 'rows', type: ['array', 'string'], of: 'object', required: true, description: 'The rows, or a ${…} hole naming a list of them in the bound data. Every row is drawn, in order. A hole that resolves to anything but a list draws an error panel, never the empty state.' }, + { name: 'columns', type: 'array', of: 'object', required: true, description: 'The columns, in order: { path, label, format?, enum? }. path is a dotted path into one row (owner.name); label is a string or an inline translation map. format is text (the default, drawn as written), datetime (an instant in the viewer\'s display locale and time zone) or enum (the value\'s label from enum: { value: label }; a value the map does not name is drawn as written). A field the row lacks, null or empty draws "—".' }, + { name: 'emptyLabel', type: ['string', 'object'], description: 'What the table says when there are no rows; "No rows to display" when omitted.' }, + API_BINDING_INPUT, + ], +}); diff --git a/ui/packages/app-shell/src/index.ts b/ui/packages/app-shell/src/index.ts index 2a81e810c12..65070383cb9 100644 --- a/ui/packages/app-shell/src/index.ts +++ b/ui/packages/app-shell/src/index.ts @@ -367,7 +367,7 @@ import './console/connect/ConnectAgentWidget.js'; import './console/connect/ManagedPersonAssistants.js'; import './console/security/UserEffectiveAccess.js'; // Generic product-page blocks — hero, stat, usage-bar, checklist, tile-grid -// (objectui#12197). +// (objectui#12197), and row-table (#31856). import './console/blocks/productBlocks.js'; // SDUI widget for the Cloud welcome page's seeded workspace-timezone line (objectui#11930). import './console/home/CloudWorkspaceTimezoneNotice.js'; diff --git a/ui/packages/cli/src/__tests__/product-blocks-namespace-13301.test.ts b/ui/packages/cli/src/__tests__/product-blocks-namespace-13301.test.ts index 9501134cf0f..84da49edbb4 100644 --- a/ui/packages/cli/src/__tests__/product-blocks-namespace-13301.test.ts +++ b/ui/packages/cli/src/__tests__/product-blocks-namespace-13301.test.ts @@ -27,7 +27,8 @@ import { validateAuthoredDocument } from '../utils/authoring-face.js'; import { KNOWN_SCHEMA_TYPES } from '../utils/known-schema-types.js'; import { validate } from '../commands/validate.js'; -const HOME_BLOCKS = ['hero', 'stat', 'usage-bar', 'checklist', 'tile-grid'] as const; +// `row-table` (#31856) joined the five, registered the same way. +const HOME_BLOCKS = ['hero', 'stat', 'usage-bar', 'checklist', 'tile-grid', 'row-table'] as const; /** Is `type` unclaimed by every arm of the validator's root union? */ function refusedAtType(type: string): boolean { diff --git a/ui/packages/cli/src/__tests__/registered-types-validate-ratchet-10859.test.ts b/ui/packages/cli/src/__tests__/registered-types-validate-ratchet-10859.test.ts index 52d7d52cb85..eb1a298e5ba 100644 --- a/ui/packages/cli/src/__tests__/registered-types-validate-ratchet-10859.test.ts +++ b/ui/packages/cli/src/__tests__/registered-types-validate-ratchet-10859.test.ts @@ -176,8 +176,13 @@ const REFUSED_AT_TYPE = 0; * objectui#13449: minus `ui:html`, the namespaced twin of the raw-HTML `html` * node type, retired from the registry with its renderer; the armed bare `html` * left with its arm, which became a refusal, so it moved nothing here. + * #31856: plus `app-shell:row-table`, the sixth console product block's + * namespaced twin, registered the way objectui#13301 registers the five and + * refused at `type` for the same reason: the bare `row-table` is the one + * authorable key, and its arm landed with it. A named stopgap raise of that + * one key; any other rise is still a regression. */ -const NAMESPACED_REFUSED_AT_TYPE = 306; +const NAMESPACED_REFUSED_AT_TYPE = 307; /** The bare registry keys — the population the card measured. */ const BARE_KEYS = KNOWN_SCHEMA_TYPES.filter((key) => !key.includes(':')); diff --git a/ui/packages/cli/src/utils/known-schema-types.ts b/ui/packages/cli/src/utils/known-schema-types.ts index 8598be1cbe0..5e60be00822 100644 --- a/ui/packages/cli/src/utils/known-schema-types.ts +++ b/ui/packages/cli/src/utils/known-schema-types.ts @@ -51,6 +51,7 @@ export const KNOWN_SCHEMA_TYPES: readonly string[] = [ 'app-shell:cloud:ai-model-status', 'app-shell:hero', 'app-shell:mcp:connect-agent', + 'app-shell:row-table', 'app-shell:stat', 'app-shell:tile-grid', 'app-shell:usage-bar', @@ -406,6 +407,7 @@ export const KNOWN_SCHEMA_TYPES: readonly string[] = [ 'report-designer', 'report-viewer', 'resizable', + 'row-table', 'scroll-area', 'section', 'security:effective-access', diff --git a/ui/packages/types/src/__tests__/product-block-arms-12197.test.ts b/ui/packages/types/src/__tests__/product-block-arms-12197.test.ts index 84420424c62..6ff3329e341 100644 --- a/ui/packages/types/src/__tests__/product-block-arms-12197.test.ts +++ b/ui/packages/types/src/__tests__/product-block-arms-12197.test.ts @@ -7,8 +7,9 @@ */ /** - * The arms of the five product-page blocks (objectui#12197): `hero`, `stat`, - * `usage-bar`, `checklist` and `tile-grid`, registered by `@object-ui/app-shell`. + * The arms of the product-page blocks: `hero`, `stat`, `usage-bar`, + * `checklist` and `tile-grid` (objectui#12197), and `row-table` (#31856), + * registered by `@object-ui/app-shell`. * * Each arm accepts the node a product page authors — props in `properties`, * copy as a string or an inline translation map, the spec's API binding as @@ -61,6 +62,19 @@ const FIXTURES = { addTile: { label: 'Add app', href: '/marketplace' }, }, }, + 'row-table': { + type: 'row-table', + dataSource: BINDING, + properties: { + rows: '${data.actors}', + columns: [ + { path: 'name', label: { en: 'Name', 'zh-CN': '名称' } }, + { path: 'lastRun.at', label: 'Last run', format: 'datetime' }, + { path: 'status', label: 'Status', format: 'enum', enum: { active: 'Active', paused: { en: 'Paused' } } }, + ], + emptyLabel: { en: 'No agents yet' }, + }, + }, } as const; describe('product-page block arms (objectui#12197)', () => { @@ -105,4 +119,39 @@ describe('product-page block arms (objectui#12197)', () => { it('refuses a checklist with no steps', () => { expect(safeValidateSchema({ type: 'checklist', properties: { items: [] } }).success).toBe(false); }); + + describe('row-table (#31856)', () => { + const column = (extra: Record) => ({ + type: 'row-table', + properties: { rows: [{ name: 'a' }], columns: [{ path: 'name', label: 'Name', ...extra }] }, + }); + + it('accepts literal rows', () => { + expect(safeValidateSchema(column({})).success).toBe(true); + }); + + it('refuses a format it does not draw', () => { + expect(safeValidateSchema(column({ format: 'currency' })).success).toBe(false); + }); + + it('refuses an enum column with no label map, and a label map on a column that is not enum', () => { + expect(safeValidateSchema(column({ format: 'enum' })).success).toBe(false); + expect(safeValidateSchema(column({ format: 'text', enum: { a: 'A' } })).success).toBe(false); + }); + + it('refuses a column path that is not a dotted path', () => { + expect(safeValidateSchema(column({ path: '${data.name}' })).success).toBe(false); + expect(safeValidateSchema(column({ path: 'owner[0]' })).success).toBe(false); + }); + + it('refuses an undeclared column key, such as the prose word `header`', () => { + expect(safeValidateSchema(column({ header: 'Name' })).success).toBe(false); + }); + + it('refuses a table with no columns, and rows that are a partial hole', () => { + expect(safeValidateSchema({ type: 'row-table', properties: { rows: [], columns: [] } }).success).toBe(false); + const partial = { type: 'row-table', properties: { rows: 'rows: ${data.actors}', columns: [{ path: 'a', label: 'A' }] } }; + expect(safeValidateSchema(partial).success).toBe(false); + }); + }); }); diff --git a/ui/packages/types/src/__tests__/zod-mirror-parity.test.ts b/ui/packages/types/src/__tests__/zod-mirror-parity.test.ts index 47b0cb12565..eb67e7c09e8 100644 --- a/ui/packages/types/src/__tests__/zod-mirror-parity.test.ts +++ b/ui/packages/types/src/__tests__/zod-mirror-parity.test.ts @@ -986,7 +986,7 @@ import { BaseSchema, ComponentConfigSchema, ComponentInputSchema, ComponentMetaS import { CloudWorkspaceTimezoneNoticeSchema } from '../zod/cloud.zod.js'; import { McpAuthorizedAssistantsSchema } from '../zod/mcp-authorized-assistants.zod.js'; import { SecurityEffectiveAccessSchema } from '../zod/security-effective-access.zod.js'; -import { ChecklistBlockItemSchema, ChecklistBlockSchema, HeroBlockSchema, StatBlockSchema, TileGridBlockAddTileSchema, TileGridBlockItemSchema, TileGridBlockSchema, UsageBarBlockSchema } from '../zod/product-blocks.zod.js'; +import { ChecklistBlockItemSchema, ChecklistBlockSchema, HeroBlockSchema, RowTableBlockSchema, RowTableColumnSchema, StatBlockSchema, TileGridBlockAddTileSchema, TileGridBlockItemSchema, TileGridBlockSchema, UsageBarBlockSchema } from '../zod/product-blocks.zod.js'; import { RecordApprovalDecisionBlockSchema } from '../zod/record-approval-decision.zod.js'; import { RecordApprovalsBlockSchema, RecordAttachmentsBlockSchema } from '../zod/record-panels.zod.js'; import { CalendarEventSchema, CalendarViewSchema, CarouselItemSchema, CarouselSchema, ChatbotSchema, ChatbotEnhancedSchema, ChatbotFloatingSchema, ChatMessageSchema, ChatMessageSourceSchema, ChatToolInvocationSchema, DashboardComponentSchema, DashboardConfigSchema, DashboardWidgetConfigSchema, DashboardWidgetLayoutSchema, DashboardWidgetSchema, FilterBuilderSchema, FilterFieldSchema, KanbanCardSchema, KanbanColumnSchema, CardTemplateSchema, FilterGroupSchema } from '../zod/complex.zod.js'; @@ -1008,7 +1008,7 @@ import type { BaseSchema as Ts_BaseSchema, ComponentConfig as Ts_ComponentConfig import type { CloudWorkspaceTimezoneNoticeSchema as Ts_CloudWorkspaceTimezoneNoticeSchema } from '../cloud'; import type { McpAuthorizedAssistantsSchema as Ts_McpAuthorizedAssistantsSchema } from '../mcp-authorized-assistants'; import type { SecurityEffectiveAccessSchema as Ts_SecurityEffectiveAccessSchema } from '../security-effective-access'; -import type { ChecklistBlockItem as Ts_ChecklistBlockItem, ChecklistBlockSchema as Ts_ChecklistBlockSchema, HeroBlockSchema as Ts_HeroBlockSchema, StatBlockSchema as Ts_StatBlockSchema, TileGridBlockAddTile as Ts_TileGridBlockAddTile, TileGridBlockItem as Ts_TileGridBlockItem, TileGridBlockSchema as Ts_TileGridBlockSchema, UsageBarBlockSchema as Ts_UsageBarBlockSchema } from '../product-blocks'; +import type { ChecklistBlockItem as Ts_ChecklistBlockItem, ChecklistBlockSchema as Ts_ChecklistBlockSchema, HeroBlockSchema as Ts_HeroBlockSchema, RowTableBlockSchema as Ts_RowTableBlockSchema, RowTableColumn as Ts_RowTableColumn, StatBlockSchema as Ts_StatBlockSchema, TileGridBlockAddTile as Ts_TileGridBlockAddTile, TileGridBlockItem as Ts_TileGridBlockItem, TileGridBlockSchema as Ts_TileGridBlockSchema, UsageBarBlockSchema as Ts_UsageBarBlockSchema } from '../product-blocks'; import type { RecordApprovalDecisionBlockSchema as Ts_RecordApprovalDecisionBlockSchema } from '../record-approval-decision'; import type { RecordApprovalsBlockSchema as Ts_RecordApprovalsBlockSchema, RecordAttachmentsBlockSchema as Ts_RecordAttachmentsBlockSchema } from '../record-panels'; import type { CalendarEvent as Ts_CalendarEvent, CalendarViewSchema as Ts_CalendarViewSchema, CarouselItem as Ts_CarouselItem, CarouselSchema as Ts_CarouselSchema, ChatbotSchema as Ts_ChatbotSchema, ChatbotEnhancedSchema as Ts_ChatbotEnhancedSchema, ChatbotFloatingSchema as Ts_ChatbotFloatingSchema, ChatMessage as Ts_ChatMessage, ChatMessageSource as Ts_ChatMessageSource, ChatToolInvocation as Ts_ChatToolInvocation, DashboardComponentSchema as Ts_DashboardComponentSchema, DashboardWidgetLayout as Ts_DashboardWidgetLayout, DashboardWidgetSchema as Ts_DashboardWidgetSchema, FilterBuilderSchema as Ts_FilterBuilderSchema, FilterField as Ts_FilterField, KanbanCard as Ts_KanbanCard, KanbanColumn as Ts_KanbanColumn, CardTemplate as Ts_CardTemplate } from '../complex'; @@ -1864,6 +1864,8 @@ const MIRRORS = { 'product-blocks.zod.ts#ChecklistBlockItemSchema': ChecklistBlockItemSchema, 'product-blocks.zod.ts#ChecklistBlockSchema': ChecklistBlockSchema, 'product-blocks.zod.ts#HeroBlockSchema': HeroBlockSchema, + 'product-blocks.zod.ts#RowTableBlockSchema': RowTableBlockSchema, + 'product-blocks.zod.ts#RowTableColumnSchema': RowTableColumnSchema, 'product-blocks.zod.ts#StatBlockSchema': StatBlockSchema, 'product-blocks.zod.ts#TileGridBlockAddTileSchema': TileGridBlockAddTileSchema, 'product-blocks.zod.ts#TileGridBlockItemSchema': TileGridBlockItemSchema, @@ -2071,6 +2073,8 @@ interface Declared { 'product-blocks.zod.ts#ChecklistBlockItemSchema': Ts_ChecklistBlockItem; 'product-blocks.zod.ts#ChecklistBlockSchema': Ts_ChecklistBlockSchema; 'product-blocks.zod.ts#HeroBlockSchema': Ts_HeroBlockSchema; + 'product-blocks.zod.ts#RowTableBlockSchema': Ts_RowTableBlockSchema; + 'product-blocks.zod.ts#RowTableColumnSchema': Ts_RowTableColumn; 'product-blocks.zod.ts#StatBlockSchema': Ts_StatBlockSchema; 'product-blocks.zod.ts#TileGridBlockAddTileSchema': Ts_TileGridBlockAddTile; 'product-blocks.zod.ts#TileGridBlockItemSchema': Ts_TileGridBlockItem; @@ -5381,6 +5385,8 @@ const SPEC_DERIVED_PAIRS: readonly string[] = [ 'product-blocks.zod.ts#ChecklistBlockItemSchema', 'product-blocks.zod.ts#ChecklistBlockSchema', 'product-blocks.zod.ts#HeroBlockSchema', + 'product-blocks.zod.ts#RowTableBlockSchema', + 'product-blocks.zod.ts#RowTableColumnSchema', 'product-blocks.zod.ts#StatBlockSchema', 'product-blocks.zod.ts#TileGridBlockAddTileSchema', 'product-blocks.zod.ts#TileGridBlockItemSchema', @@ -5407,7 +5413,7 @@ const ZOD_DIR = join(dirname(fileURLToPath(import.meta.url)), '..', 'zod'); * MINUEND under it had moved. Nothing failed on any of those days, because nothing * compared the registry to a number. objectui#7433 is that absence, not the digits. */ -const EXPECTED_MIRROR_PAIRS = 199; +const EXPECTED_MIRROR_PAIRS = 201; /** * A ledger this file can size from its own AST. `WiderThanDeclared` joined at diff --git a/ui/packages/types/src/index.ts b/ui/packages/types/src/index.ts index 95a6a430433..69fee66ce73 100644 --- a/ui/packages/types/src/index.ts +++ b/ui/packages/types/src/index.ts @@ -892,6 +892,7 @@ import type { UsageBarBlockSchema, ChecklistBlockSchema, TileGridBlockSchema, + RowTableBlockSchema, } from './product-blocks.js'; import type { RecordApprovalDecisionBlockSchema } from './record-approval-decision.js'; import type { RecordApprovalsBlockSchema, RecordAttachmentsBlockSchema } from './record-panels.js'; @@ -1048,6 +1049,10 @@ export type { TileGridBlockAddTile, TileGridBlockProps, TileGridBlockSchema, + // `row-table` (#31856), the sixth product block. + RowTableColumn, + RowTableBlockProps, + RowTableBlockSchema, } from './product-blocks.js'; export type { @@ -1174,7 +1179,9 @@ export type AnySchema = | StatBlockSchema | UsageBarBlockSchema | ChecklistBlockSchema - | TileGridBlockSchema; + | TileGridBlockSchema + // #31856 — landed with its zod arm. + | RowTableBlockSchema; /** * Utility type to extract the schema type from a type string. diff --git a/ui/packages/types/src/product-blocks.ts b/ui/packages/types/src/product-blocks.ts index 8318ed60d95..4662e603210 100644 --- a/ui/packages/types/src/product-blocks.ts +++ b/ui/packages/types/src/product-blocks.ts @@ -9,10 +9,11 @@ /** * @object-ui/types - Product-page blocks * - * The TypeScript twin of `zod/product-blocks.zod.ts` (objectui#12197): the five + * The TypeScript twin of `zod/product-blocks.zod.ts` (objectui#12197): the * product-neutral blocks `@object-ui/app-shell` registers for pages a product - * composes as metadata — `hero`, `stat`, `usage-bar`, `checklist` and - * `tile-grid` (ADR-0060 rule 2: a generic block, named for what it draws). + * composes as metadata — `hero`, `stat`, `usage-bar`, `checklist`, + * `tile-grid` and `row-table` (ADR-0060 rule 2: a generic block, named for + * what it draws). * * `@objectstack/spec` has no `ComponentPropsMap` row for these blocks, so * nothing is read by reference: every member below is a key the block's @@ -150,3 +151,33 @@ export interface TileGridBlockSchema extends BaseSchema { body?: never; children?: never; } + +/** + * One `row-table` column — `resultDialog.fields`' `path` / `label` / `format` + * vocabulary, with `datetime` and `enum` this block's own formats. + */ +export interface RowTableColumn { + /** Dotted path into one row, e.g. `owner.name`. */ + path: string; + label: I18nLabel; + /** `text` as written (the default), `datetime` as an instant, `enum` through `enum`. */ + format?: 'text' | 'datetime' | 'enum'; + /** For `format: 'enum'`: the label drawn for each value. */ + enum?: Record; +} + +/** `row-table`'s props bag. */ +export interface RowTableBlockProps { + rows: Array> | ProductBlockExpressionHole; + columns: RowTableColumn[]; + emptyLabel?: I18nLabel; +} + +/** `row-table` — the rows a bound list holds, as a table. */ +export interface RowTableBlockSchema extends BaseSchema { + type: 'row-table'; + properties: RowTableBlockProps; + dataSource?: ElementApiDataSource; + body?: never; + children?: never; +} diff --git a/ui/packages/types/src/zod/index.zod.ts b/ui/packages/types/src/zod/index.zod.ts index e3ec7440683..30c81b1f31b 100644 --- a/ui/packages/types/src/zod/index.zod.ts +++ b/ui/packages/types/src/zod/index.zod.ts @@ -471,6 +471,8 @@ export { TileGridBlockItemSchema, TileGridBlockAddTileSchema, TileGridBlockSchema, + RowTableColumnSchema, + RowTableBlockSchema, ProductBlockComponentSchema, } from './product-blocks.zod.js'; export type { ProductBlockComponentZodType } from './product-blocks.zod.js'; diff --git a/ui/packages/types/src/zod/product-blocks.zod.ts b/ui/packages/types/src/zod/product-blocks.zod.ts index 8aa3719f7b7..b1e584200df 100644 --- a/ui/packages/types/src/zod/product-blocks.zod.ts +++ b/ui/packages/types/src/zod/product-blocks.zod.ts @@ -9,9 +9,9 @@ /** * @object-ui/types/zod - Product-page block Zod Validators * - * The arms for the five product-neutral blocks `@object-ui/app-shell` registers - * for pages a product composes as metadata (objectui#12197): `hero`, `stat`, - * `usage-bar`, `checklist` and `tile-grid` + * The arms for the product-neutral blocks `@object-ui/app-shell` registers + * for pages a product composes as metadata: `hero`, `stat`, `usage-bar`, + * `checklist` and `tile-grid` (objectui#12197), and `row-table` (#31856) * (`console/blocks/productBlocks.tsx`). The TypeScript twin is * `../product-blocks.ts`. * @@ -210,6 +210,76 @@ export const TileGridBlockSchema = BaseSchema.extend({ children: retirementTombstone(neitherChannel('tile-grid', 'its tiles')), }); +/** + * A column's dotted `path` into one row: segments of letters, digits, `_` or + * `-` joined by single dots, a numeric segment indexing a list. The grammar of + * the binding's own `path`, which the renderer walks with the same reader + * (`selectElementApiPath`, `@object-ui/react`). + */ +const ROW_PATH_RE = /^[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)*$/; + +/** + * One `row-table` column. `path` / `label` / `format` are `resultDialog.fields`' + * vocabulary (`@objectstack/spec` `ActionSchema`), with `text` shared and + * `datetime` and `enum` this block's own members. + */ +export const RowTableColumnSchema = z + .strictObject({ + path: z + .string() + .regex(ROW_PATH_RE, { + error: () => + 'A `row-table` column `path` is a dotted path into one row, such as `owner.name` or `steps.0.at`: ' + + 'segments of letters, digits, `_` or `-` joined by single dots — no brackets, no `${…}`, no slashes.', + }) + .describe('Dotted path into one row, e.g. `owner.name`.'), + label: label('The column heading.'), + format: z + .enum(['text', 'datetime', 'enum']) + .optional() + .describe( + 'How the column draws its value: `text` as written (the default), `datetime` as an instant in the ' + + 'viewer\'s display locale and time zone, `enum` through the column\'s `enum` label map.', + ), + enum: z + .record(z.string(), label('The label drawn for this value.')) + .optional() + .describe('For `format: \'enum\'`: the label drawn for each value. A value the map does not name is drawn as written.'), + }) + .superRefine((column, ctx) => { + if (column.format === 'enum' && column.enum === undefined) { + ctx.addIssue({ + code: 'custom', + path: ['enum'], + message: 'A column with `format: \'enum\'` declares its `enum` label map: `{ value: label }`.', + }); + } + if (column.format !== 'enum' && column.enum !== undefined) { + ctx.addIssue({ + code: 'custom', + path: ['enum'], + message: '`enum` is read only by a column with `format: \'enum\'`: set that format, or drop `enum`.', + }); + } + }); + +/** `row-table` — the rows a bound list holds, as a table. */ +export const RowTableBlockSchema = BaseSchema.extend({ + type: z.literal('row-table'), + properties: z + .strictObject({ + rows: z + .union([z.array(z.record(z.string(), z.unknown())), expressionHole('a list of rows')]) + .describe('The rows, or a hole naming a list of them in the bound `data`. Every row is drawn.'), + columns: z.array(RowTableColumnSchema).min(1).describe('The columns, in order.'), + emptyLabel: label('What the table says when there are no rows.').optional(), + }) + .describe('The `row-table` props bag.'), + dataSource: apiBinding(), + body: retirementTombstone(neitherChannel('row-table', 'its rows')), + children: retirementTombstone(neitherChannel('row-table', 'its rows')), +}); + /** * Union of the product-block arms — the category member `AnyComponentSchema` * lists (objectui#12197). @@ -220,6 +290,7 @@ const ProductBlockComponentSchemaInferred = z.discriminatedUnion('type', [ UsageBarBlockSchema, ChecklistBlockSchema, TileGridBlockSchema, + RowTableBlockSchema, ]); /** From de4a8dcd32eccac567adf0c8c791d4df3faed28b Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 9 Nov 2026 09:00:31 +0000 Subject: [PATCH 2/2] fix(app-shell): row-table draws its own error face, not the object binding's panel The object-binding error panel marks a consumer of ElementDataSourceGate, which an api-bound product block is not. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01QsR2jTx4LkMSXMTUGZuzQW --- .../src/console/blocks/productBlocks.tsx | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/ui/packages/app-shell/src/console/blocks/productBlocks.tsx b/ui/packages/app-shell/src/console/blocks/productBlocks.tsx index 73c15d8c3a2..e95653038be 100644 --- a/ui/packages/app-shell/src/console/blocks/productBlocks.tsx +++ b/ui/packages/app-shell/src/console/blocks/productBlocks.tsx @@ -49,7 +49,7 @@ * each column's `path` with the binding's own path reader * (`selectElementApiPath`), formats `datetime` through the one date-display * path (`formatDateTime`, `@object-ui/core`, the `datetime` cell's face), - * and draws a list it cannot read with the binding's error panel. + * and draws a list it cannot read with the binding's error face. * * Types and arms: `@object-ui/types` `product-blocks.ts` / * `zod/product-blocks.zod.ts`. @@ -60,12 +60,7 @@ import * as React from 'react'; import { Link } from 'react-router-dom'; import { Check, CheckCircle2, Circle, Copy, Plus } from 'lucide-react'; import { ComponentRegistry, formatDateTime, getDisplayTimeZone, subscribeDisplayTimeZone } from '@object-ui/core'; -import { - ElementDataSourceErrorPanel, - SchemaRenderer, - selectElementApiPath, - useConfigBagEvaluator, -} from '@object-ui/react'; +import { SchemaRenderer, selectElementApiPath, useConfigBagEvaluator } from '@object-ui/react'; import { Badge, Button, @@ -459,12 +454,20 @@ export function RowTableBlock({ schema, className }: BlockRendererProps) { React.useSyncExternalStore(subscribeDisplayTimeZone, getDisplayTimeZone, getDisplayTimeZone); const read = readRowTable(props); if (!read.ok) { + // The binding's own error face and title (`SchemaRenderer`'s + // `ElementApiDataSourcePanel`), drawn here because this block, not the + // binding, finds the list unreadable. return ( - +
+

+ {t('element.component.apiUnreadable', { defaultValue: 'This component’s API data source could not be read' })} +

+

{read.message}

+
); } const { rows, columns } = read;