@collective-intelligence/ui-react 0.6.0 → 0.7.1

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 (87) hide show
  1. package/README.md +220 -170
  2. package/dist/components/ai-elements/index.d.ts +445 -4
  3. package/dist/components/ai-elements/index.js +3 -1
  4. package/dist/components/icons/index.d.ts +184 -1
  5. package/dist/components/icons/index.js +1 -1
  6. package/dist/components/illustrations/index.js +1 -1
  7. package/dist/components/ui/index.d.ts +293 -235
  8. package/dist/components/ui/index.js +2 -4
  9. package/dist/components/ui-extensions/atoms/ThemeToggle/index.js +1 -1
  10. package/dist/components/ui-extensions/hooks/use-mobile.js +1 -1
  11. package/dist/components/ui-extensions/index.d.ts +36 -21
  12. package/dist/components/ui-extensions/index.js +6 -6
  13. package/dist/components/ui-extensions/molecules/LabeledField/index.d.ts +22 -0
  14. package/dist/components/ui-extensions/molecules/LabeledField/index.js +2 -0
  15. package/dist/components/ui-extensions/molecules/VideoPlayer/index.js +2 -2
  16. package/dist/hooks/index.js +1 -1
  17. package/dist/hooks/operations.js +1 -1
  18. package/dist/hooks/use-debounced-callback.js +1 -1
  19. package/dist/hooks/use-mount-action.js +1 -1
  20. package/dist/index-0dt7qv78.js +2 -0
  21. package/dist/index-33ef93f6.js +2 -0
  22. package/dist/index-410hza8j.js +2 -0
  23. package/dist/index-78w37zqq.js +2 -0
  24. package/dist/{index-9gtg7nt7.js → index-9tdk1jd5.js} +2 -2
  25. package/dist/index-ampejsqd.js +2 -0
  26. package/dist/index-aq49ztmj.js +2 -0
  27. package/dist/index-brb2fssx.js +4 -0
  28. package/dist/index-c4aack9s.js +2 -0
  29. package/dist/index-e0qytqhh.js +2 -0
  30. package/dist/index-eh2w7m4e.js +2 -0
  31. package/dist/index-ftn430ea.js +2 -0
  32. package/dist/{index-6r0znbzv.js → index-fzn1f905.js} +2 -2
  33. package/dist/index-hqx38rgx.js +0 -0
  34. package/dist/{index-4cds99c5.js → index-jmgcfmxe.js} +2 -2
  35. package/dist/index-jzyzapvz.js +2 -0
  36. package/dist/{index-qbwndfn2.js → index-kzykjydw.js} +2 -2
  37. package/dist/{index-zmwpsfzp.js → index-p2yzw0qb.js} +2 -2
  38. package/dist/index-pe89kg1j.js +2 -0
  39. package/dist/index-pkw46hwt.js +2 -0
  40. package/dist/index-q560eskm.js +2 -0
  41. package/dist/{index-rjemhrz1.js → index-r9trsk22.js} +2 -2
  42. package/dist/{index-vx2b9cz3.js → index-shpd3834.js} +2 -2
  43. package/dist/index-t2rwc8rk.js +2 -0
  44. package/dist/index-tb9dhges.js +2 -0
  45. package/dist/{index-9289ppfk.js → index-w3zn83g3.js} +2 -2
  46. package/dist/index-w7hwsck8.js +2 -0
  47. package/dist/index-wnkq9nn0.js +2 -0
  48. package/dist/index-xy8a2fr7.js +2 -0
  49. package/dist/index-yaf9t9w5.js +42 -0
  50. package/dist/index-yh7sjgdy.js +2 -0
  51. package/dist/index.js +1 -1
  52. package/dist/resources.js +1 -1
  53. package/dist/shadcn.css +3 -4
  54. package/dist/tokens/theme.js +1 -1
  55. package/dist/utils/cn.js +1 -1
  56. package/package.json +12 -45
  57. package/dist/chat.d.ts +0 -579
  58. package/dist/chat.js +0 -2
  59. package/dist/index-064d20xp.js +0 -2
  60. package/dist/index-0gzm7bb9.js +0 -2
  61. package/dist/index-1hxjsnw5.js +0 -2
  62. package/dist/index-2twj52t7.js +0 -2
  63. package/dist/index-2yf6mq9g.js +0 -2
  64. package/dist/index-64r6cav3.js +0 -1
  65. package/dist/index-7j277075.js +0 -2
  66. package/dist/index-ab3fc47y.js +0 -2
  67. package/dist/index-b1wfq5b8.js +0 -2
  68. package/dist/index-dg126t3v.js +0 -2
  69. package/dist/index-dvvkk1vk.js +0 -2
  70. package/dist/index-ecvn2gnv.js +0 -2
  71. package/dist/index-fnk7gsdd.js +0 -2
  72. package/dist/index-ggr2edm8.js +0 -2
  73. package/dist/index-m0v264jr.js +0 -2
  74. package/dist/index-ngpxevag.js +0 -2
  75. package/dist/index-nxbvv8m4.js +0 -2
  76. package/dist/index-pearjjhb.js +0 -2
  77. package/dist/index-r2snvwyb.js +0 -42
  78. package/dist/index-r5ds1mtq.js +0 -2
  79. package/dist/index-r7hjj3ek.js +0 -2
  80. package/dist/index-rgbg5bsy.js +0 -2
  81. package/dist/index-sd38wa4w.js +0 -2
  82. package/dist/index-t9yq7kfg.js +0 -2
  83. package/dist/index-tcwzyy71.js +0 -2
  84. package/dist/index-vyhk8kgm.js +0 -6
  85. package/dist/index-ykjbsyeq.js +0 -2
  86. package/dist/index-zrw7ne3f.js +0 -2
  87. package/dist/styles.css +0 -2
package/README.md CHANGED
@@ -7,9 +7,11 @@ The package preserves the design-system source structure under
7
7
  `src/components/`, including `ui`, `ui-extensions`, `icons`, and
8
8
  `illustrations`, plus shared hooks, utilities, and theme tokens. The
9
9
  `/resources` entrypoint contains generic table, list, filter, pagination,
10
- dialog, and action primitives. The `/chat` entrypoint contains the chat
11
- display parts, and `/styles.css` is the prebuilt stylesheet for apps without
12
- Tailwind.
10
+ dialog, and action primitives. `/ai-elements` contains the AI Elements of the
11
+ chat. Every primitive is built on Base UI (`@base-ui/react`) with the shadcn
12
+ `base-lyra` look. Apps style them with Tailwind v4 (see
13
+ [Styling a host app](#styling-a-host-app)). To move from 0.5 or earlier, see
14
+ [Migrating to the chat release minor](#migrating-to-the-chat-release-minor).
13
15
 
14
16
  All components accept display-ready props and do not fetch data, own
15
17
  authentication, or depend on private CI packages. React and React DOM remain
@@ -19,18 +21,20 @@ peer dependencies.
19
21
  prebundle. Consumers must provide it so the public `Form` provider and their
20
22
  form hooks share the same context.
21
23
 
24
+ `streamdown` is a required peer dependency: `MarkdownEditorPreview` and the
25
+ AI Elements render Markdown with it. `ai` (`>=7.0.173 <8`) is an optional peer
26
+ dependency, needed only by the AI Elements that take AI SDK types (see
27
+ [AI Elements](#ai-elements)). Both are excluded from this package's browser
28
+ prebundle, so browser and server-side rendering consumers resolve them for
29
+ their own runtime.
30
+
22
31
  `bun run build` produces production JSX for the published entrypoints while
23
32
  keeping React and React DOM external. These artifacts support consumers using
24
33
  either production or development React. After building,
25
34
  `bun run test test/built-runtime.test.ts` verifies rendering with both modes.
26
35
 
27
- `react-markdown` and `remark-gfm` remain regular runtime dependencies and are
28
- excluded only from this package's browser prebundle. Browser and server-side rendering
29
- consumers resolve its dependencies for their own runtime, keeping browser-only
30
- DOM code out of server imports.
31
-
32
36
  Published entrypoints share runtime chunks inside `dist`; distribute that
33
- directory intact. This keeps modal focus and pointer-lock state shared when
37
+ directory intact. This keeps modal focus and scroll-lock state shared when
34
38
  composing primitives from `/ui` with dialogs from `/ui-extensions`.
35
39
  `bun run test:pack` rebuilds the package and checks this cross-entrypoint
36
40
  modal lifecycle and consumer form context before validating the packed consumer.
@@ -88,94 +92,10 @@ Run `bun run build-storybook` for the interactive **Resources / Controlled
88
92
  entity / Journey** example. `bun run test:pack` checks these exports from the
89
93
  packed JavaScript and declarations in an isolated external consumer.
90
94
 
91
- ## Chat parts
92
-
93
- Import the generic chat display parts from
94
- `@collective-intelligence/ui-react/chat`. They take display-ready values and
95
- callbacks only: they make no request, hold no query state and construct no
96
- client. The AI React package composes them with the chat state.
97
-
98
- - `ChatMessage`: one message row. Pass `sender` (`user` or `assistant`), the
99
- display-ready `author` and `timestamp`, and the body as `children`. `avatar`
100
- replaces the default sender avatar.
101
- - `ChatMarkdown`: an answer's Markdown with GitHub extensions (tables, task
102
- lists, strikethrough, autolinks) through `remark-gfm`. Links open in a new
103
- tab. `components` replaces element renderers over the chat defaults.
104
- - `ChatComposerShell`: the composer frame with a controlled `value`,
105
- `onValueChange` and `onSubmit`. Enter sends; Shift+Enter adds a line.
106
- `state` is `idle`, `submitting` or `running`; with `onStop`, a running
107
- answer shows a stop button in place of Send, which waits and takes no
108
- second press while `stopping` is `true`. With `showStop`, the stop button
109
- shows in any `state` and Send stays, for an answer that still takes
110
- messages: the stop button comes first in the trailing controls, so a send
111
- menu in `trailing` stays beside Send. `onFilesAdd` receives dropped and
112
- pasted files.
113
- The `notice`, `attachments`, `suggestions`, `leading`, `trailing` and
114
- `footer` slots place caller content around the input. `onInputKeyDown` runs
115
- first; prevent its default to replace Enter-to-send, for example in a slash
116
- command menu. `labels` holds every visible and accessible text.
117
- - `ChatToolEvidence`: the display parts of tool results, each in a titled
118
- frame. A part is one of `evidence`, `table`, `sources`, `links`, `summary`,
119
- `warnings`, `text`, `json` or `custom`. Only `http` and `https` URLs become
120
- links. Long tables and source lists show more rows on request.
121
- - `ChatProcessingSteps`: a run summary that opens to a timeline of `steps`
122
- (`kind`, `label`, optional `detail`, `status`). Use `open` and
123
- `onOpenChange` to control it, or `defaultOpen`.
124
- - `ChatApprovalCard`: an approval request with its `status` (`pending`,
125
- `approved`, `rejected`, `cancelled`, `expired`), `summary`, `meta`, `steps`
126
- with progress, recorded `decisions` and `resolution`. `onApprove` receives
127
- the optional comment (or `null`); `onReject` receives the required reason,
128
- which a reject form asks for. Leave a callback out to hide its control;
129
- leave both out to show a pending request as read only. `pendingAction`
130
- (`approve` or `reject`) holds every control. `outcome` (`recorded`,
131
- `continuation_in_progress`, `continuation_failed`,
132
- `reconciliation_required`, `already_approved`, `already_decided`) replaces
133
- the controls with its label. `children` shows caller content, for example
134
- the request context, above the controls.
135
- - `ChatQuestionCard`: a question or a direct confirmation. `mode` is `choice`
136
- (the first click answers), `choice_or_text` (choices and a free-text answer
137
- with Continue), `text` (an open answer) or `confirm` (approve, or revise
138
- with text). `onRespond` receives `{ action: "answer", optionId }`,
139
- `{ action: "answer", text }`, `{ action: "approve" }` or
140
- `{ action: "revise", text }`. `status` `responding` holds the controls;
141
- `completed`, `failed` and `cancelled` show the prompt, the status label and
142
- the optional `outcome`.
143
- - `ChatPermissionPrompt`: a capability permission prompt for the capability
144
- `name`. `onDecide` receives `deny`, `allow_this_conversation` or
145
- `allow_always`; `pendingDecision` holds the buttons.
146
- - `ChatAnswerFeedback`: thumbs up and down for an answer. `value` is the
147
- current `positive` or `negative` rating; a second press calls `onClear`.
148
- Thumbs down asks for a required note in a dialog before `onSubmit`;
149
- submit stays disabled while the note is blank. Thumbs up sends no note.
150
- `pending` holds the buttons.
151
- - `ChatAttachmentChip`: one file. `mode="draft"` takes `onRemove`;
152
- `mode="stored"` takes an optional `onDownload` (no callback, no download
153
- button), `pending` and `error`. `previewUrl` shows an image thumbnail that
154
- opens in a dialog; the caller owns the URL, for example an object URL.
155
- - `ChatRunStatus`: an answer's run with a display-ready status `label`, a
156
- `tone` (`success`, `warning`, `danger`, `primary`, `neutral`) and an
157
- optional `detail`, for example a short run id.
158
- - `ChatMemoryEvidence`: the `used` and `saved` counts, a `memoryDisabled`
159
- badge and the first six display-ready `events`. It renders nothing without
160
- events.
161
- - `ChatContextUsageRing`: how full the conversation context is, from a
162
- `ratio` between 0 and 1, as a ring meter named by `label`.
163
- - `ChatCompactionMarker`: the transcript line above which a summary replaces
164
- the older context, with the covered `messageCount`, else `runCount`.
165
-
166
- The parts with an `error` prop show it as an alert. Overlays (the feedback
167
- note and the image preview) render in the container of
168
- `PortalContainerProvider`.
169
-
170
- Each part takes `className` and `classNames` for its inner elements and marks
171
- its root with `data-part`.
172
-
173
- ## Base UI chat primitives
174
-
175
- `/ui` also exports the shadcn `base-lyra` chat primitives, built on Base UI
176
- (`@base-ui/react`) and `@shadcn/react`. They sit beside the Radix components:
177
- no Radix component changes, and their names do not clash with the existing
178
- `/ui` exports.
95
+ ## Chat primitives
96
+
97
+ `/ui` exports the shadcn `base-lyra` chat primitives, built on Base UI and
98
+ `@shadcn/react` like the rest of `/ui`. They were public from 0.3.8:
179
99
 
180
100
  | Component | Exports |
181
101
  | ---------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
@@ -199,29 +119,19 @@ no Radix component changes, and their names do not clash with the existing
199
119
  or the children you pass, and `lineNumbers` numbers a text child. The
200
120
  package does not bundle `shiki`.
201
121
  - `HoverCardContent` renders into the nearest `PortalContainerProvider`
202
- container, like the Radix overlays, and takes its own `container` prop.
203
- - The Base UI `Button`, `Collapsible` and `Separator` that these parts use
204
- are internal (`src/components/ui/base/`). `/ui` still exports the Radix
205
- `Button`, `Collapsible` and `Separator`.
206
- - The primitives use the `base-lyra` classes and the shadcn variants and
207
- utilities (`data-open:`, `scroll-fade-*`, `shimmer`, `no-scrollbar`). A
208
- Tailwind v4 app that renders them adds
209
- `@import "@collective-intelligence/ui-react/shadcn.css";` after
210
- `@import "tailwindcss"`. The published `shadcn.css` registers the package's
211
- `dist` folder with `@source`, because Tailwind does not scan `node_modules`
212
- on its own, so the app needs no `@source` of its own for these parts. Today only this package's Storybook does; the
213
- Dashboard, the Studio and `tokens.css` do not.
214
- - The prebuilt `/styles.css` does not include their classes: `ci.css`
215
- excludes their files with `@source not`, so the stylesheet is byte-identical
216
- to the one before they were added.
217
- - `@shadcn/react` declares `react >=19`. It uses no React 19 hook; under React
218
- 18 a `ref` you pass to a message-scroller part does not reach the element,
219
- as for the other `/ui` components that take `ref` as a prop.
122
+ container, like the other overlays, and takes its own `container` prop.
123
+ - `@shadcn/react` declares `react >=19`. It uses no React 19 hook, but the
124
+ message scroller needs React 19 for its `ref`: under React 18 a `ref` that
125
+ you pass to a message-scroller part does not reach the element, as for the
126
+ other `/ui` components that take `ref` as a prop.
220
127
 
221
128
  ## AI Elements
222
129
 
223
- `/ai-elements` exports the AI Elements that do not depend on the AI SDK
224
- (`ai`), on the Base UI collapsible:
130
+ `/ai-elements` exports the AI Elements of the chat, with their parts and prop
131
+ types. The entry is client-only (`"use client"`) and renders on the server.
132
+ None makes a network request.
133
+
134
+ These need no AI SDK (public from 0.3.8):
225
135
 
226
136
  - `Reasoning`, `ReasoningTrigger`, `ReasoningContent` and `useReasoning`.
227
137
  `ReasoningContent` renders its Markdown string with core Streamdown (no
@@ -236,51 +146,89 @@ no Radix component changes, and their names do not clash with the existing
236
146
  - `Sources`, `SourcesTrigger`, `SourcesContent` and `Source`.
237
147
  - `Shimmer`, which animates with the Web Animations API instead of `motion`.
238
148
 
239
- `streamdown` is an optional peer dependency, needed only by `/ai-elements`,
240
- and is excluded from this package's browser prebundle like `react-markdown`.
241
- Install it next to the package when you import `/ai-elements`. Streamdown's
242
- own classes need a Tailwind `@source` on `node_modules/streamdown/dist/*.js`
243
- in the app. The entry is client-only (`"use client"`) and renders on the
244
- server.
245
-
246
- ## Prebuilt stylesheet
247
-
248
- Apps without Tailwind import `@collective-intelligence/ui-react/styles.css`
249
- once and render the chat inside an element with the `ci-root` class. Every
250
- rule of the stylesheet applies inside that element, so no style reaches the
251
- rest of the page:
252
-
253
- - Preflight, utilities and the design tokens apply to `.ci-root` and its
254
- subtree. The tokens are CSS variables on `.ci-root`; set a variable on the
255
- element (for example `--radius` or `--background`) to theme the chat. Every
256
- radius size derives from `--radius`; `--font-text`, `--font-heading` and
257
- `--font-code` set the fonts. The stylesheet loads no web font.
258
- - Dark tokens apply with `.ci-root.dark` or under a `.dark` ancestor. A
259
- `light` class on `.ci-root` keeps the chat light under a `.dark` ancestor.
260
- - Keyframes names start with `ci-`. Overlay enter and exit animations of the
261
- Tailwind apps are not part of the stylesheet.
262
-
263
- `bun run build` compiles `src/styles/ci.css` with `@tailwindcss/cli` into
264
- `dist/styles.css`, from the classes of this package's source and of the
265
- `@collective-intelligence/ai-react` source, whose default `<Chat>` uses this
266
- stylesheet only. Tests and stories are not scanned. `turbo.json` lists the
267
- ai-react source as a build input, so a class change there rebuilds the
268
- stylesheet. Tailwind writes
269
- two document-level rules that nesting cannot scope: the preflight
270
- `html, :host` rule and the `@property` fallback rule. The build moves both onto
271
- the chat root and its subtree, and fails when Tailwind changes them. It also
272
- removes every `@property` rule: a registration applies to the whole document,
273
- and a typed one (`--tw-gradient-from` as `<color>`) breaks the same property
274
- of a host page, for example the gradients of a Tailwind v3 app. The fallback
275
- rule then sets the initial value of each Tailwind property inside the chat in
276
- every browser. `test/styles-global-selectors.test.ts` fails on any `:root`,
277
- `html`, `body`, bare `*` or other selector outside `.ci-root`, on any
278
- `@property` rule, and on keyframes without the `ci-` prefix.
279
-
280
- Tailwind apps of this repository (the Dashboard and the Studio) do not import
281
- the prebuilt stylesheet. They import the canonical design tokens from
282
- `src/styles/tokens.css`, keep only their own overrides, and keep scanning this
283
- package's source with `@source`.
149
+ These take AI SDK types, so they need the optional peer `ai`
150
+ (`>=7.0.173 <8`):
151
+
152
+ - `Conversation`, `ConversationContent`, `ConversationItem`,
153
+ `ConversationEmptyState`, `ConversationScrollButton`,
154
+ `ConversationDownload` and `messagesToMarkdown`, on the message scroller.
155
+ - `Message`, `MessageContent`, `MessageResponse` (an answer's Markdown with
156
+ core Streamdown; the app adds Streamdown plugins), `MessageActions`,
157
+ `MessageAction`, `MessageToolbar` and the `MessageBranch` parts.
158
+ - `PromptInput` and its parts (textarea, attachments, action menu, select,
159
+ command, submit, provider and hooks).
160
+ - `Attachments`, `Attachment`, `AttachmentPreview`, `AttachmentInfo`,
161
+ `AttachmentRemove`, the attachment hover card and the helpers
162
+ `getAttachmentLabel` and `getMediaCategory`.
163
+ - `Context` and its parts: the token counts of the context, without cost.
164
+ - `Tool`, `ToolHeader`, `ToolContent`, `ToolInput`, `ToolOutput` and
165
+ `getStatusBadge`. Input and output show in a `CodeBlock`, without `shiki`.
166
+ - `Confirmation` and its parts, which take the `approval` and `state` of a
167
+ tool part.
168
+ - `Questionnaire` and its parts (the shadcn `base-lyra` questionnaire on
169
+ `@shadcn/react`), which submits as a native form.
170
+
171
+ Streamdown's own classes need a Tailwind `@source` on
172
+ `node_modules/streamdown/dist/*.js` in the app.
173
+
174
+ ## Styling a host app
175
+
176
+ The package ships no prebuilt stylesheet. A host app builds the styles of
177
+ these components with its own Tailwind v4 build:
178
+
179
+ ```css
180
+ @import "tailwindcss";
181
+ @import "@collective-intelligence/ui-react/shadcn.css";
182
+ @import "tw-animate-css";
183
+
184
+ /* Tailwind does not scan node_modules by itself. */
185
+ @source "../node_modules/streamdown/dist/*.js";
186
+
187
+ @custom-variant dark (&:is(.dark *));
188
+
189
+ :root {
190
+ --background: #f7f8fa;
191
+ --foreground: #172033;
192
+ /* ...the other shadcn tokens */
193
+ --brand: #1642a3;
194
+ --brand-hover: #10337f;
195
+ --brand-fg: #ffffff;
196
+ }
197
+
198
+ .dark {
199
+ --background: #0f1521;
200
+ --foreground: #eef1f5;
201
+ /* ...the same tokens with their dark values */
202
+ --brand: #7fa3f0;
203
+ --brand-hover: #a3bdf5;
204
+ --brand-fg: #0f1521;
205
+ }
206
+
207
+ @theme inline {
208
+ --color-background: var(--background);
209
+ --color-foreground: var(--foreground);
210
+ /* ...one --color-* per token, as in the shadcn Tailwind v4 setup */
211
+ }
212
+ ```
213
+
214
+ - `shadcn.css` holds the shadcn variants and utilities that the primitives
215
+ use (`data-open:`, `scroll-fade-*`, `shimmer`, `no-scrollbar`), and
216
+ registers this package's `dist` folder with `@source`, so the app needs no
217
+ `@source` for this package. Import it after `@import "tailwindcss"`.
218
+ - `tw-animate-css` gives the overlays their enter and exit animations.
219
+ - Set the shadcn tokens on `:root` and their dark values on `.dark`. Declare
220
+ each token that refers to another variable on `.dark` too: a variable
221
+ resolves on the element that declares it, so a `.dark` element below
222
+ `<html>` otherwise keeps the light value. Put the `dark` class on `<html>`
223
+ or on any ancestor of the components.
224
+ - Besides the shadcn tokens, the components read CI's brand tokens
225
+ `--brand`, `--brand-hover` and `--brand-fg` and the status colors
226
+ `--success`, `--warning` and `--danger`. `--accent` is the shadcn soft
227
+ accent, not the brand color.
228
+ - The Dashboard and the Studio of this repository import
229
+ `src/styles/tokens.css`, which imports `shadcn.css`, declares the CI tokens
230
+ that way and maps them in `@theme`; they keep only their own overrides and
231
+ scan this package's source with `@source`.
284
232
 
285
233
  ## Overlay container
286
234
 
@@ -288,13 +236,15 @@ Dialogs, alert dialogs, sheets, drawers, popovers, menus, menubars, context
288
236
  menus, tooltips, selects and hover cards render into `document.body` by
289
237
  default. Wrap a
290
238
  subtree in `PortalContainerProvider` (from `/ui`) with a `container` element to
291
- render its overlays into that element, for example inside `.ci-root`. The
292
- `container` prop of an overlay's content wins over the provider.
239
+ render its overlays into that element, for example inside the chat root of
240
+ `@collective-intelligence/ai`. The `container` prop of an overlay's content
241
+ wins over the provider; `undefined` falls back to the provider. A container is
242
+ an `HTMLElement` or `null` (`PortalContainer`).
293
243
 
294
244
  ## Error alerts
295
245
 
296
246
  Import `ErrorAlert` from `@collective-intelligence/ui-react/ui-extensions`.
297
- It composes the existing destructive `Alert` and Radix `Collapsible` primitives.
247
+ It composes the existing destructive `Alert` and Base UI `Collapsible` primitives.
298
248
  Pass the visible message as `children`, an optional `title`, and an optional
299
249
  `details` object containing a trigger `label` and arbitrary React `content`.
300
250
  Omitting `details` removes both the disclosure trigger and its panel.
@@ -390,6 +340,25 @@ description to their control with `aria-describedby`. With `CardOption` and a
390
340
  custom `control`, pass a `descriptionId` and set the same id as the
391
341
  `aria-describedby` of your control.
392
342
 
343
+ ## Labelled field
344
+
345
+ `LabeledField` shows a `<label for={id}>` above the control that its children
346
+ render, and an optional `help` text or `error` below it. Import it from
347
+ `@collective-intelligence/ui-react/ui-extensions`, or from its own subpath
348
+ `@collective-intelligence/ui-react/ui-extensions/labeled-field`. The
349
+ `ui-extensions` entry also loads its Markdown components and thus
350
+ `react-markdown`; the subpath does not. Use the subpath in a package that
351
+ needs only the field.
352
+
353
+ ```tsx
354
+ import { Input } from "@collective-intelligence/ui-react/ui"
355
+ import { LabeledField } from "@collective-intelligence/ui-react/ui-extensions/labeled-field"
356
+
357
+ ;<LabeledField id="email" label="Email" help="We send the code here.">
358
+ <Input id="email" type="email" />
359
+ </LabeledField>
360
+ ```
361
+
393
362
  ## Video player
394
363
 
395
364
  Import `VideoPlayer` from its own subpath,
@@ -445,11 +414,92 @@ chunk split and the notice in the packed artifact.
445
414
  ## Enum value migration
446
415
 
447
416
  Repository-owned component options use `snake_case`. Update `Card.visual`
448
- from `accent-gradient` to `accent_gradient`; `InputGroupAddon.align` from
449
- `inline-start`, `inline-end`, `block-start`, or `block-end` to `inline_start`,
450
- `inline_end`, `block_start`, or `block_end`; and `InputGroupButton.size` from
451
- `icon-sm` or `icon-xs` to `icon_sm` or `icon_xs`. Matching `data-align`,
452
- `data-size`, and `data-visual` values use these new spellings too.
417
+ from `accent-gradient` to `accent_gradient`; the matching `data-visual` value
418
+ uses the new spelling too.
419
+
420
+ The shadcn base-lyra primitives keep the registry's spelling: `Button.size`
421
+ takes `icon-sm` and `icon-xs`, `InputGroupAddon.align` takes `inline-start`,
422
+ `inline-end`, `block-start` or `block-end`, and `InputGroupButton.size` takes
423
+ `xs`, `sm`, `icon-xs` or `icon-sm`. Replace the earlier `inline_start`,
424
+ `block_end` and `icon_sm` spellings of these props.
453
425
 
454
426
  Native HTML input types retain their protocol spelling: for example,
455
427
  `ResourceField.control` accepts `datetime-local` and forwards it to the input.
428
+
429
+ ## Migrating to the chat release minor
430
+
431
+ The chat release minor is the next minor release after 0.5.0. It moves every
432
+ primitive from Radix to Base UI with the `base-lyra` look, renames the brand
433
+ token, and removes `./chat` and `./styles.css`, with no compatibility layer.
434
+ The package CHANGELOG says who each change affects. Do these steps:
435
+
436
+ 1. Install the required peer `streamdown` (`^2.7.0`). Remove `react-markdown`,
437
+ `remark-gfm` and `vaul` if only this package needed them. Install `ai`
438
+ (`>=7.0.173 <8`) if you import the AI Elements that take AI SDK types.
439
+ 2. Replace an import of `@collective-intelligence/ui-react/styles.css` with
440
+ the Tailwind v4 setup of [Styling a host app](#styling-a-host-app).
441
+ 3. Replace each `var(--accent)` that means the brand color with
442
+ `var(--brand)` (and `--accent-hover`, `--accent-fg` with `--brand-hover`,
443
+ `--brand-fg`), and each `var(--accent-color)` with `var(--accent)`. A host
444
+ theme sets `--brand*` to change the brand color.
445
+ 4. Replace the parts of `@collective-intelligence/ui-react/chat` (second
446
+ table). For the whole chat, render `<Chat>` of
447
+ `@collective-intelligence/ai/views`.
448
+ 5. Update each Radix prop, callback, data attribute and CSS variable with the
449
+ first table, then check your forms, menus, selects and dialogs in the
450
+ browser: some behavior changes have no compile error.
451
+
452
+ | 0.5 and earlier | Chat release minor |
453
+ | ---------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- |
454
+ | `<Button asChild><a href="/x">Open</a></Button>` | `<Button nativeButton={false} render={<a href="/x" />}>Open</Button>` |
455
+ | `asChild` on any other part | `render={<Element />}` |
456
+ | menu item `onSelect` | `onClick`; `closeOnClick={false}` keeps the menu open |
457
+ | checkbox or radio menu item closes the menu | stays open; `closeOnClick` closes it |
458
+ | `DropdownMenuLabel` anywhere in the menu | inside a `DropdownMenuGroup` |
459
+ | `<Menubar value onValueChange>` | `open` and `onOpenChange` on each `MenubarMenu` |
460
+ | `<Select onValueChange={setValue}>` | `<Select items={items} onValueChange={(value) => value !== null && setValue(value)}>` |
461
+ | `SelectItem textValue` | `label` |
462
+ | `SelectContent position="popper"` | the default (`alignItemWithTrigger={false}`) |
463
+ | `<ToggleGroup type="single" value="a">` | `<ToggleGroup value={["a"]}>` |
464
+ | `<ToggleGroup type="multiple">` | `<ToggleGroup multiple>`; `spacing={0}` joins the items |
465
+ | `<Accordion type="single" collapsible defaultValue="a">` | `<Accordion defaultValue={["a"]}>` |
466
+ | `<Accordion type="multiple">` | `<Accordion multiple>` |
467
+ | `TooltipProvider delayDuration`, `skipDelayDuration` | `delay`, `timeout`; one tooltip's delay on `TooltipTrigger` |
468
+ | `onEscapeKeyDown`, `onPointerDownOutside`, `onInteractOutside` | `onOpenChange(open, eventDetails)`: read `eventDetails.reason`, call `eventDetails.cancel()` |
469
+ | `onOpenAutoFocus`, `onCloseAutoFocus` | `initialFocus`, `finalFocus` on the content |
470
+ | `AlertDialogAction` closes the dialog | close it through the controlled `open` state |
471
+ | `PopoverContent avoidCollisions` | `collisionAvoidance` |
472
+ | `TabsContent forceMount` | `keepMounted` |
473
+ | a tab activates on arrow-key focus | on click or Enter |
474
+ | `Checkbox checked="indeterminate"` | `indeterminate` |
475
+ | `Slider value={[50]}` | `value={50}` |
476
+ | `Drawer direction="bottom"` | `swipeDirection="down"`; `showSwipeHandle` shows the handle |
477
+ | `InputGroupAddon align="block_end"` | `align="block-end"` |
478
+ | `InputGroupButton size="icon_sm"` | `size="icon-sm"` |
479
+ | `data-[state=open]:`, `data-[state=closed]:` | `data-open:`, `data-closed:` |
480
+ | `data-[state=checked]:`, `data-[state=active]:`, `data-[state=on]:` | `data-checked:`, `data-active:`, `aria-pressed:` |
481
+ | `data-[vaul-drawer-direction=bottom]:` | `data-[swipe-direction=down]:` |
482
+ | `w-(--radix-popover-trigger-width)`, `--radix-select-trigger-width` | `w-(--anchor-width)` |
483
+ | `var(--accent)` for the brand color | `var(--brand)` |
484
+ | `var(--accent-color)`, `var(--accent-color-foreground)` | `var(--accent)`, `var(--accent-foreground)` |
485
+ | `import "@collective-intelligence/ui-react/styles.css"` and `.ci-root` | Tailwind v4 with `shadcn.css` |
486
+
487
+ | `@collective-intelligence/ui-react/chat` | Replacement |
488
+ | ---------------------------------------- | ------------------------------------------------------------------------ |
489
+ | `ChatMessage` | `Message` and `MessageContent` of `./ai-elements` |
490
+ | `ChatMarkdown` | `MessageResponse` of `./ai-elements` |
491
+ | `ChatComposerShell` | `PromptInput` and its parts of `./ai-elements` |
492
+ | `ChatAttachmentChip` | `Attachments` and `Attachment` of `./ai-elements` |
493
+ | `ChatApprovalCard` | `Confirmation` of `./ai-elements`, on the tool part's approval |
494
+ | `ChatQuestionCard` | `Questionnaire` of `./ai-elements` |
495
+ | `ChatContextUsageRing` | `Context` of `./ai-elements` |
496
+ | `ChatProcessingSteps` | the `Trace` parts of `./ui`, or `ChainOfThought` of `./ai-elements` |
497
+ | `ChatCompactionMarker` | `Marker` of `./ui` |
498
+ | `ChatToolEvidence` | `EvidencePart` of `@collective-intelligence/ai/views` |
499
+ | `ChatMemoryEvidence` | `MemoryEvidencePart` of `@collective-intelligence/ai/views` |
500
+ | `ChatAnswerFeedback` | `ChatAnswerFeedback` of `@collective-intelligence/ai/views` |
501
+ | `ChatRunStatus` | `RunTrace` of `@collective-intelligence/ai/views` |
502
+ | `ChatPermissionPrompt` | none: a tool approval is a `Confirmation` in the tool part of the answer |
503
+
504
+ The replacements take other props than the old parts: they render AI SDK
505
+ message parts, or the CI Data Parts of `@collective-intelligence/ai/domain`.