@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
package/README.md CHANGED
@@ -11,18 +11,37 @@ navigation and modifier-key behavior.
11
11
 
12
12
  ## Build with an agent
13
13
 
14
- Use the [use-elements skill](skills/use-elements/SKILL.md) when building an app and the
15
- [extend-elements skill](skills/extend-elements/SKILL.md) when changing the library. Both ship with the package.
14
+ The package ships skills that teach a coding agent this library, matched to the installed version. Copy them into the
15
+ agent's skills directory from a project with Elements installed:
16
16
 
17
- Find a recipe by task from a project with Elements installed:
17
+ ```sh
18
+ pnpm exec mechane-elements-catalog --install-skills .claude/skills
19
+ ```
20
+
21
+ Use `.agents/skills` or another directory for an agent that reads skills from there. Run the command again after each
22
+ upgrade; it replaces the three skills with the new version's copies.
23
+
24
+ | Skill | Use it to |
25
+ | ---------------------------------------------------- | ------------------------------------------------------------------------ |
26
+ | [use-elements](skills/use-elements/SKILL.md) | Choose components and build a page, with a guide for each family. |
27
+ | [review-elements](skills/review-elements/SKILL.md) | Check a page by keyboard, read state, width, theme and agent access. |
28
+ | [upgrade-elements](skills/upgrade-elements/SKILL.md) | Move an app to a new version, with the changes each release needs. |
29
+ | [extend-elements](skills/extend-elements/SKILL.md) | Change the library itself. It stays in the package and is not installed. |
30
+
31
+ An agent without skills can read the same files in place. Add one line to its instructions file, such as `AGENTS.md`:
32
+ "Before building UI, read `node_modules/@mechane-ai/elements/skills/use-elements/SKILL.md`."
33
+
34
+ Find a recipe by task, or a component by its export name:
18
35
 
19
36
  ```sh
20
37
  pnpm exec mechane-elements-catalog "searchable table with filters"
38
+ pnpm exec mechane-elements-catalog segmentedcontrol
21
39
  ```
22
40
 
23
- The catalog connects a task to the example's TSX, public imports, and rendered Storybook story. Read the same index
24
- programmatically at `@mechane-ai/elements/catalog.json`. When running the local Elements Storybook, connect an MCP
25
- client to `http://localhost:6006/mcp` to explore the examples while developing.
41
+ The catalog connects a task to the example's TSX, public imports, and rendered Storybook story, and a component to its
42
+ import path and declaration file. Read the same index programmatically at `@mechane-ai/elements/catalog.json`. When
43
+ running the local Elements Storybook, connect an MCP client to `http://localhost:6006/mcp` to explore the examples while
44
+ developing.
26
45
 
27
46
  ## Enable an agent in an app
28
47
 
@@ -46,12 +65,12 @@ available actions. After requesting a change, read the resulting state, includin
46
65
  data owner. Keep credentials and private values out of observable labels, descriptions, and results. The application
47
66
  authorizes data reads and mutations on the server.
48
67
 
49
- | What the agent needs | What to look for in the mounted UI |
50
- | ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
51
- | Find and open a record | Use the named `collection-query`, then re-read `collection-results` until its `status` is `ready`. A pending or failed read can retain the previous rows. Match the chosen item to a mounted `collection-record` by `collection` and `recordId`, then use its advertised action. |
52
- | Know where the user is | Read the `page-title`, current `navigation-link` or tab, and the `page-section` at the reading position. Scrolling updates the section an agent can query. |
53
- | Inspect a chart or file | Query chart or tree items for the visible label and identifier. Read the chart's formatted `readout` after inspection. After selection, query the inspector's labeled `detail-field` entries. |
54
- | Complete a form | Use visible field validation and `form-status` for pending, error, or success. Use `Field.Root isSensitive` to hide sensitive labels, values, and validation from the bridge. Put `ConfirmButton` on the action that performs a consequential mutation. |
68
+ | What the agent needs | What to look for in the mounted UI |
69
+ | ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
70
+ | Find and open a record | Use the named `collection-query`, then re-read `collection-results` until its `status` is `ready`. A pending or failed read can retain the previous rows. Each item is a row named as a reader sees it. Use the `open`, `sort`, `select`, `previousPage` and `nextPage` actions of `collection-results`. |
71
+ | Know where the user is | Read the `page-title`, current `link` or tab, and the `page-section` at the reading position. Scrolling updates the section an agent can query. |
72
+ | Inspect a chart or file | Query chart or tree items for the visible label and identifier. Read the chart's formatted `readout` after inspection. After selection, query the inspector's labeled `detail-field` entries. |
73
+ | Complete a form | Use visible field validation and `form-status` for pending, error, or success. Use `Field.Root isSensitive` to hide sensitive labels, values, and validation from the bridge. Put `ConfirmButton` on the action that performs a consequential mutation. |
55
74
 
56
75
  ## Install
57
76
 
@@ -181,8 +200,14 @@ application owns which view is active and when to unmount it; use this for a dra
181
200
  inspection. `WorkbenchScroll` requires an accessible `label`; its `isFlush` mode leaves list insets to the table. Its
182
201
  `scrollRestorationId` identifies the actual scroll region for application-owned restoration. Layout wrappers leave
183
202
  sequential keyboard navigation to their controls. Tables and viewers add a named scroll stop when overflow needs one.
184
- Interactive Cartesian charts have one Tab stop, a local datum cursor, and arrow-key inspection. Enter or Space activates
185
- supplied selection; Escape dismisses details while retaining the cursor.
203
+ Interactive charts have one Tab stop, a local datum cursor, and arrow-key inspection. Enter or Space activates supplied
204
+ selection; Escape dismisses the readout while retaining the cursor.
205
+
206
+ Change callbacks receive the UI SDK's change details after the value. `details.reason` names what happened, such as
207
+ `input-change`, `clear-press` or `item-press`, and `details.source` says whether a pointer, the keyboard, an agent or
208
+ code caused it. `Input` and `Textarea` `onValueChange`, a collection's `search.onChange` and `search.onSubmit`, a
209
+ filter's `onChange`, `FilterChips` `onRemove`, a chart's `selection.onSelect` and a table's `onSortChange` and
210
+ `onSelectionChange` all pass them.
186
211
 
187
212
  `Workbench` accepts an optional `inspector={{ label: 'Workspace', content: <WorkspaceFiles /> }}`. The application
188
213
  supplies the accessible name with the panel content and owns opening, closing, and focus restoration. The inspector
@@ -211,10 +236,15 @@ Set `rowSizing="content"` for records that need multiline cells; virtualization
211
236
  belongs in a detail view or a deliberately content-sized row, not behind a clipped control. Use `DataTableText` for a
212
237
  primary string and optional secondary string inside one cell; both text elements own their ellipsis. Arbitrary nested
213
238
  layouts do not inherit text truncation. Give dates and numeric values sufficient column width or explicit content
214
- sizing. The table owns its cell insets, so an enclosing page should not add another gutter around its rows.
215
- `CollectionEnd` renders nothing when complete unless an explicit summary is supplied. `Timeline.Root` and
216
- `Timeline.Item` compose readable activity with supplied titles, icons, timestamps, metadata, and body content, without
217
- interpreting domain events.
239
+ sizing. The table owns its cell insets, so an enclosing page should not add another gutter around its rows. A table's
240
+ row actions share one Tab stop. Arrow keys move by a row, Page Up and Page Down by ten, and Home and End reach the first
241
+ and last supplied row, including rows the window has not rendered. With `selectedIds`, a row's checkbox toggles it,
242
+ Shift and a click select the range from the row chosen before, and the header checkbox selects every supplied row. The
243
+ control row above a table is one UI SDK toolbar: applied filter chips, find, filters and display share a Tab stop, and
244
+ arrow keys move between them. `CollectionEnd` renders nothing when complete unless an explicit summary is supplied.
245
+ `Timeline.Root` and `Timeline.Item` compose readable activity with supplied titles, icons, timestamps, metadata, and
246
+ body content, without interpreting domain events. The events share one Tab stop on the UI SDK timeline, and arrow keys
247
+ move between them.
218
248
 
219
249
  `CommandActivity` from `/ai` presents a collapsed Bash command with supplied execution state. Its `CommandDetails` body
220
250
  is also available for an existing trace disclosure. Supply command and output text separately, with explicit omission
@@ -1,10 +1,34 @@
1
- import { readFileSync } from 'node:fs';
1
+ import { cpSync, readFileSync, rmSync } from 'node:fs';
2
+ import { join, resolve } from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
2
4
  import { parseArgs } from 'node:util';
3
5
 
4
6
  const ignored = new Set(['a', 'an', 'and', 'are', 'build', 'for', 'in', 'of', 'on', 'page', 'the', 'to', 'with']);
5
7
 
8
+ /** The skills for an application that uses Elements. The package also ships a skill for changing the library. */
9
+ const appSkills = ['use-elements', 'review-elements', 'upgrade-elements'];
10
+
6
11
  /** @import {Catalog} from './catalog.d.mts' */
7
12
 
13
+ /**
14
+ * Replaces each application skill in the directory with the copy from the installed package.
15
+ *
16
+ * @param {Catalog} catalog The catalog built from the public package.
17
+ * @param {string} directory The agent's skills directory, such as `.claude/skills`.
18
+ */
19
+ function installSkills(catalog, directory) {
20
+ const installed = appSkills.map((name) => {
21
+ const target = resolve(directory, name);
22
+
23
+ rmSync(target, { recursive: true, force: true });
24
+ cpSync(fileURLToPath(new URL(`../skills/${name}`, import.meta.url)), target, { recursive: true });
25
+
26
+ return join(directory, name);
27
+ });
28
+
29
+ return { package: catalog.package, version: catalog.version, installed };
30
+ }
31
+
8
32
  /**
9
33
  * @param {Catalog} catalog The catalog built from the public package.
10
34
  * @param {string} query Normalized task or public export name.
@@ -44,17 +68,31 @@ function lookup(catalog, query) {
44
68
  };
45
69
  }
46
70
 
71
+ const usage = [
72
+ 'Usage: mechane-elements-catalog [task or public export name]',
73
+ ' mechane-elements-catalog --install-skills <directory>',
74
+ '',
75
+ 'With a task, prints the matching recipes, public exports and the best example as JSON.',
76
+ 'With --install-skills, copies the Elements skills into an agent skills directory such as .claude/skills.',
77
+ ].join('\n');
78
+
47
79
  /** @param {Catalog} catalog The catalog built from the public package. */
48
80
  export function runCatalog(catalog) {
49
81
  const { positionals, values } = parseArgs({
50
82
  allowPositionals: true,
51
- options: { help: { type: 'boolean', short: 'h', default: false } },
83
+ options: { 'help': { type: 'boolean', short: 'h', default: false }, 'install-skills': { type: 'string' } },
52
84
  });
53
85
 
86
+ const directory = values['install-skills'];
87
+
54
88
  if (values.help) {
55
- process.stdout.write('Usage: mechane-elements-catalog [task or public export name]\n');
89
+ process.stdout.write(`${usage}\n`);
56
90
  } else {
57
- const result = lookup(catalog, positionals.join(' ').trim().toLowerCase());
91
+ const result =
92
+ directory === undefined
93
+ ? lookup(catalog, positionals.join(' ').trim().toLowerCase())
94
+ : installSkills(catalog, directory);
95
+
58
96
  process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
59
97
  }
60
98
  }