@mechane-ai/elements 0.45.0 → 0.46.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/README.md +48 -18
  2. package/bin/mechane-elements-catalog.mjs +42 -4
  3. package/dist/ai.js +268 -202
  4. package/dist/catalog.json +91 -31
  5. package/dist/categorical-values-BXi-rJuv.js +74 -0
  6. package/dist/chart-cursor-1mFd48Jc.js +23 -0
  7. package/dist/chart-data-CIJVWCYt.js +21 -0
  8. package/dist/{chart-frame-Ztktqs1b.js → chart-frame-BaxKn_MB.js} +22 -41
  9. package/dist/{chart-input-BO3BqlFO.js → chart-input-Bm82_9Rd.js} +2 -2
  10. package/dist/chart-theme-4zprJ3rW.js +404 -0
  11. package/dist/charts/cartesian.js +1598 -1432
  12. package/dist/charts/distribution.js +476 -404
  13. package/dist/charts/graph.js +363 -349
  14. package/dist/charts/hierarchy.js +103 -94
  15. package/dist/charts/matrix.js +340 -333
  16. package/dist/charts/timeline.js +167 -134
  17. package/dist/charts.js +3 -3
  18. package/dist/{code-block-Cpfr7B6a.js → code-block-DioAM2bZ.js} +67 -52
  19. package/dist/collections.js +1648 -1188
  20. package/dist/content/code.js +1 -1
  21. package/dist/content/diff.js +67 -66
  22. package/dist/content/link.js +1 -1
  23. package/dist/content/markdown.js +2 -2
  24. package/dist/content/tree.js +2 -2
  25. package/dist/{content-link-CGeFFb9F.js → content-link-NWuHp5rC.js} +1 -1
  26. package/dist/content.js +1 -1
  27. package/dist/csp.js +6 -11
  28. package/dist/feedback.js +1 -1
  29. package/dist/forms/dates.js +274 -214
  30. package/dist/{forms-DeU0Tiv3.js → forms-CEbwzlRR.js} +50 -41
  31. package/dist/forms.js +3 -3
  32. package/dist/index.js +1 -1
  33. package/dist/layout.js +207 -207
  34. package/dist/navigation.js +4 -3
  35. package/dist/packages/ai/src/conversation.d.ts +2 -0
  36. package/dist/packages/ai/src/prompt-input.d.ts +7 -2
  37. package/dist/packages/charts/src/cartesian/composition-bars.d.ts +2 -2
  38. package/dist/packages/charts/src/cartesian/index.d.ts +3 -2
  39. package/dist/packages/charts/src/cartesian/scatter-plot.d.ts +8 -2
  40. package/dist/packages/charts/src/cartesian/time-series.d.ts +11 -1
  41. package/dist/packages/charts/src/categorical-values.d.ts +14 -9
  42. package/dist/packages/charts/src/chart-frame.d.ts +7 -9
  43. package/dist/packages/charts/src/chart-inspection.d.ts +1 -2
  44. package/dist/packages/charts/src/chart-range.d.ts +33 -0
  45. package/dist/packages/charts/src/chart-rows.d.ts +20 -0
  46. package/dist/packages/charts/src/chart-theme.d.ts +17 -0
  47. package/dist/packages/charts/src/chart.d.ts +81 -0
  48. package/dist/packages/charts/src/distribution/distribution-plot.d.ts +4 -4
  49. package/dist/packages/charts/src/index.d.ts +1 -0
  50. package/dist/packages/charts/src/matrix/matrix-strip.d.ts +3 -3
  51. package/dist/packages/charts/src/plot-width.d.ts +0 -1
  52. package/dist/packages/charts/src/timeline/index.d.ts +1 -1
  53. package/dist/packages/charts/src/timeline/waterfall.d.ts +6 -2
  54. package/dist/packages/collections/src/collection-controls.d.ts +5 -1
  55. package/dist/packages/collections/src/collection-filters.d.ts +4 -1
  56. package/dist/packages/collections/src/control-toolbar.d.ts +13 -0
  57. package/dist/packages/collections/src/data-table-layout.d.ts +78 -0
  58. package/dist/packages/collections/src/data-table-rows.d.ts +54 -0
  59. package/dist/packages/collections/src/data-table-styles.d.ts +340 -0
  60. package/dist/packages/collections/src/data-table-text.d.ts +13 -0
  61. package/dist/packages/collections/src/data-table-trigger.d.ts +23 -0
  62. package/dist/packages/collections/src/data-table.d.ts +3 -85
  63. package/dist/packages/collections/src/index.d.ts +11 -6
  64. package/dist/packages/collections/src/query-controls.d.ts +6 -2
  65. package/dist/packages/collections/src/table-results.d.ts +47 -13
  66. package/dist/packages/collections/src/timeline.d.ts +1 -0
  67. package/dist/packages/collections/src/use-collection-controls.d.ts +2 -1
  68. package/dist/packages/collections/src/use-table-window.d.ts +25 -0
  69. package/dist/packages/content/src/viewer.d.ts +8 -0
  70. package/dist/packages/core/src/disclosure.d.ts +9 -1
  71. package/dist/packages/core/src/index.d.ts +1 -0
  72. package/dist/packages/core/src/route-link.d.ts +11 -0
  73. package/dist/packages/forms/src/dates/date-inputs.d.ts +3 -1
  74. package/dist/packages/forms/src/file-picker.d.ts +15 -0
  75. package/dist/packages/forms/src/form-controls.d.ts +1 -6
  76. package/dist/packages/forms/src/forms.d.ts +4 -1
  77. package/dist/packages/forms/src/index.d.ts +4 -2
  78. package/dist/packages/forms/src/selection.d.ts +14 -0
  79. package/dist/packages/foundations/src/csp/index.d.ts +1 -1
  80. package/dist/packages/foundations/src/csp/provider.d.ts +7 -2
  81. package/dist/packages/navigation/src/index.d.ts +1 -1
  82. package/dist/{pierre-diff-B3tD3-6z.js → pierre-diff-DlvjyuJn.js} +1 -1
  83. package/dist/plot-width-v2c_rA20.js +63 -0
  84. package/dist/{src-gqEebHEa.js → src-1EHkSFS-.js} +395 -274
  85. package/dist/{src-DBNncL7_.js → src-BPTDJqt0.js} +48 -68
  86. package/dist/src-CGc_hjxJ.js +409 -0
  87. package/dist/{src-DcW_gMX8.js → src-CpdJlDhO.js} +480 -362
  88. package/dist/{src-Dcs3SZ9V.js → src-DVHlknB6.js} +1 -1
  89. package/dist/styles2.css +136 -114
  90. package/package.json +1 -4
  91. package/skills/extend-elements/SKILL.md +74 -0
  92. package/skills/review-elements/SKILL.md +76 -0
  93. package/skills/upgrade-elements/SKILL.md +34 -0
  94. package/skills/upgrade-elements/references/releases.md +58 -0
  95. package/skills/use-elements/SKILL.md +64 -13
  96. package/skills/use-elements/references/agent.md +57 -0
  97. package/skills/use-elements/references/charts.md +63 -0
  98. package/skills/use-elements/references/collections.md +89 -0
  99. package/skills/use-elements/references/conversations.md +47 -0
  100. package/skills/use-elements/references/forms.md +81 -0
  101. package/skills/use-elements/references/styling.md +70 -0
  102. package/skills/use-elements/references/workspace.md +3 -3
  103. package/dist/categorical-values-DZLGQVW1.js +0 -63
  104. package/dist/chart-navigation-BAbb5PV9.js +0 -154
  105. package/dist/header-styles-COxCYFZx.js +0 -90
  106. package/dist/packages/charts/src/chart-navigation.d.ts +0 -39
  107. package/dist/packages/charts/src/chart-surface.d.ts +0 -27
  108. package/dist/packages/navigation/src/route-link.d.ts +0 -2
  109. package/dist/plot-width-CIqBiHcd.js +0 -105
  110. package/dist/src-Bk7M67zy.js +0 -396
@@ -0,0 +1,76 @@
1
+ ---
2
+ name: review-elements
3
+ description:
4
+ Review a page built with Mechane Elements before it ships. Use after building or changing UI with
5
+ `@mechane-ai/elements`, or when asked to check keyboard access, loading states, narrow layouts, themes or agent
6
+ access.
7
+ ---
8
+
9
+ # Review an Elements page
10
+
11
+ Run the page in a browser and use it. A passing type check says nothing about focus, loading or layout. Report what you
12
+ checked, what failed and what you could not check.
13
+
14
+ ## 1. Keyboard alone
15
+
16
+ Put the pointer away and complete the page's main task.
17
+
18
+ - Tab reaches every control once, in reading order, with a visible focus ring.
19
+ - A table's row actions, a control row, a chart, a timeline, tabs and a segmented control are each **one** Tab stop.
20
+ Arrow keys move inside them. Another Tab stop inside one of these means a wrapper is fighting the component.
21
+ - Enter or Space activates. Escape closes the top layer only: a readout before its dialog, a menu before its drawer.
22
+ - Closing a dialog, menu or popover returns focus to what opened it. After a save, focus lands on the result.
23
+ - Text entry keeps its keys. A shortcut does not fire while the reader types.
24
+
25
+ ## 2. Every read state
26
+
27
+ Hold a slow read, fail one, and return an empty result.
28
+
29
+ - Pending reserves the result's geometry with a matching placeholder. Nothing jumps when the content arrives.
30
+ - A refresh keeps the last result, its focus and any draft on screen, with progress or the failure beside it.
31
+ - A failed first read shows a `Notice` with Retry in place. A successful empty result shows an `EmptyState`.
32
+ - Each failure has one presentation. Not a banner and a toast for the same error.
33
+ - Navigate away mid-read. A late response must not replace the new selection's content.
34
+ - A pending save disables a second submit. A failed save keeps the draft.
35
+
36
+ ## 3. Width and pointer
37
+
38
+ Check 360 pixels wide, a tablet width and a wide desktop.
39
+
40
+ - The page never scrolls sideways. A wide table or plot scrolls inside its own region.
41
+ - Toolbar actions wrap below their title. Long labels wrap or truncate with the full value available elsewhere.
42
+ - With a coarse pointer, standalone controls give 44px targets and text fields use 16px text.
43
+ - At a wide viewport, the right edges of a report header, its table and the pane line up.
44
+
45
+ ## 4. Theme and motion
46
+
47
+ - Switch to the dark theme and open every menu, dialog, popover and tooltip. A portaled panel in the wrong theme means
48
+ the theme is not on the document root.
49
+ - Turn on reduced motion. Fades and slides stop, and nothing waits for an animation to finish.
50
+
51
+ ## 5. Honest content
52
+
53
+ - Unknown is not zero. A missing value shows as unavailable, and a chart draws a gap.
54
+ - Try the longest real name, a large number, an empty optional field and a single row.
55
+ - Dates and numbers carry a unit, and come from a formatter with an explicit locale and time zone.
56
+ - An icon-only button has an accessible name. A chart's title says what was measured and for which period.
57
+
58
+ ## 6. What an agent sees
59
+
60
+ When the app enables the bridge from `/agent`, print `agent.snapshot()` on the page.
61
+
62
+ - Every component has a label a person would recognize.
63
+ - The listed actions match what the visible controls can do right now. A disabled control offers no action.
64
+ - No credential, private draft or hidden record appears in a label, an item or a result.
65
+ - A step an agent takes produces the same request and the same pending state as a person's press.
66
+
67
+ ## 7. Read the code once
68
+
69
+ - Imports come from `@mechane-ai/elements` entries. No second component library renders the same kind of control.
70
+ - No class or inline style changes a control's size, padding, radius or focus ring. `xstyle` carries placement only.
71
+ - No custom `onKeyDown`, tooltip or scroll effect duplicates what the component already does.
72
+ - Each value has one owner: controlled with its callback, or an uncontrolled default.
73
+ - The server authorizes every read and mutation. The UI's disabled state is not the permission check.
74
+
75
+ Not covered by this review: a real screen reader, a physical touch device and right-to-left text. Say so in the report
76
+ unless you ran them.
@@ -0,0 +1,34 @@
1
+ ---
2
+ name: upgrade-elements
3
+ description:
4
+ Upgrade `@mechane-ai/elements` in an app. Use when changing the package version, or when types, keyboard behavior or
5
+ agent output changed after an upgrade.
6
+ ---
7
+
8
+ # Upgrade Elements
9
+
10
+ Elements is below 1.0, so a minor version can remove or change an API. Upgrade one minor version at a time when the gap
11
+ is large.
12
+
13
+ 1. Read the installed version: `pnpm exec mechane-elements-catalog` prints it first.
14
+ 2. Change the version, install, and run this command so the skills match the new package:
15
+
16
+ ```sh
17
+ pnpm exec mechane-elements-catalog --install-skills .claude/skills
18
+ ```
19
+
20
+ Use the directory the skills were installed in before.
21
+
22
+ 3. Read [the release notes](references/releases.md) for every version between the old one and the new one.
23
+ 4. Run the app's type check. Fix each error from the notes. For a removed or renamed export, look up its replacement:
24
+
25
+ ```sh
26
+ pnpm exec mechane-elements-catalog filepicker
27
+ ```
28
+
29
+ 5. Search the app for what the type check cannot see: agent component names in an `allow` function, role or Tab-order
30
+ assumptions in tests, and CSS that targets Elements internals.
31
+ 6. Review each changed page with the `review-elements` skill. Behavior changes show in the browser, not in types.
32
+
33
+ Do not pin an old behavior back with a wrapper or a patch. Move the call site to the new API, and report anything the
34
+ new version cannot do.
@@ -0,0 +1,58 @@
1
+ # Release notes for applications
2
+
3
+ Newest first. Each section lists what an application must change, then what it may adopt.
4
+
5
+ ## 0.46
6
+
7
+ Every interactive component now runs on a UI SDK primitive. `@base-ui/react`, `@tanstack/react-virtual` and
8
+ `@shadcn/react` are no longer dependencies of the package.
9
+
10
+ ### Change
11
+
12
+ - **`FilePicker` has a new API.** It was a native file input with `onChange`. It now takes
13
+ `onValueChange(files, details)` with `accept`, `multiple`, `maxFiles`, `maxSize` and `minSize`. It lists the chosen
14
+ files and shows why a file was refused.
15
+
16
+ ```tsx
17
+ // Before
18
+ <FilePicker onChange={(event) => setFile(event.currentTarget.files?.[0])} />
19
+ // After
20
+ <FilePicker maxSize={32 * 1024 * 1024} onValueChange={(files) => setFile(files[0])} />
21
+ ```
22
+
23
+ - **`ChartDatumButton` is removed.** Row charts handle their own rows. Pass `selection` to the chart instead.
24
+ - **`Accordion.Root` requires `aria-label` or `aria-labelledby`.**
25
+ - **`CSPProvider` takes `nonce` and `children` only.**
26
+ - **`Waterfall`'s `selectedRef` is `Ref<HTMLDivElement>`** and points at the selected row.
27
+ - **Agent names changed.** `navigation-link` is now `link`, and every Elements link reports `href` and `current` and
28
+ offers `follow`. `collection-record` is removed; open a row with `open` on `collection-results`. A chart offers
29
+ `inspect`, `select` and `dismiss`. Update any `allow` function that names the old components or actions.
30
+
31
+ ### Behavior to check
32
+
33
+ - **One Tab stop per composite.** A table's row actions, the control row above a collection, a timeline's events, a
34
+ waterfall's rows and a row chart with `selection` are each one Tab stop with arrow keys inside. Update tests that
35
+ press Tab once per row.
36
+ - `CollectionToolbar` and `FilterChips` have `role="toolbar"` where they had `role="group"`.
37
+ - A selectable `DataTable` shows a header checkbox for every supplied row, and Shift with a click selects a range.
38
+ - `Waterfall` is a `treegrid`.
39
+ - The day pickers show one typed field per date unit instead of the browser's date field.
40
+ - `ToggleGroup` sizes to its content instead of stretching across a column.
41
+ - On bars and bridge columns the ink edge now means selected only. The band and the readout mark the inspected column.
42
+ - A bridge chart leaves out a value label that would touch another label. The value stays in the readout.
43
+
44
+ ### Adopt
45
+
46
+ - **Change details.** These callbacks gained a second `details` argument with the reason, the source and `cancel()`:
47
+ `Input` and `Textarea` `onValueChange`, a collection's `search.onChange` and `search.onSubmit`, a filter's `onChange`,
48
+ `FilterChips` `onRemove`, a chart's `selection.onSelect`, `Waterfall` `onSelect`, a scatter range's `onChange`, and
49
+ `DataTable` `onSortChange` and `onSelectionChange`. One-argument handlers keep working.
50
+ - **`SegmentedControl`** for one choice from a short row. Replace a `ToggleGroup` that forced a single value.
51
+ - **`rangeSelection`** on `LineChart` and `AreaChart` for a time range the reader draws, moves and resizes.
52
+ - **`history`** on `PromptInput` for Arrow Up recall. Command or Control with Enter always submits.
53
+ - New agent components: `message`, `viewer` and `chart-range`.
54
+
55
+ ## 0.29
56
+
57
+ `ReportSection` is removed. Move its metric summary into the explanatory chart's `report.summary` or
58
+ `report.seriesValues`. Use `Stack` when the content already belongs to a region.
@@ -1,36 +1,87 @@
1
1
  ---
2
2
  name: use-elements
3
3
  description:
4
- Build React pages with Mechane Elements. Find the page recipe, public imports, and Storybook example for a collection,
5
- report, tabbed workspace, or form.
4
+ Build React pages with Mechane Elements. Use when adding or changing UI in an app that has `@mechane-ai/elements`
5
+ installed, such as a table, report, chart, form, workspace shell, conversation, or agent access.
6
6
  ---
7
7
 
8
8
  # Build with Elements
9
9
 
10
- From the app with `@mechane-ai/elements` installed, look up the user’s task:
10
+ ## Look it up in the installed version
11
+
12
+ From the app with `@mechane-ai/elements` installed, look up the user's task:
11
13
 
12
14
  ```sh
13
15
  pnpm exec mechane-elements-catalog "searchable table with filters"
14
16
  ```
15
17
 
16
- Start with the matching recipe. Read its TSX for the full component composition and its public imports. The same example
17
- runs in the Elements Storybook under **Recipes**. The command uses the installed package. The machine-readable index is
18
- also available at `@mechane-ai/elements/catalog.json`.
18
+ The answer is JSON for the installed version: the matching recipes, the best recipe's TSX, and its public imports. Start
19
+ from that TSX. The same example runs in the Elements Storybook under **Recipes**.
20
+
21
+ Look up one component by its export name, without spaces:
22
+
23
+ ```sh
24
+ pnpm exec mechane-elements-catalog segmentedcontrol
25
+ ```
26
+
27
+ Each match names its import path and its declaration file inside the package. Read that declaration for the props and
28
+ callbacks. Do not guess a prop from another library. The same index is at `@mechane-ai/elements/catalog.json`.
29
+
30
+ ## Set up once
31
+
32
+ - Import `@mechane-ai/elements/styles.css` once at the app entry. Ordinary React apps need no StyleX compiler.
33
+ - Spread `themeProps.light` or `themeProps.dark` from `/theme` onto the document root, so portaled menus and dialogs
34
+ inherit the theme. The app stores the preference.
35
+ - Mount one `Toaster` from `/feedback` at the root when the app reports outcomes with `toast`.
36
+ - Supply the app's own reset and fonts. See [styling](references/styling.md) for layers, tokens and a nonce policy.
19
37
 
20
- Load `@mechane-ai/elements/styles.css` once at the app entry. Choose the owning family for each import. Keep route
21
- state, authorized data, and mutations in the application.
38
+ ## Who owns what
39
+
40
+ Elements owns the interaction, focus, keyboard, announcements and appearance. The app owns routes, data, authorization,
41
+ persistence and every asynchronous operation.
42
+
43
+ - Pass a controlled value with its change callback, or an uncontrolled default. Never both.
44
+ - A change callback receives the value, then the change details. `details.reason` names what happened and
45
+ `details.source` says whether a pointer, the keyboard, an agent or code caused it.
46
+ - Pass pending, failed and ready states in. A click or a resolved request does not mean the operation completed.
47
+ - Import from the family that owns the interaction. Do not import `@ui-sdk/react` beside Elements for the same control.
48
+ - Use a named `variant`, `tone` or `density`. There is no size, padding or radius prop. `xstyle` takes placement only,
49
+ such as width or alignment.
50
+
51
+ ## Pick the component
52
+
53
+ | The page needs | Use | Read |
54
+ | ------------------------------------------------- | ---------------------------------------------------------------------------------- | -------------------------------------------- |
55
+ | An app frame, a page, sections, a record page | `AppShell`, `PageLayout`, `PageSection`, `RecordPage` | [workspace](references/workspace.md) |
56
+ | Records compared across columns, search, filters | `DataTable` with a `query` | [collections](references/collections.md) |
57
+ | A selected record's fields beside its list | `Inspector`, `Details` | [collections](references/collections.md) |
58
+ | Fields, choices, dates, files, a save | `Field`, the `/forms` controls, `FormActions`, `ConfirmButton` | [forms](references/forms.md) |
59
+ | A trend, comparison, distribution or relationship | One chart from a `/charts/*` entry | [charts](references/charts.md) |
60
+ | A first read, a refresh, an empty or failed read | `AsyncRegion`, `LoadingScope`, `EmptyState`, `Notice` | [reports](references/reports.md) |
61
+ | A command menu, a decision, an anchored panel | `Menu`, `AlertDialog`, `Dialog`, `Drawer`, `Popover`, `Tooltip` | the catalog |
62
+ | Route destinations or panels inside one view | `PageNavigation` for links, `Tabs` or `ContentTabs` for panels | [workspace](references/workspace.md) |
63
+ | A transcript, a prompt, tool activity, approvals | `Conversation`, `Message`, `PromptInput`, `Approval` | [conversations](references/conversations.md) |
64
+ | Markdown, source, a diff, a file tree, a log | `/content/markdown`, `/content/code`, `/content/diff`, `/content/tree`, `/content` | the catalog |
65
+ | A model or browser agent that reads and acts | `createAgent` and `registerTools` from `/agent` | [agent access](references/agent.md) |
66
+
67
+ ## Start from a recipe
22
68
 
23
69
  - **Searchable collection.** Use local query mode for a complete finite collection. For a paged source, send search and
24
70
  filters to the data owner before it takes a page. Keep the query and current page together in route state when users
25
71
  need to return to the same results.
26
72
  - **Sectioned report.** Mount the shell around the router outlet. Put each heading and its body in a sibling
27
- `PageSection`. The shell and sections own the sticky geometry. See [workspace layout](references/workspace.md) and
28
- [report loading and inspection](references/reports.md).
73
+ `PageSection`. The shell and sections own the sticky geometry.
74
+ - **Allocation report.** Show how one total divides with a parts strip above one explanatory chart. Give each part one
75
+ tone everywhere.
29
76
  - **Tabbed workspace.** Put page-wide navigation and its actions in the page navigation slot. Use links for route
30
77
  destinations and tabs for panels within the current view.
31
78
  - **Consequential form.** The owner validates and submits the draft. Use the shared confirmation and pending states,
32
79
  mark sensitive input at its source, and keep the draft available when the save fails.
33
80
 
34
- For a task outside those four recipes, search the same catalog for a public component. Inspect its declaration for
35
- supported props and callbacks. In a running Elements Storybook, an MCP client can also discover components and examples
36
- at `/mcp`.
81
+ For a task outside the recipes, search the catalog for a public component and compose it with the layout parts above. In
82
+ a running Elements Storybook, an MCP client can also discover components and examples at `/mcp`.
83
+
84
+ ## Before you finish
85
+
86
+ Check the page with the `review-elements` skill: keyboard alone, every read state, a phone width, the dark theme, and
87
+ what an agent sees. After a package upgrade, follow the `upgrade-elements` skill.
@@ -0,0 +1,57 @@
1
+ # Agent access
2
+
3
+ Elements components describe themselves to an agent: a name, a label, their state, their items and the actions a person
4
+ could take. The bridge is optional. Nothing is exposed until the application creates it.
5
+
6
+ ## Turn it on
7
+
8
+ Create the bridge in client code at browser startup:
9
+
10
+ ```ts
11
+ import { createAgent, registerTools } from '@mechane-ai/elements/agent';
12
+ import type { AgentAction } from '@mechane-ai/elements/agent';
13
+
14
+ const allow = (step: AgentAction) =>
15
+ step.confirm === undefined && step.component === 'collection-query' && step.action === 'setQuery';
16
+
17
+ const agent = createAgent({ allow });
18
+ const unregister = registerTools(agent, { allow });
19
+ // Call unregister() when the host ends this integration.
20
+ ```
21
+
22
+ - `agent.snapshot()` lists the mounted components with their state and actions. `agent.query(...)` finds components and
23
+ list items. `agent.act({ steps })` runs steps in order.
24
+ - For the app's own model, pass the definitions in `agentTools` to the model and route each call to the matching method.
25
+ - `registerTools` exposes the same tools to a browser agent through WebMCP. It needs `allow`.
26
+ - `allow` decides each step. Start by allowing the few actions the product needs. A step with `confirm` set is one a
27
+ person must approve, such as Send, Stop or an approval decision.
28
+
29
+ ## What an agent can read and do
30
+
31
+ | Component | It reads | It can ask for |
32
+ | -------------------- | ------------------------------------------------ | ---------------------------------------------------- |
33
+ | `collection-query` | The search text and filter choices | `setQuery`, `submitSearch`, `setFilter` |
34
+ | `collection-results` | Every supplied row as a named item, and `status` | `sort`, `select`, `open`, `previousPage`, `nextPage` |
35
+ | `chart` | Each item with exact values, inspected, selected | `inspect`, `select`, `dismiss` |
36
+ | `chart-range` | The selected range | `setRange`, `clear` |
37
+ | `link` | `href` and whether it is current | `follow` |
38
+ | `page-title` | The page's title | Nothing |
39
+ | `page-section` | The section at the reading position | Nothing |
40
+ | `detail-field` | A labeled field of the selected record | Nothing |
41
+ | `form-status` | Pending, error or success, with its message | Nothing |
42
+ | `message` | A message's author, kind and text | Nothing |
43
+ | `viewer` | A code, diff, JSON, log or stack viewer's label | Nothing |
44
+
45
+ Form controls, menus, dialogs, tabs and the other controls appear under their UI SDK names with their own actions. Read
46
+ `agent.snapshot()` in the running app for the exact list.
47
+
48
+ ## Rules for the application
49
+
50
+ - An agent's step goes through the same callback as a person's press. `details.source` is `agent` in that callback.
51
+ - A requested change to a controlled value is complete only when the application supplies the new state. After a step,
52
+ read the result again. Wait for `collection-results` to report `status: 'ready'`; a pending read can keep old rows.
53
+ - A refused step explains itself, for example with the columns a table can sort by. Let the agent read the refusal.
54
+ - Advertise an action only when the visible control can perform it. Disable the control and the action together.
55
+ - Keep credentials and private values out of labels, descriptions and results. Set `isSensitive` on `Field.Root`.
56
+ - The bridge is not authorization. The server authorizes every read and mutation.
57
+ - Give every interactive component an accessible name. An agent finds a component by its name and label.
@@ -0,0 +1,63 @@
1
+ # Charts
2
+
3
+ Import shared frames, legends and tones from `@mechane-ai/elements/charts`, and each plot from its own entry. The
4
+ application queries, aggregates, ranks and samples. A chart draws supplied measurements and lets a reader inspect them.
5
+
6
+ ## Choose the chart
7
+
8
+ | The reader asks | Use | Entry |
9
+ | -------------------------------------------- | ----------------------------------------------- | ------------------------------------------- |
10
+ | How did it move over time? | `LineChart`, `AreaChart` | `/charts/cartesian` |
11
+ | The same period for several measures | `SmallMultiples` | `/charts/cartesian` |
12
+ | A trend inside a metric row, not inspectable | `Sparkline` | `/charts/cartesian` |
13
+ | How do categories compare? | `BarChart`, or `RankedBars` in a supplied order | `/charts/cartesian`, `/charts/distribution` |
14
+ | What makes up one total? | `BreakdownBar`, or `Treemap` for many parts | `/charts/cartesian`, `/charts/hierarchy` |
15
+ | How did a total become another total? | `BridgeChart` | `/charts/cartesian` |
16
+ | Where does an amount flow between stages? | `FlowDiagram` | `/charts/graph` |
17
+ | How are values distributed? | `Histogram`, `ECDF`, `IntervalPlot` | `/charts/distribution` |
18
+ | How do two measures relate per record? | `ScatterPlot` | `/charts/cartesian` |
19
+ | A value for every pair of two indexes | `Matrix`, `TokenHeatmap`, with `ColorLegend` | `/charts/matrix` |
20
+ | Which records connect to which? | `RelationGraph` | `/charts/graph` |
21
+ | How long did each step take, and when? | `Waterfall` | `/charts/timeline` |
22
+
23
+ Use a table when exact comparison matters more than shape.
24
+
25
+ ## Supply honest data
26
+
27
+ - A formatter declares its locale, time zone, precision and unit. Use `formatTick` for compact axes and `formatValue`
28
+ for exact readings.
29
+ - A missing value is `null` and draws a gap. A zero is a zero. Never fill a gap to make a line continuous.
30
+ - Time series need strictly increasing timestamps, with one observation per series at each timestamp.
31
+ - A chart shows an error for invalid or oversized input. It never draws a partial chart that looks complete. Choose and
32
+ label a window or an aggregate first; the entries export their limits, such as `timeSeriesLimits`.
33
+ - The title and description say what was measured, and for which period or sample.
34
+
35
+ ## Selection and ranges
36
+
37
+ Inspection is built in. A plot is one Tab stop. Arrow keys, Home and End move a cursor, the readout shows exact values,
38
+ and Escape closes it. Hover and touch do the same. Do not add your own tooltip or key handler.
39
+
40
+ Pass `selection={{ selectedId, onSelect }}` when a click or Enter should select a record. The chart reports an
41
+ identifier and the change details. The app owns the linked inspector, route or filter. Leave `selection` out for a
42
+ read-only graphic. On bars, bridge columns and treemap cells the selected mark keeps an ink edge while another mark is
43
+ inspected.
44
+
45
+ `LineChart` and `AreaChart` take `rangeSelection={{ value, onChange, step }}` for a time range the reader draws, moves
46
+ and resizes. The range is application state in the axis's own unit. `ScatterPlot` takes a controlled rectangular range.
47
+
48
+ To link a table and a bar chart, set `BarChart`'s `highlightedSeriesId` from the table's `onRowHighlightChange`.
49
+
50
+ ## Compose a report
51
+
52
+ Pass `report` when the chart is a self-contained analytical report with a caption, a period summary and the plot. Use
53
+ `report.summary` for mixed metrics or `report.seriesValues` for one value per series. Put scoped controls in
54
+ `report.actions` with `density="compact"`.
55
+
56
+ Inside a region that already groups its content, such as an inspector, use the chart without `report`. Use `ChartFrame`
57
+ and `ChartLegend` for a custom plot, with `chartToneColors` and `chartToneOutlines` for its marks. Pin a series `tone`
58
+ when color carries identity across filters, and reuse it in `ChartSeriesMarker` beside the matching table row.
59
+
60
+ ## Loading
61
+
62
+ Use `TimeSeriesChartPlaceholder`, `SmallMultiplesPlaceholder` or `BarChartPlaceholder` inside an `AsyncRegion`, with the
63
+ same title, report and height as the loaded chart. Keep the real chart mounted during a refresh.
@@ -0,0 +1,89 @@
1
+ # Tables and collections
2
+
3
+ Import from `@mechane-ai/elements/collections`. The components render supplied records and report intent. The
4
+ application owns requests, URL state, permissions and saved preferences.
5
+
6
+ ## Declare the query
7
+
8
+ Every `DataTable` takes a stable `getRowId`, a `caption`, an `empty` state and a `query`.
9
+
10
+ | Query mode | Use it when |
11
+ | ------------ | ------------------------------------------------------------------------------------------------------- |
12
+ | `local` | The app holds every row. Supply a search accessor and filter dimensions; the table filters and windows. |
13
+ | `controlled` | A server pages the rows. Supply search and filter values with callbacks, and reset the page on change. |
14
+ | `frame` | A shared header already holds the controls. Declare them once with `TableQueryFrame`. |
15
+ | `static` | The table is a fixed reference. Give a concrete `reason`. |
16
+
17
+ ```tsx
18
+ <DataTable
19
+ caption="Projects"
20
+ columns={columns}
21
+ rows={projects}
22
+ getRowId={(project) => project.id}
23
+ empty="No projects."
24
+ query={{
25
+ mode: 'local',
26
+ search: (project) => project.name,
27
+ filters: [{ id: 'status', label: 'Status', value: (project) => project.status }],
28
+ }}
29
+ />
30
+ ```
31
+
32
+ To leave out only search or only filters, replace that capability with `{ reason: '…' }`. For a paged source, apply
33
+ search, filters and sort to the whole result before the server takes a page, with a unique key as the last sort field.
34
+
35
+ ## Columns
36
+
37
+ Each column declares a `role`: `primary`, `text`, `status`, `number`, `timestamp` or `actions`. The role owns alignment
38
+ and minimum width, and the primary column takes the remaining space. Check the array with `satisfies`:
39
+
40
+ ```tsx
41
+ const columns = [
42
+ { id: 'name', label: 'Name', role: 'primary', cell: (item: Item) => item.name },
43
+ ] satisfies ReadonlyArray<DataTableColumn<Item>>;
44
+ ```
45
+
46
+ An explicit type annotation widens the columns and then requires the controlled sort props. A column with
47
+ `canSort: true` needs the `sort` and `onSortChange` pair, and the app sorts the rows.
48
+
49
+ - Rows are 48px and text truncates. Set `rowSizing="content"` for records that need several lines.
50
+ - Use `DataTableText` for a primary string with an optional second line.
51
+ - Mark a column `isSecondary` to hide it at the compact breakpoint.
52
+ - The table owns its cell insets. Keep a full-width table outside `PageContent`, or use `PageSection`'s `breakdown`.
53
+
54
+ ## Opening, selecting and paging
55
+
56
+ - `rowAction` makes a record inspectable. Supply `href` for a real link, or a callback for a local action. Other cell
57
+ controls keep their own actions. `activeRowId` marks the inspected record without changing selection.
58
+ - Selection needs `selectedIds`, `onSelectionChange` and a label for each row's checkbox. Shift and a click select a
59
+ range, and the header checkbox selects every supplied row.
60
+ - `CollectionPagination` takes the position text and explicit previous and next availability. Never infer another page
61
+ from the row count.
62
+ - `window` limits the mounted rows of a long page. It does not fetch. Use `CollectionEnd` for loading more, with its
63
+ ready, loading, retry and complete states.
64
+ - Pass `resultStatus` while a read is pending or failed, and keep the previous rows on screen.
65
+
66
+ ## The control row
67
+
68
+ A local or controlled query renders its own search and filters. For a custom header, call `useCollectionControls` with
69
+ the current values and callbacks. It returns `actions`, `chips`, `onKeyDown` and `openSearch`. Put the actions in the
70
+ page or section header and the chips below them in a `CollectionToolbar`.
71
+
72
+ The control row is one toolbar. Tab enters it once, and the arrow keys move between chips, find, filters and display
73
+ options. The search field releases the arrows only from the end of its text. Do not add a second Tab stop or a custom
74
+ key handler around it.
75
+
76
+ ## What the keyboard does
77
+
78
+ - The row actions of a table share one Tab stop. Arrow keys move by a row, Page Up and Page Down by ten, and Home and
79
+ End reach the first and last supplied row.
80
+ - `Timeline` events share one Tab stop, and arrow keys move between them. Links inside an event keep their own stops.
81
+ - Register a shortcut with `useCommandShortcuts` from `/navigation/commands`, beside the action's owner, with an
82
+ explicit `isEnabled`. `CommandPalette` lists the same action records and registers nothing by mounting.
83
+
84
+ ## A selected record
85
+
86
+ `Inspector` puts a list in `master` and the selected record in `detail`, side by side when there is room and stacked in
87
+ a narrow container. Change `revealKey` when the selection changes so a stacked detail scrolls into view. `Details`
88
+ renders labeled fields. `Metric` and `MetricGrid` summarize a record or a period; pass `isLoading` to reserve their
89
+ space. `Timestamp` takes an ISO datetime and a label the app formatted with an explicit locale and time zone.
@@ -0,0 +1,47 @@
1
+ # Conversations and agent activity
2
+
3
+ Import from `@mechane-ai/elements/ai`. These parts render supplied records. They do not call a model, start a run, store
4
+ messages or decide permissions.
5
+
6
+ ## The transcript
7
+
8
+ Compose `Conversation.Root`, `Viewport`, `Content` and one `Item` per message, with `JumpToLatest` inside the root.
9
+
10
+ - Give the viewport a label and each item a stable `messageId`. Key the root by conversation identity.
11
+ - A parent with a bounded height makes the transcript scroll. Without one it grows in page flow.
12
+ - A live conversation follows new content while the reader is at the end, and stops when they scroll up. Do not add a
13
+ scroll effect of your own.
14
+ - Mark the user's just-sent item with `shouldRevealOnAppend`, and keep its ID through acknowledgement.
15
+ - Use `initialPosition="start"` and `shouldFollow={false}` for a historical page.
16
+ - Pass `isStreaming` to `Content` while a reply is incomplete, and to the one `Markdown` message that is streaming.
17
+
18
+ `Message` takes an author, metadata, content, attachments and actions. Use `variant="chat"` for a compact chat with
19
+ end-aligned user messages. Render text with `Markdown` from `/content/markdown`. `MessageAction` is a named icon button
20
+ that shows on hover and focus. `ReplyIndicator` shows a supplied waiting label; remove it when real output arrives.
21
+
22
+ ## The prompt
23
+
24
+ `PromptInput` takes `value`, `onValueChange` and `onSubmit`. The app owns the draft, the request identity, the result
25
+ and any retry. The component never clears the text, so a failed send keeps its draft.
26
+
27
+ - Enter adds a line by default. `enterBehavior="submit"` submits, and Shift and Enter adds a line. Command or Control
28
+ with Enter always submits.
29
+ - Pass `history`, oldest first, for Arrow Up recall on the first line.
30
+ - Supplying `onStop` shows Stop in place of Send.
31
+ - Use `isCompact` for a composer pinned below a conversation.
32
+ - Model choice, suggestions and attachments go in the `controls` and `attachments` slots.
33
+
34
+ ## Activity, approvals and sources
35
+
36
+ | To show | Use |
37
+ | ----------------------------------- | ------------------------------------------------------------------ |
38
+ | A recorded shell command and output | `CommandActivity` |
39
+ | Ordered recorded steps, nested runs | `Trace` from `/content` |
40
+ | Tool input and output | `JsonViewer`, `CodeBlock`, `LogViewer`, `StackTrace` |
41
+ | A decision a person must make | `Approval` with an identified request |
42
+ | Where an answer came from | `Sources` and `InlineCitation` |
43
+ | A file change | `DiffViewer` from `/content/diff`, `FileTree` from `/content/tree` |
44
+ | Context use | `Meter` from `/feedback`, with `null` for unknown |
45
+
46
+ An `Approval` reports intent. Show it as settled only after the application acknowledges the outcome. A supplied summary
47
+ is not a model's hidden reasoning, and a recorded command is not a live terminal. Label them as what they are.
@@ -0,0 +1,81 @@
1
+ # Forms
2
+
3
+ Import controls from `@mechane-ai/elements/forms` and date controls from `/forms/dates`. The application supplies
4
+ values, labels, validation, permissions and the save.
5
+
6
+ ## Choose the control
7
+
8
+ | The reader | Use |
9
+ | ------------------------------------------------- | ------------------------------------------------------------------ |
10
+ | Types a line or several lines | `Input`, `Textarea` |
11
+ | Types a number with steps, or drags a bound | `NumberField`, `Slider`, both with a `locale` |
12
+ | Ticks a choice that a later save submits | `Checkbox` |
13
+ | Turns on a setting that applies at once | `Switch` |
14
+ | Picks one value in a form | `RadioGroup` |
15
+ | Switches between a few views, one always checked | `SegmentedControl` |
16
+ | Presses independent options, such as formatting | `ToggleGroup` |
17
+ | Picks one of several labeled strings | `SelectControl` |
18
+ | Needs rich options, object values or many choices | compound `Select` |
19
+ | Searches a finite or remote set of options | `Combobox` |
20
+ | Chooses, drops or pastes files | `FilePicker` |
21
+ | Picks a date, a day range, a month or months | `DatePicker`, `DateRangePicker`, `MonthPicker`, `MonthRangePicker` |
22
+
23
+ ```tsx
24
+ <SegmentedControl.Root value={view} onValueChange={setView} aria-label="View">
25
+ <SegmentedControl.Item value="table">Table</SegmentedControl.Item>
26
+ <SegmentedControl.Item value="chart">Chart</SegmentedControl.Item>
27
+ </SegmentedControl.Root>
28
+ ```
29
+
30
+ Use `Menu` from `/overlays` for commands and immediate choices, not for a form value.
31
+
32
+ ## Label and validate
33
+
34
+ `Field.Root` associates `Field.Label`, `Field.Description` and `Field.Error` with its control. Validation text stays
35
+ beside its field. Use `Fieldset` to name a group of fields, and `InputGroup` for a prefix, suffix or action beside an
36
+ `Input`.
37
+
38
+ ```tsx
39
+ <Field.Root name="reason" invalid={isInvalid}>
40
+ <Field.Label>Reason</Field.Label>
41
+ <Input required value={reason} onValueChange={setReason} />
42
+ <Field.Error match={isInvalid}>Enter a reason.</Field.Error>
43
+ </Field.Root>
44
+ ```
45
+
46
+ - `Input` and `Textarea` report edits through `onValueChange`, from a person or an agent.
47
+ - Set `isSensitive` on `Field.Root` for credentials and private drafts. The value, label and validation then stay out of
48
+ what an agent can read. Password inputs do this already.
49
+ - A disabled control is unavailable. A read-only value stays selectable.
50
+
51
+ ## Save
52
+
53
+ Put the submit row in `FormActions`. Pass `isPending` to the button while the request runs; it keeps focus and prevents
54
+ a second activation. Show the outcome with `FormStatus` in its pending, error or success state.
55
+
56
+ For a change that is hard to undo, use `ConfirmButton` with a `confirmation` sentence that names the record, usually
57
+ inside an `AlertDialog`. Keep the safe action first, keep the dialog open with an inline error until the server
58
+ acknowledges success, and keep the draft when the save fails. The **Consequential form** recipe shows the whole flow.
59
+
60
+ ## Files
61
+
62
+ `FilePicker` takes `accept`, `multiple`, `maxFiles`, `maxSize` and `minSize`, and reports
63
+ `onValueChange(files, details)`. It lists the chosen files and says why one was refused. It never uploads or reads a
64
+ file. The application owns storage and progress, and the server still enforces every limit. State the formats and limits
65
+ in `Field.Description`.
66
+
67
+ ## Dates
68
+
69
+ Dates are civil values, `{ year, month, day }` with one-based months. Supply the locale, time zone, today, bounds and
70
+ presets explicitly; a picker reads no clock. The app converts an inclusive range to its API's timestamps.
71
+
72
+ - The day pickers take a typed date, one field per unit. Digits fill a unit and the arrow keys step it.
73
+ - A picker keeps a draft in its popup. Apply commits one complete value. Escape and Cancel discard it.
74
+ - Use `isClearable={false}` for a required reporting period, and `validateRange` to refuse an unsupported interval.
75
+ - `parseCalendarDate`, `serializeCalendarDate`, `addCalendarDays` and their month forms convert and step values.
76
+ - `Calendar` is an inline calendar with immediate selection. `EventMonth` is a month grid of the app's own events.
77
+
78
+ ## Settings pages
79
+
80
+ `SettingsSection` groups settings and `SettingsRow` binds a real `controlId` to its label and description. Settings that
81
+ apply at once use `Switch` or a select. Settings saved together use a form with `FormActions`.