Skip to content
This repository was archived by the owner on Nov 4, 2026. It is now read-only.

Commit 401611b

Browse files
feat(types)!: the widget slot's metric-card arm declares MetricCard's registered inputs, and the widget component slot takes the arm (objectui#11467) (#11482)
Fixes #11467 Clause-②: yes Parent: objectui#8347, which keeps the index-signature removal. This PR is its F2 half and leaves the signature in place: every commit compiles with `BaseSchema`'s signature present. ## What this does Seat answer A, executed. `DashboardWidgetSlotComponentSchema` is the widget slot's component arm. It now declares `metric-card`'s registered inputs as members, typed as the props `MetricCard` reads. The zod twin declares the same members. The widget's legacy `component` slot takes the arm first, then any other node, on both faces. | member | TypeScript face | zod twin | source of the type | | --- | --- | --- | --- | | `title` | `string \| I18nLabel`, optional | spec `I18nLabelSchema` (defaults stripped), optional | `MetricCardProps.title` | | `value` | `string \| number`, **required** | `z.union` of string and number, required | `MetricCardProps.value`; the registration marks it `required` | | `icon` | `string`, optional | `z.string()`, optional | `MetricCardProps.icon` | | `trend` | `'up' \| 'down' \| 'neutral'`, optional | `z.enum` of the three, optional | the registration's enum, which equals `MetricCardProps.trend` | | `trendValue` | `string`, optional | `z.string()`, optional | `MetricCardProps.trendValue` | | `description` | inherited `BaseSchema` member, not restated | inherited | already `string \| I18nLabel` on both faces | `component` changes too. On the TypeScript face it is `DashboardWidgetSlotComponentSchema | SchemaNode`. On the zod face it is `z.union` of the arm and `BaseSchema`. **"By reference" across a package boundary.** `@object-ui/types` cannot import the registration or `MetricCard`, so the members are transcribed. The registering package holds them to both sources in `metricCardRegisteredInputsStrictFace-11022.test.ts`: - every registered input is a member of the arm on both faces; - every member the arm adds beyond `BaseSchema` and `layout` is a registered input; - `value` is required, as the registration marks it; - `trend` is exactly the registered enum; - a type-level equality between the arm's members and `MetricCardProps` for the six inputs. **No second spelling.** objectui#11022's side table of input names (`DASHBOARD_WIDGET_SLOT_REGISTERED_INPUTS`, through `declareRegisteredInputs`) recorded these same names so the strict walker could admit them. Every name it held is now a member, so the table, `declareRegisteredInputs` / `registeredInputsOf`, and the walker's branch for them are removed. They were internal and not exported, and the arm was their only caller. **A guard instead of the table's `satisfies`.** The arm's zod `type` is `z.enum` over `DASHBOARD_COMPONENT_WIDGET_TYPES` with a `satisfies` check against the one-member list `metric-card`. A second member of the closed set is therefore a compile error until the arm is split per component. Without the check, the new member would inherit the card's props. ## Measured first **H1. Which inputs `MetricCard` reads.** Two instruments, both at base `d93e53f5`. - *Type-checker census.* A TypeScript LanguageService ran over plugin-dashboard's own program. For each `MetricCardProps` member it looked up the references to the member symbol, then the uses of the destructured binding in the render body. `title`, `value`, `icon`, `trend`, `trendValue` and `description` are each destructured and read. A standalone `tsc` program over the same config: 0 errors. - *Runtime probe.* A real `DashboardRenderer` drew the card through the real `SchemaRenderer` and `ComponentRegistry`, one key removed at a time from a full card. The probe was a one-shot test file, deleted after the run. - Removing `title`, `value` or `description` changed the text. - Removing `icon` changed the drawn svg count. - Removing `trend` or `trendValue` changed the text, the svg count and the trend colour class. Each is drawn only together with the other. - Changing `trend` from up to down or neutral moved the colour class from green to red or yellow. - CONTROL: an unregistered key changed nothing drawn. It does land as a DOM attribute through `MetricCard`'s rest spread (objectui#4426, pre-existing). All five keys the card named are read. `description` is the sixth input and is already declared on `BaseSchema`. **H2. What each zod face judged at base.** - Tolerant face: the slot arm declared only `description` (through `BaseSchema`). The other five passed through the catchall unjudged. - Strict face: it admitted all six names from the side table. Five were judged by the catchall (`unknown`), so `trend: 'sideways'`, `title: 7` and `value: {}` all parsed on both faces. - The `component` slot was `BaseSchema` alone. The strict face therefore refused a card's `title`, `value`, `icon`, `trend` and `trendValue` there as `unrecognized_keys`. That includes the plugin-dashboard README's own legacy-envelope example. **H3.** PR objectui#11460 had landed (`9d1c0bff`) before this branch was cut from `d93e53f5`. **H4.** `zod-mirror-parity.test.ts` did not move. The file is untouched, and the types suite is green with it. `component` stays in `KnownDrift` (the primitive arms of `SchemaNode`), and so does `widgets`. ## Accept-set change (Clause-② yes) | document | tolerant face, before → after | strict face, before → after | TypeScript face, before → after | | --- | --- | --- | --- | | card in `widgets[]` with all inputs well-typed | accept → accept | accept → accept | compiles → compiles | | card in `widgets[]`, `trend: 'sideways'` / `title: 7` / `icon: 5` / `trendValue: 3` / `value: {}` | accept → **refuse** at that key | accept → **refuse** | compiles → **error** | | card in `widgets[]` with `icon`, `trend` or `trendValue` and no `value` | accept → **refuse** | accept → **refuse** | compiles → **error** | | card in `widgets[]` with only `title` / `description` / `layout` and no `value` | accept → accept (through the widget arm) | accept → accept | compiles → compiles (widget arm) | | card in a widget's `component` slot with its inputs (README example) | accept → accept | **refuse → accept** | compiles → compiles | | card in `component` with `trend: 'sideways'` | accept → accept (`BaseSchema` fallback) | refuse → refuse (now at the arm's `trend`) | compiles → compiles while the signature stands | | any other node in `component` (`{ type: 'chart' }`) | unchanged | unchanged | unchanged | | undeclared key on a card (`someProp`) | kept → kept | refused by name → refused by name | compiles → compiles while the signature stands | The TypeScript face gains no accepted key while the signature stands. The read type of `title` off a `widgets[]` entry moves from `any` to `string | I18nLabel`. Six consumer packages and two examples type-check unchanged; see Gates. ## The card's own reading, two legs The probe used the parent's mutation: only `BaseSchema`'s documented index signature deleted, with `@object-ui/types` rebuilt so that `dist/base.d.ts` keeps 1 signature. Then `tsc -p packages/types/tsconfig.test.json` and `pnpm check:doc-snippets` ran. The mutation went through `scripts/ablation-replace.mjs` from the objectstack checkout: anchor 1 → 0, blob `ce2bc9e31dc6` → `93c3221b8301`, restored to blob == HEAD, `git diff HEAD` empty. Both legs ran in this container, in two worktrees. | | base `d93e53f5` (control) | head `35a89136` | | --- | --- | --- | | types test program, errors in the arm-7952 and 9256 files | `value` x3 (README usage copy; `component` slot x2), `title` x1 (9256 accepting literal), plus probe `someProp` | probe `someProp`, probe `bogus` only | | `check:doc-snippets` | 70 of 776 blocks failed; 3 diagnostics in `packages/plugin-dashboard/README.md` | 68 of 776 failed; 0 in the plugin-dashboard README | | diagnostics, set difference | — | the 3 README diagnostics gone; nothing new | The `bogus` line at head is the arm-7952 file's "MEASURED LIMIT" constant. That corner shuts once the `component` card's `value` is declared, and the constant says to delete it then. This is noted for objectui#8347's last PR. The restore leg rebuilt types: `dist/base.d.ts` signatures 2, src 2, `git diff HEAD` 0. ## Reverse verification of the new pins Each leg deleted the members with `ablation-replace.mjs` on the committed tree (anchor 1 → 0, blob moved), ran, and restored (blob == HEAD, `git diff HEAD` empty). The direction was predicted before each run: red. - **zod members deleted.** vitest over the three pin files: 21 failed, 29 passed. Red: the grade pins, every value-judgment row, the `value`-required row, the arm-shape pin, the README-literal strict pin, plugin-dashboard UNDER-admission x6, DECLARED, typed-members, and the saved-layout strict parse. - **TypeScript members deleted.** The types test program: 10 errors. Six `Equal` pins went false: the five members and the zod twin. Three `@ts-expect-error` directives went unused (TS2578). The `title` read pin went false. ## Corpus re-judged `scripts/measure-strict-authoring-face.mjs` ran at base and at head over the schema catalog, the docs fences, the apps and the types sources: 610 documents, 2244 nodes. - Tolerant face: unchanged. `documentsRedTodayWholeDocument` is 23 → 23 and `nodesRedToday` 30 → 30. - The script's strict twin: 61 → 56 documents refused. The 5 are the three catalog dashboards and two docs dashboards with direct-slot cards. That script keeps its own walker, which never modelled the objectui#11022 side table, so at base it disagreed with the shipped strict face on exactly these 5. The shipped face accepted them at base and accepts them now. With the table gone, the script and the face agree. - Every `metric-card` in the corpus carries a string `value` and a `trend` from the three, so no document's verdict moved on the shipped faces. - One already-red docs dashboard (a `type: 'card'` widget with `children`, in the plugin-dashboard mdx) also lists the component arm's missing `value` among its union errors now. Its verdict is unchanged; only the error shape moved. ## Pins moved - `strict-widget-slot-registered-inputs-11022.test.ts`. Several blocks are rewritten: - "admitted unjudged" becomes "refused at that key, on both faces"; - the "side table" shape pin becomes "the arm's shape is the base plus `layout` and the five inputs"; - the hand-built-node derivation block is removed with the mechanism. - The `bogus` and `value`-required fixtures now carry a `value`. - `metricCardRegisteredInputsStrictFace-11022.test.ts`. The OVER-admission test, which read "strict keys minus tolerant keys", is replaced by DECLARED-both-directions on both faces. Typed-member and `MetricCardProps` pins are added. The UNDER-admission and `layout` fixtures carry the required `value`. - `dashboard-widget-slot-component-arm-7952.test.ts`. `value` is added to two existing literals so each pin keeps refusing for its stated reason. A new objectui#11467 block holds the member types, the twin parity, the TypeScript refusals, the `component` slot type, the README's two literals on both faces, and the `component`-slot strict judgment. ## Files outside the claimed surface (declared) The claim's surface did not list five files. Each one is the same accept-set change, not a side quest: - `packages/types/src/zod/node-derivation.ts` and `packages/types/src/strict-authoring-face.ts`: the side table and its walker branch are removed, because every name in it is now a member. - `strict-widget-slot-registered-inputs-11022.test.ts` (types) and `metricCardRegisteredInputsStrictFace-11022.test.ts` (plugin-dashboard): they pinned the passthrough-plus-side-table state that the ruling replaces. - `packages/types/README.md`: its strict-face paragraph described the side table. The renderer, the index signature and `SchemaNode` are untouched. ## Gates (head `35a89136`) - `pnpm --filter PKG run type-check` (each echoed `type-check`): exit 0 for types, plugin-dashboard, core, sdui-parser, plugin-list, plugin-designer, app-shell, example-schema-catalog and example-console-starter. All 40 packages were built first, with turbo `Tasks: 40 successful`. - vitest from the worktree root, each a repo-relative path: - `packages/types/`: 330 files, 8770 tests passed; - `packages/plugin-dashboard/`: 160 files, 1532 passed, 6 skipped (pre-existing); - `examples/schema-catalog/`: 39 files, 2235 passed; - `packages/sdui-parser/`: 20 files, 289 passed; - 8 consumer files in cli, app-shell, plugin-designer and core: 96 passed. - `check:doc-snippets`: 776 of 776 judged, 0 failed. `check:doc-examples`: 87 fail, all 87 declared. `check:doc-types`: green. - `check:spec-symbols`, `check:component-surface-parity`, `check:new-line-citations`, `check:control-bytes`, `check:changeset-claims`, `check:pending-changeset-literals`, `check:doc-fences`, `check:readme-exports`, `check:test-path-roots` and `check:handler-key-reads`: exit 0. - `node scripts/check-changeset-no-major.mjs` and `node scripts/check-changeset-presence.mjs`: exit 0. - `check:sdui-registration-pins`: **NOT MEASURED**. It exits 2 with "No console build to weigh", a prerequisite the run did not meet. No registration or `sideEffects` array moved. - `node scripts/check-governed-queue-guard.mjs --test` on the 11 paths: NOT GOVERNED. ## Overlap - `main` advanced 6 commits after `d93e53f5`, objectui#11477 (F3) among them. `git merge-tree` against it is clean. The one shared file is `packages/types/README.md`, in a different section. Nothing on `main` touches `complex.ts`, `complex.zod.ts` or `zod-mirror-parity.test.ts`. - objectui#11466 (F1) is in flight on `SchemaNode`. `component` is `DashboardWidgetSlotComponentSchema | SchemaNode`, so it composes with whatever `SchemaNode` becomes, and the card stays typed by the arm. ## Acceptance notes - **`value` required is enforced on the arm, not on every `metric-card`.** A `{ type: 'metric-card', title }` entry with no card-only input still parses on both faces through the widget arm. The widget arm parses it because `DashboardWidgetTypeSchema` also carries the closed component types (objectui#4600). Reported to the seat as a finding. - **Measured limit in the `component` slot.** A card that fails the arm still parses on the tolerant face through the `BaseSchema` fallback, and the TypeScript union has the same corner. Only the strict face refuses it. This is recorded as a MEASURED LIMIT in the arm-7952 file, not ruled. - **The mdx's `type: 'card'` widget with `children`** is refused by the validator today. The README twin was repaired by objectui#7035; the mdx was not. Reported to the seat as a finding. The session that made this change is `https://claude.ai/code/session_01XvhGmGAP79ZB8swnkapxPC`. --- _Generated by [Claude Code](https://claude.ai/code/session_01XvhGmGAP79ZB8swnkapxPC)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 2b188fa commit 401611b

14 files changed

Lines changed: 581 additions & 382 deletions

‎.changeset/11022-strict-widget-slot-registered-inputs.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,7 @@ The strict authoring face accepts a correctly authored `metric-card` in a dashbo
1313
No migration: a document that parsed on either face still parses there.
1414

1515
⚠️ **Dated note, 2026-10-01 — the slot arm declares `layout` — objectui#11070.** "the slot arm's shape and catchall are what they were" and "a document that parsed on either face still parses there" above held when this change landed. Later in this same release, round 11 of objectui#11070 added `layout` to the slot arm's shape, by reference to the spec's widget `layout`. So the tolerant face now refuses a malformed `layout` on a `metric-card` in the widget slot. `.changeset/11070-dashboard-keys-round11.md` states what ships; the text above is kept as the reading of this change.
16+
17+
⚠️ **Dated note, 2026-10-02 — the slot arm declares `metric-card`'s registered inputs — objectui#11467.** Three readings above held when this change landed. Later in this same release, objectui#11467 made all three false. "The slot's component-node arm now records the input names the `metric-card` registration declares" and "`deriveStrictAuthoringSchema` admits those names on that node before closing it": the arm now declares `title`, `value`, `icon`, `trend` and `trendValue` as members on both faces. The recorded names and the walker step that admitted them are retired, so both faces judge each value by its member. "its `component` is still judged as a plain `BaseSchema` node on both faces": that slot now takes the arm first, then `BaseSchema`. "No migration: a document that parsed on either face still parses there": both faces now refuse a `metric-card` in the widget slot whose `trend`, `title`, `icon`, `trendValue` or `value` falls outside its member, or that carries `icon`, `trend` or `trendValue` without `value`. `.changeset/11467-metric-card-arm-inputs.md` states what ships; the text above is kept as the reading of this change.
18+
19+
⚠️ **Dated note, 2026-10-02 — the tolerant face's arm moves too — objectui#11467.** "The tolerant face (`AnyComponentSchema`, `DashboardComponentSchema` and every other mirror): its accept set, output and inferred types are unchanged" above held when this change landed. objectui#11467 changed the slot arm's accept set and inferred type on the tolerant face, as the note above states for what it now refuses. `.changeset/11467-metric-card-arm-inputs.md` states what ships; the text above is kept as the reading of this change.

‎.changeset/11070-dashboard-keys-round11.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@ The strict authoring face accepts the `layout` that the editable dashboard grid'
1313
**Fix:** write `layout` as the four numbers Save Layout writes, or leave it out.
1414

1515
`options.description` is not changed by this release. `@objectstack/spec` does not declare it on the widget's `options`, so the strict face keeps refusing an authored one (objectui#11228 ruling C), and its status is an open decision on objectui#11070. Comments in `@object-ui/plugin-dashboard` that called it declared now say so; that package's runtime behaviour is unchanged.
16+
17+
⚠️ **Dated note, 2026-10-02 — the slot arm declares `metric-card`'s registered inputs — objectui#11467.** "The widget arm, the component node's other keys and the registered-input record objectui#11022 added", under "What does not move" above, held when this change landed. Later in this same release, objectui#11467 moved all three. The widget arm's `component` member now takes the slot's component arm first, then `BaseSchema`. The component node declares `title`, `value`, `icon`, `trend` and `trendValue` as members on both faces, so each value is judged by its member. The registered-input record and the strict walker's step that admitted it are retired. `.changeset/11467-metric-card-arm-inputs.md` states what ships; the text above is kept as the reading of this change.

‎.changeset/11348-dashboard-widget-reads.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,5 @@ a declaration on `ObjectDataTableSchema` with its own changeset; the drawer's
2828
literal is unchanged.
2929

3030
⚠️ **Dated note, 2026-10-01 — the component arm now declares `layout` — objectui#11070.** "the component arm has no spec row and declares none of them" above held when this change landed. Later in this same release, round 11 of objectui#11070 declared `layout` on the component arm, by reference to the spec's widget `layout`, because Save Layout writes it onto every `widgets[]` entry. `title` and `colorVariant` are still declared on the widget arm only. `.changeset/11070-dashboard-keys-round11.md` states what ships; the text above is kept as the reading of this change.
31+
32+
⚠️ **Dated note, 2026-10-02 — the component arm now declares `title` — objectui#11467.** "`title` and `colorVariant` are still declared on the widget arm only" in the note above held when that note was written. Later in this same release, objectui#11467 declared `metric-card`'s registered inputs on the component arm, `title` among them as the card's heading, typed as `MetricCard` reads it. So `title` is declared on both arms, and it reads as `string | I18nLabel` straight off a `widgets[]` entry. `colorVariant` is still declared on the widget arm only. `.changeset/11467-metric-card-arm-inputs.md` states what ships; the text above is kept as the reading of this change.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
'@object-ui/types': minor
3+
---
4+
5+
A `metric-card` in a dashboard's widget slot is checked against the props `MetricCard` renders, on the TypeScript face and in the validator (objectui#11467). This narrows a published accept set on both faces and widens the strict authoring face in one place. Both changes are stated below. `minor`, per this repository's version alignment; the narrowing is the breaking part.
6+
7+
`DashboardWidgetSlotComponentSchema` is the widget slot's component arm. It used to type the card's props only through `BaseSchema`'s `[key: string]: any`, and its zod twin admitted them through `.passthrough()` and judged nothing. The strict face (`StrictAnyComponentSchema`) admitted their names from a side table and judged their values by that same catchall.
8+
9+
- **What changed.** The arm declares `metric-card`'s registered inputs as members, with the types of the props `MetricCard` reads: `title` (a string or an inline per-locale map, `I18nLabel`), `value` (`string | number`, required, as the registration marks it), `icon` (`string`), `trend` (`'up' | 'down' | 'neutral'`, the registration's enum) and `trendValue` (`string`). The sixth input, `description`, was already a `BaseSchema` member. The zod twin declares the same members, so every face judges each value by its member. The widget's legacy `component` slot now takes the arm first and then any other node, on both faces: `component?: DashboardWidgetSlotComponentSchema | SchemaNode`. The zod twin is `z.union([arm, BaseSchema])`.
10+
- **What now refuses that did not.** Directly in `widgets[]`, `AnyComponentSchema` / `DashboardComponentSchema` and `StrictAnyComponentSchema` now refuse a card with any of these: a `trend` outside the three; a `title`, `icon` or `trendValue` that is not a string (`title` may also be a per-locale map); a `value` that is neither a string nor a number; or `icon`, `trend` or `trendValue` with no `value`. On the TypeScript face each of these literals is now a compile error, and so is a card annotated `DashboardWidgetSlotComponentSchema` with no `value`. All of them used to pass through the index signature and the passthrough. Every `metric-card` in the schema catalog, the docs fences and the apps' authored documents still parses on both faces. This was re-measured with `scripts/measure-strict-authoring-face.mjs` at this change's base and on this change, and no document moved on the tolerant face.
11+
- **What now parses that did not.** On the strict face, a `metric-card` in a widget's `component` slot carrying its inputs. `BaseSchema` alone in that slot refused them as unrecognized, including in the plugin-dashboard README's own legacy-envelope example.
12+
- **What does not move.** Any key the arm does not declare is still kept by the tolerant face's passthrough and refused by name on the strict face. The widget arm, `DashboardWidgetSchema`, still declares none of `value`, `icon`, `trend` and `trendValue`. Any other component node in the `component` slot is judged by `BaseSchema` as before.
13+
- **Read types.** `title` now reads as `string | I18nLabel` straight off a `widgets[]` entry instead of `any`, because both arms declare it.
14+
15+
**Fix:** write `trend` as one of the three, give the card a `value`, and keep `title`, `icon` and `trendValue` as strings (`title` may also be a per-locale map).
16+
17+
The internal `declareRegisteredInputs` side table (objectui#11022) and the strict walker's branch for it are removed. Every name it recorded is now a member of the arm. Neither was exported from the package.

‎content/docs/plugins/plugin-dashboard.mdx‎

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,18 @@ A `metric-card` is a dashboard widget-slot entry: it sits directly in a
7676
and the dashboard renders it as the `plugin-dashboard:metric-card` node. The
7777
bare `metric-card` NODE key is retired (objectui#10859), so a `metric-card`
7878
outside a dashboard's `widgets[]` renders nothing but the renderer's
79-
"Unknown component type" panel. Its keys:
79+
"Unknown component type" panel. Its keys, as `DashboardWidgetSlotComponentSchema`
80+
(`@object-ui/types`) declares them and `@object-ui/types/zod` judges them:
8081

8182
```plaintext
8283
{
8384
type: 'metric-card',
84-
title: string,
85-
value: string | number,
85+
title?: string | I18nLabel, // plain string or inline per-locale map
86+
value: string | number, // required
8687
icon?: string, // Lucide icon name
87-
trend?: 'up' | 'down' | 'neutral',
88-
trendValue?: string,
89-
description?: string,
88+
trend?: 'up' | 'down' | 'neutral', // drawn with trendValue
89+
trendValue?: string, // drawn with trend
90+
description?: string | I18nLabel,
9091
className?: string
9192
}
9293
```
@@ -463,7 +464,8 @@ const dashboard: DashboardComponentSchema = {
463464

464465
An entry of `widgets[]` is either a widget (`DashboardWidgetSchema`) or a
465466
component node placed directly in the slot (`DashboardWidgetSlotComponentSchema`).
466-
The widget keys (`title`, `colorVariant`, `filter`, …) are declared on the widget
467+
The component arm declares the card's registered inputs — the keys above. The
468+
widget keys (`colorVariant`, `filter`, `dataset`, …) are declared on the widget
467469
arm, which takes them from the spec's `DashboardWidget` row, and on no member of
468470
the component arm. To read one off `widgets[]`, read it through
469471
`DashboardWidgetSchema`. The component arm is assignable to that type, so the
@@ -479,10 +481,12 @@ const widgets: DashboardWidgetSchema[] = dashboard.widgets;
479481
const accents = widgets.map((w) => w.colorVariant ?? 'default');
480482
```
481483

482-
`layout` is the exception: both arms declare it, the component arm by reference
483-
to the spec's widget `layout`, because the editable grid's Save Layout writes it
484-
onto every entry, a `metric-card` node included. It reads with the spec's type
485-
off any `widgets[]` entry, the strict authoring face accepts it on a component
484+
`title` and `layout` are the exceptions: both arms declare them. `title` is the
485+
card's heading on the component arm, typed as `MetricCard` reads it. The
486+
component arm declares `layout` by reference to the spec's widget `layout`,
487+
because the editable grid's Save Layout writes it onto every entry, a
488+
`metric-card` node included. `layout` reads with the spec's type off any
489+
`widgets[]` entry, the strict authoring face accepts it on a component
486490
node, and a malformed one (not four numbers, or a key besides `x`, `y`, `w` and
487491
`h`) is refused on either arm.
488492

‎packages/plugin-dashboard/README.md‎

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ The authored shape is typed by `@object-ui/types`:
563563
| --- | --- |
564564
| `DashboardComponentSchema` | the whole `type: 'dashboard'` node — `columns`, `gap`, `widgets`, `header`, `globalFilters`, `dateRange`, `refreshIntervalSeconds`, … |
565565
| `DashboardWidgetSchema` | one entry of `widgets[]` — the spec's `DashboardWidget` keys, plus objectui's own (`component`, `layout`, `options`, …) |
566-
| `DashboardWidgetSlotComponentSchema` | the other kind of `widgets[]` entry — a component node placed directly in the slot, `type` one of the closed component set (`metric-card`); every other key is that component's own prop, except the spec's widget `layout`, which places the node |
566+
| `DashboardWidgetSlotComponentSchema` | the other kind of `widgets[]` entry — a component node placed directly in the slot, `type` one of the closed component set (`metric-card`); its other keys are that component's own props, which it declares (`title`, `value`, `icon`, `trend`, `trendValue`, and `description` from `BaseSchema`), except the spec's widget `layout`, which places the node |
567567
| `DashboardWidgetLayout` | a widget's `{ x, y, w, h }` grid box |
568568

569569
```typescript
@@ -592,7 +592,8 @@ const users: DashboardWidgetSchema = {
592592
};
593593

594594
// Component format: a registered component node in the widget's `component`
595-
// slot. Its keys are that COMPONENT's props, not widget keys.
595+
// slot. Its keys are that COMPONENT's props, not widget keys; a `metric-card`
596+
// here is typed by the same arm as `kpi` below.
596597
const custom: DashboardWidgetSchema = {
597598
id: 'kpi_custom',
598599
component: {
@@ -607,7 +608,8 @@ const custom: DashboardWidgetSchema = {
607608

608609
// Component node directly in the slot — the shape every `metric-card` example
609610
// above uses. `type` is one of the closed component set; the other keys are
610-
// the component's own props, carried by `BaseSchema`'s index signature.
611+
// the component's own props, which `DashboardWidgetSlotComponentSchema`
612+
// declares.
611613
const kpi: DashboardWidgetSlotComponentSchema = {
612614
type: 'metric-card',
613615
title: 'Revenue',
@@ -633,13 +635,26 @@ package's export surface either. A `metric-card` node is typed as a COMPONENT
633635
node in both places it can appear: in a widget's `component` slot (`custom`
634636
above) and directly in `widgets[]` (`kpi` above, `DashboardWidgetSlotComponentSchema`
635637
— the component arm of `DashboardComponentSchema['widgets']`, first in the
636-
declaration as in the zod schema's two-arm slot). Its keys are checked as
637-
`BaseSchema` keys either way,
638-
never as widget keys.
638+
declaration as in the zod schema's two-arm slot). Either way its keys are
639+
checked against that arm, which declares the card's registered inputs, never
640+
as widget keys:
641+
642+
| Key | Type |
643+
| --- | --- |
644+
| `value` | `string \| number` — required |
645+
| `title` | `string` or an inline per-locale map (`I18nLabel`) |
646+
| `icon` | `string` — a Lucide icon name |
647+
| `trend` | `'up' \| 'down' \| 'neutral'` — drawn with `trendValue` |
648+
| `trendValue` | `string` — drawn with `trend` |
649+
| `description` | `string` or `I18nLabel`, from `BaseSchema` |
650+
651+
`@object-ui/types/zod` judges the same members, so `objectui validate` refuses
652+
a card directly in `widgets[]` whose `trend` is outside the three, or whose
653+
`value` is neither a string nor a number.
639654

640655
### Reading a widget key off `widgets[]`
641656

642-
The widget keys (`title`, `colorVariant`, `filter`, …) are declared on the
657+
The widget keys (`colorVariant`, `filter`, `dataset`, …) are declared on the
643658
widget arm, `DashboardWidgetSchema`, which takes them from the spec's
644659
`DashboardWidget` row. The component arm declares none of them. Read straight
645660
off a `widgets[]` entry, such a key is typed `any`, supplied by the component
@@ -657,9 +672,11 @@ const widgets: DashboardWidgetSchema[] = dashboard.widgets;
657672
const accents = widgets.map((w) => w.colorVariant ?? 'default');
658673
```
659674

660-
`layout` is the one widget key both arms declare. The component arm takes the
661-
spec's widget `layout` by reference, because Save Layout writes it onto every
662-
entry of `widgets[]`, a `metric-card` node included (see
675+
`title` and `layout` are the two widget keys both arms declare. `title` is the
676+
card's heading on the component arm, typed as `MetricCard` reads it, so it reads
677+
as a string or an `I18nLabel` straight off a `widgets[]` entry. The component
678+
arm takes the spec's widget `layout` by reference, because Save Layout writes it
679+
onto every entry of `widgets[]`, a `metric-card` node included (see
663680
[DashboardGridLayout](#dashboardgridlayout--persisting-drag--resize-edits)). So
664681
`layout` reads with the spec's type straight off a `widgets[]` entry, and the
665682
strict authoring face accepts it on a component node. A malformed one (not

0 commit comments

Comments
 (0)