@collective-intelligence/ui-react 0.7.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.
- package/README.md +201 -170
- package/dist/components/ai-elements/index.d.ts +445 -4
- package/dist/components/ai-elements/index.js +3 -1
- package/dist/components/icons/index.js +1 -1
- package/dist/components/illustrations/index.js +1 -1
- package/dist/components/ui/index.d.ts +293 -235
- package/dist/components/ui/index.js +2 -4
- package/dist/components/ui-extensions/atoms/ThemeToggle/index.js +1 -1
- package/dist/components/ui-extensions/hooks/use-mobile.js +1 -1
- package/dist/components/ui-extensions/index.d.ts +36 -21
- package/dist/components/ui-extensions/index.js +6 -6
- package/dist/components/ui-extensions/molecules/LabeledField/index.js +1 -1
- package/dist/components/ui-extensions/molecules/VideoPlayer/index.js +2 -2
- package/dist/hooks/index.js +1 -1
- package/dist/hooks/operations.js +1 -1
- package/dist/hooks/use-debounced-callback.js +1 -1
- package/dist/hooks/use-mount-action.js +1 -1
- package/dist/index-0dt7qv78.js +2 -0
- package/dist/index-33ef93f6.js +2 -0
- package/dist/index-410hza8j.js +2 -0
- package/dist/index-78w37zqq.js +2 -0
- package/dist/{index-yp7dwqdt.js → index-9tdk1jd5.js} +2 -2
- package/dist/index-ampejsqd.js +2 -0
- package/dist/index-aq49ztmj.js +2 -0
- package/dist/index-brb2fssx.js +4 -0
- package/dist/index-c4aack9s.js +2 -0
- package/dist/index-e0qytqhh.js +2 -0
- package/dist/index-eh2w7m4e.js +2 -0
- package/dist/index-ftn430ea.js +2 -0
- package/dist/{index-xmk5as68.js → index-fzn1f905.js} +2 -2
- package/dist/{index-q5rfnpnm.js → index-jmgcfmxe.js} +2 -2
- package/dist/index-jzyzapvz.js +2 -0
- package/dist/{index-1amahhaz.js → index-kzykjydw.js} +2 -2
- package/dist/{index-m7gvtt3h.js → index-p2yzw0qb.js} +2 -2
- package/dist/index-pe89kg1j.js +2 -0
- package/dist/index-pkw46hwt.js +2 -0
- package/dist/index-q560eskm.js +2 -0
- package/dist/{index-e503pv3f.js → index-r9trsk22.js} +2 -2
- package/dist/{index-5x3deeat.js → index-shpd3834.js} +2 -2
- package/dist/index-t2rwc8rk.js +2 -0
- package/dist/index-tb9dhges.js +2 -0
- package/dist/{index-r2keb0zb.js → index-w3zn83g3.js} +2 -2
- package/dist/index-w7hwsck8.js +2 -0
- package/dist/index-wnkq9nn0.js +2 -0
- package/dist/index-xy8a2fr7.js +2 -0
- package/dist/index-yaf9t9w5.js +42 -0
- package/dist/index-yh7sjgdy.js +2 -0
- package/dist/index.js +1 -1
- package/dist/resources.js +1 -1
- package/dist/shadcn.css +3 -4
- package/dist/tokens/theme.js +1 -1
- package/dist/utils/cn.js +1 -1
- package/package.json +6 -45
- package/dist/chat.d.ts +0 -579
- package/dist/chat.js +0 -2
- package/dist/index-05ch8g3p.js +0 -2
- package/dist/index-2136bczj.js +0 -2
- package/dist/index-4r9c455p.js +0 -2
- package/dist/index-4vk89see.js +0 -2
- package/dist/index-4xymfb7h.js +0 -2
- package/dist/index-50pv1cer.js +0 -2
- package/dist/index-6aftpcjv.js +0 -2
- package/dist/index-74qkvrg9.js +0 -2
- package/dist/index-79sav2qr.js +0 -2
- package/dist/index-ar540v2r.js +0 -2
- package/dist/index-bpnj24pg.js +0 -2
- package/dist/index-d6srr7et.js +0 -2
- package/dist/index-dea72se6.js +0 -2
- package/dist/index-drbb68sv.js +0 -2
- package/dist/index-eccj25rh.js +0 -2
- package/dist/index-em3kg0cy.js +0 -2
- package/dist/index-eyr85r2d.js +0 -2
- package/dist/index-f22spsh5.js +0 -2
- package/dist/index-h7m6anb3.js +0 -7
- package/dist/index-hmd0rx9g.js +0 -2
- package/dist/index-j136rmty.js +0 -1
- package/dist/index-k1f6eehk.js +0 -2
- package/dist/index-ncrdjrq1.js +0 -2
- package/dist/index-ndjegtyf.js +0 -2
- package/dist/index-ra03yvht.js +0 -2
- package/dist/index-rqqztw4a.js +0 -42
- package/dist/index-s3nshy6x.js +0 -2
- package/dist/index-xqct5yan.js +0 -2
- package/dist/index-yqjasa46.js +0 -2
- package/dist/index-z6vdzwb1.js +0 -2
- package/dist/index-z9tsk9ev.js +0 -2
- package/dist/index-zwm9cyre.js +0 -2
- 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.
|
|
11
|
-
|
|
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
|
|
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
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
`@
|
|
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
|
|
203
|
-
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
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
|
|
224
|
-
(`
|
|
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
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
-
|
|
259
|
-
`
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
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
|
|
292
|
-
`container` prop of an overlay's content
|
|
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
|
|
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.
|
|
@@ -464,11 +414,92 @@ chunk split and the notice in the packed artifact.
|
|
|
464
414
|
## Enum value migration
|
|
465
415
|
|
|
466
416
|
Repository-owned component options use `snake_case`. Update `Card.visual`
|
|
467
|
-
from `accent-gradient` to `accent_gradient`; `
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
`
|
|
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.
|
|
472
425
|
|
|
473
426
|
Native HTML input types retain their protocol spelling: for example,
|
|
474
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`.
|