You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 5b3e3ad
Browse filesBrowse the repository at this point in the historyBrowse files
* feat(grid): add embeddable select grid component
Expose `SelectGrid` on the grid capability: the driven grid as a
component a host plugin renders inside a render session of its own. On
mount it reads the dialogs capability, failing that render with an error
naming the count when there is not exactly one provider, and maps its
request with `selectRequest` once. It renders the dialogs' embeddable
`Select` with the host's `width`, `height`, and `isActive`, and maps a
submitted choice back through `selection`, so `onSubmit` receives
exactly what `select` resolves with. It is created once at registration
so every read yields the same component.
The contract gains `SelectGridProps<T, A>`, built over `EmbeddedProps`
imported type-only from `@fx/tx/dialogs`, and the `SelectGrid` member,
typed as returning `unknown`. The demo tests' stub providers gain the
member, and the boundary test's exact list of contract type names gains
`SelectGridProps`.
* test(grid): drive the embeddable select grid from a host session
Render `grid.SelectGrid`, read from the registry, inside a host session
on a keyboard and screen of its own while the command's streams stay
captured. Cover acting on a row, a row offering no actions, cancelling
with Escape, an inactive grid taking no keys until activated, the
host's height and width bounding what it draws, and the render failing
with the provider count when the dialogs provider is absent or repeated.
* test(grid): type the embeddable select grid through the published contract
The packed consumer fixture types `SelectGridProps`, which resolves the
grid contract through the dialogs contract in the tarball, and builds a
`grid.SelectGrid` element with the injected React, cast at
`createElement` as the contract requires of a host.
* docs: document the embeddable select grid component
Document `SelectGrid` in the plugin guide's grid section: the shared
embedded props it takes, the select it is drawn as, what `onSubmit`
receives, the dialogs lookup on mount, and the cast at `createElement`,
with a host example. Mark the grid spec's embeddable selection
implemented, add a changelog row, tick the second task of change 0038,
and set the change complete in the docs index.
* docs: record the select grid pull request on change 0038
Copy file name to clipboardExpand all lines: docs/changes/0038-add-embeddable-grid-components.md
+8-8Lines changed: 8 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@
5
5
Expose the grid as two components a plugin renders inside its own render session: `Grid`, the printed lines as an element laid out for a given width, and `SelectGrid`, the driven grid over the dialogs' embeddable `Select`. `print` and `select` stay as they are.
6
6
7
7
**Spec:**[Grid](../specs/grid/)
8
-
**Status:**draft
8
+
**Status:**complete
9
9
**Depends On:** 0029, 0030, 0036
10
10
11
11
## Motivation
@@ -78,13 +78,13 @@ Skipping or weakening any of these rules to land the PR MUST be treated as a bug
78
78
-[x]`test/plugin-consumer.test.ts`: the consumer fixture types `Grid` through the published contract; `test/plugin-boundary.test.ts` keeps passing
-[x][Grid](../specs/grid/) spec: mark [Embeddable Grid](../specs/grid/index.md#embeddable-grid) implemented and add a changelog row
81
-
-[] Add the embeddable `SelectGrid` component (after [Change 0036](./0036-add-embeddable-dialog-components.md))
82
-
-[]`plugins/grid/contract.ts`: `SelectGridProps<T, A>` importing `EmbeddedProps` type-only from `@fx/tx/dialogs`, and the `SelectGrid` member
83
-
-[]`plugins/grid/index.ts` and `plugins/grid/select.ts`: the component over the dialogs' `Select`, mapping the request on mount and the answer on submit
84
-
-[]`test/grid-embedded.test.ts`: every scenario in [Grid: Embeddable Selection](../specs/grid/index.md#embeddable-selection) — acting on a row, cancelling, and the absent dialogs provider — plus `isActive`, `height`, and a row offering no actions
85
-
-[]`test/plugin-consumer.test.ts`: the consumer fixture types `SelectGrid`, resolving the grid contract through the dialogs contract in the packed tarball
-[][Grid](../specs/grid/) spec: mark [Embeddable Selection](../specs/grid/index.md#embeddable-selection) implemented and add a changelog row; set this change `complete` in `docs/index.yml` and `docs/index.md`
-[x]`plugins/grid/contract.ts`: `SelectGridProps<T, A>` importing `EmbeddedProps` type-only from `@fx/tx/dialogs`, and the `SelectGrid` member
83
+
-[x]`plugins/grid/index.ts` and `plugins/grid/select.ts`: the component over the dialogs' `Select`, mapping the request on mount and the answer on submit
84
+
-[x]`test/grid-embedded.test.ts`: every scenario in [Grid: Embeddable Selection](../specs/grid/index.md#embeddable-selection) — acting on a row, cancelling, and the absent dialogs provider — plus `isActive`, `height`, and a row offering no actions
85
+
-[x]`test/plugin-consumer.test.ts`: the consumer fixture types `SelectGrid`, resolving the grid contract through the dialogs contract in the packed tarball
-[x][Grid](../specs/grid/) spec: mark [Embeddable Selection](../specs/grid/index.md#embeddable-selection) implemented and add a changelog row; set this change `complete` in `docs/index.yml` and `docs/index.md`
description: Expose the grid as a Grid component drawing the printed lines for a given width and a SelectGrid component driving rows over the dialogs' embeddable Select, leaving print and select unchanged.
Copy file name to clipboardExpand all lines: docs/manual/plugins.md
+41-1Lines changed: 41 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -646,10 +646,11 @@ import type {
646
646
GridSelectRow,
647
647
OutputStream,
648
648
Row,
649
+
SelectGridProps,
649
650
} from"@fx/tx/grid";
650
651
```
651
652
652
-
`Grid` is what the key carries: `print(request)` writing a `GridRequest` — a `stream`, an optional `layout` of `"table"` or `"flow"`, optional `headers`, the `rows`, an optional `empty` message, and an optional `summary` — and `select(request)` driving a `GridSelectRequest` of a `message`, optional `headers`, and `GridSelectRow`s, each carrying its `cells`, the `value` identifying it, and the `GridAction`s it offers, resolving to a `GridSelection` of the chosen `value` and `action` or to `undefined`. It also carries `Grid`, the printed grid as a component taking `GridProps`, described below. A `Row` is a list of `Cell`s or bare strings, and an `OutputStream` is anything that can be written to and may report its `columns` and `isTTY`.
653
+
`Grid` is what the key carries: `print(request)` writing a `GridRequest` — a `stream`, an optional `layout` of `"table"` or `"flow"`, optional `headers`, the `rows`, an optional `empty` message, and an optional `summary` — and `select(request)` driving a `GridSelectRequest` of a `message`, optional `headers`, and `GridSelectRow`s, each carrying its `cells`, the `value` identifying it, and the `GridAction`s it offers, resolving to a `GridSelection` of the chosen `value` and `action` or to `undefined`. It also carries `Grid`, the printed grid as a component taking `GridProps`, and `SelectGrid`, the driven grid as a component taking `SelectGridProps`, both described below. A `Row` is a list of `Cell`s or bare strings, and an `OutputStream` is anything that can be written to and may report its `columns` and `isTTY`.
653
654
654
655
A consumer reads `registrations<Grid>("@fx/tx/grid")` inside its command action, after initialization has committed every provider. The contract is types only, and it declares a cell's `variable` as [Theming](#use-the-bundled-theme-capability)'s own `ThemeVariable` by importing `@fx/tx/theme` rather than restating that vocabulary, so a variable renamed there is renamed in every cell that can name one. The grid resolves a theme for the stream it is printing to through the theme capability above, so a `tx` composed without exactly one theme provider fails the call with an error naming the count rather than choosing an appearance of its own. It uses the injected React and Ink instances and never reaches for the process's own streams.
`SelectGrid` is `select` as a component, for the same plugin. It takes `SelectGridProps<T, A>`: the `GridSelectRequest` you would pass to `select` as its `request`, and the `width`, `height`, `isActive`, `onSubmit`, and `onCancel` every embeddable component that takes keys shares — the `EmbeddedProps` of [Embed a dialog in your own interface](#embed-a-dialog-in-your-own-interface), which the grid contract imports from `@fx/tx/dialogs` rather than restating, so they mean exactly what they mean for `dialogs.Select`. It draws its request as that embedded `Select`, given your `width`, `height`, and `isActive`, so every rule above about selecting — the padded rows, the dropped `variable` and `align`, a row's actions as the column it opens, a row with no actions taken on its own — holds for it, and so does every rule that section states for an embedded `Select`: it is one-shot, it reads your callbacks on every call, it presents the request it was mounted with, and it answers keys only while it is active. `onSubmit` receives exactly the `GridSelection` `select` would resolve with, its `action` key absent where the row offered none, and `onCancel` is called where `select` would resolve `undefined`.
771
+
772
+
It reads the dialogs capability when it mounts, while your command runs, and fails that render — which your session's error handling sees like any other render failure — with an error naming the count where a `tx` is composed without exactly one dialogs provider, rather than falling back to anything. It writes to no stream and needs no interactive one, so the handover guarantee above is `select`'s alone: a process you start after `onSubmit` inherits a terminal your session holds, and handing it over is yours. Every read of the capability yields the same `SelectGrid`. Cast it where you hand it to `createElement`, exactly as `Grid`:
Sorting, grouping, filtering, and paginating the supplied rows are out of scope, as are machine-readable output, borders and box drawing, spanning and wrapped cells, caller-specified widths, multi-row selection, in-place cell editing, column reordering, and value formatting of every kind — a duration, a timestamp, and a byte count are the consumer's to render into a string before it hands one over.
Copy file name to clipboardExpand all lines: docs/specs/grid/index.md
+3-2Lines changed: 3 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,9 +6,9 @@ The grid capability lays text out in aligned cells and either prints it once or
6
6
7
7
A grid is not only a table. A table — a header row over columns of equal meaning — is one layout; a flow, where a list of short items fills as many columns as the terminal affords, is another. Both are the same cells measured the same way, so both belong to one capability.
8
8
9
-
[Change 0030](../../changes/0030-publish-bundled-capability-contracts.md) publishes this contract at `@fx/tx/grid` and renames the capability's registry key to that same specifier, so a consumer imports the contract rather than restating it, under [Plugin System: Published Capability Contracts](../plugin-system/index.md#published-capability-contracts). That change has landed, so every requirement below describes current behavior except those the next paragraph names.
9
+
[Change 0030](../../changes/0030-publish-bundled-capability-contracts.md) publishes this contract at `@fx/tx/grid` and renames the capability's registry key to that same specifier, so a consumer imports the contract rather than restating it, under [Plugin System: Published Capability Contracts](../plugin-system/index.md#published-capability-contracts). That change has landed.
10
10
11
-
[Change 0038](../../changes/0038-add-embeddable-grid-components.md)specifies[Embeddable Grid](#embeddable-grid) and [Embeddable Selection](#embeddable-selection) — a printed grid and a driven one rendered inside a plugin's own render session — together with the members they add to [Grid Capability](#grid-capability). [Embeddable Grid](#embeddable-grid) and the `Grid` member it adds are implemented. [Embeddable Selection](#embeddable-selection) and the `SelectGrid` member it adds are planned and not yet implemented: today the capability exposes `print`, `select`, and `Grid`.
11
+
[Change 0038](../../changes/0038-add-embeddable-grid-components.md)adds[Embeddable Grid](#embeddable-grid) and [Embeddable Selection](#embeddable-selection) — a printed grid and a driven one rendered inside a plugin's own render session — together with the `Grid` and `SelectGrid`members they add to [Grid Capability](#grid-capability). That change has landed too, so every requirement below describes current behavior: the capability exposes `print`, `select`, `Grid`, and `SelectGrid`.
12
12
13
13
## Background
14
14
@@ -436,3 +436,4 @@ They share every measurement decision and differ only in what drives them. Split
436
436
| 2026-09-06 | Required the grid contract to be published at `@fx/tx/grid` as a types-only import, replacing the local structural copy every consumer maintained | [0030-publish-bundled-capability-contracts](../../changes/0030-publish-bundled-capability-contracts.md) |
437
437
| 2026-10-18 | Desired embeddable `Grid` and `SelectGrid` components, sized by their host under the props Dialogs defines for every embeddable component | [0038-add-embeddable-grid-components](../../changes/0038-add-embeddable-grid-components.md) |
438
438
| 2026-10-18 | Implemented the embeddable `Grid` component: the lines `print` would write, laid out against the host's `width` rather than a stream's, themed for the injected standard error, and handed to the host's session whole, a cell's own trailing spaces included | [0038-add-embeddable-grid-components](../../changes/0038-add-embeddable-grid-components.md) |
439
+
| 2026-10-18 | Implemented the embeddable `SelectGrid` component: the request `select` presents, drawn as the dialogs' embeddable `Select` in the host's `width`, `height`, and focus, mapped once on mount and answered through `onSubmit` with exactly the selection `select` resolves with, reading the dialogs capability when it mounts and failing that render naming the count when there is not exactly one provider | [0038-add-embeddable-grid-components](../../changes/0038-add-embeddable-grid-components.md) |
0 commit comments