@timbal-ai/timbal-react 0.5.5 → 0.6.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 (44) hide show
  1. package/README.md +128 -4
  2. package/dist/app.cjs +5311 -0
  3. package/dist/app.d.cts +29 -0
  4. package/dist/app.d.ts +29 -0
  5. package/dist/app.esm.js +81 -0
  6. package/dist/chart-artifact-C71dk4xI.d.ts +329 -0
  7. package/dist/chart-artifact-CPEpOmtV.d.cts +329 -0
  8. package/dist/chat-CWtQWDtJ.d.cts +650 -0
  9. package/dist/chat-CWtQWDtJ.d.ts +650 -0
  10. package/dist/chat.cjs +4162 -0
  11. package/dist/chat.d.cts +13 -0
  12. package/dist/chat.d.ts +13 -0
  13. package/dist/chat.esm.js +51 -0
  14. package/dist/chunk-4TCJQSIX.esm.js +565 -0
  15. package/dist/chunk-IYENDIRY.esm.js +119 -0
  16. package/dist/chunk-KC5QLVUG.esm.js +22 -0
  17. package/dist/chunk-M4V6Q6XO.esm.js +1082 -0
  18. package/dist/chunk-OFHLFNJH.esm.js +138 -0
  19. package/dist/chunk-OVHR7J3J.esm.js +1574 -0
  20. package/dist/chunk-WLTW56MC.esm.js +66 -0
  21. package/dist/chunk-YJQLLFKP.esm.js +3672 -0
  22. package/dist/index.cjs +1822 -358
  23. package/dist/index.d.cts +15 -931
  24. package/dist/index.d.ts +15 -931
  25. package/dist/index.esm.js +187 -5578
  26. package/dist/layout-B9VayJhZ.d.cts +75 -0
  27. package/dist/layout-CQWngNQ7.d.ts +75 -0
  28. package/dist/studio.cjs +5734 -0
  29. package/dist/studio.d.cts +15 -0
  30. package/dist/studio.d.ts +15 -0
  31. package/dist/studio.esm.js +27 -0
  32. package/dist/styles.css +46 -2
  33. package/dist/timbal-v2-button-F4-z7m33.d.cts +40 -0
  34. package/dist/timbal-v2-button-F4-z7m33.d.ts +40 -0
  35. package/dist/ui.cjs +720 -0
  36. package/dist/ui.d.cts +74 -0
  37. package/dist/ui.d.ts +74 -0
  38. package/dist/ui.esm.js +44 -0
  39. package/dist/welcome--80i_O0p.d.cts +190 -0
  40. package/dist/welcome-BOizSp5h.d.ts +190 -0
  41. package/package.json +35 -3
  42. package/scripts/dev-linked.mjs +66 -0
  43. package/vite/local-dev.d.ts +4 -0
  44. package/vite/local-dev.mjs +115 -0
package/README.md CHANGED
@@ -1,6 +1,28 @@
1
1
  # @timbal-ai/timbal-react
2
2
 
3
- React components and runtime for building Timbal chat UIs. Drop in a single component to get a fully-featured streaming chat interface connected to a Timbal workforce agent.
3
+ React components and runtime for building Timbal chat UIs and studio apps. Drop in a single component to get a fully-featured streaming chat interface connected to a Timbal workforce agent, or compose dashboards with the **app kit**.
4
+
5
+ ## Package structure (0.6+)
6
+
7
+ | Subpath | Use when |
8
+ |---------|----------|
9
+ | `@timbal-ai/timbal-react` | Full surface (chat shells, auth, artifacts, app kit) |
10
+ | `@timbal-ai/timbal-react/chat` | Chat-only apps — `Thread`, `Composer`, runtime, layout helpers |
11
+ | `@timbal-ai/timbal-react/studio` | Studio chrome — `TimbalChatShell`, `TimbalStudioShell`, sidebar |
12
+ | `@timbal-ai/timbal-react/ui` | Primitives — `Button`, `Dialog`, `Avatar`, `Shimmer` |
13
+ | `@timbal-ai/timbal-react/app` | Dashboards — `AppShell`, `Page`, `DataTable`, `StatTile`, … |
14
+ | `@timbal-ai/timbal-react/styles.css` | Theme tokens (required once) |
15
+
16
+ ### API tiers
17
+
18
+ 1. **Stable** — `TimbalChat`, shells, `Thread`, `Composer`, auth, `styles.css`, documented app kit components.
19
+ 2. **Composable** — `@assistant-ui/react` primitives re-exported from the main entry; message column classes from `./chat` (`threadMessageColumnClass`, `assistantMessageRootClass`, …).
20
+ 3. **Internal** — `src/design/*` class composites (not exported); extend via CSS variables or public layout helpers.
21
+
22
+ ```tsx
23
+ import { threadMessageColumnClass } from "@timbal-ai/timbal-react/chat";
24
+ import { AppShell, Page, StatTile } from "@timbal-ai/timbal-react/app";
25
+ ```
4
26
 
5
27
  ## Installation
6
28
 
@@ -187,7 +209,24 @@ function MyShell() {
187
209
  }
188
210
  ```
189
211
 
190
- The `--studio-inset-left` CSS variable is automatically set on the document by `StudioSidebar`, so a normal Tailwind `pl-[var(--studio-inset-left)]` call resolves to the correct offset.
212
+ `--studio-inset-left` is a **static** CSS variable (the expanded sidebar width) good for layouts where the sidebar never collapses. It does **not** track the collapse animation on its own.
213
+
214
+ To inset a main column that follows the sidebar as it collapses, use `AppShell`, which wires the tracking automatically:
215
+
216
+ ```tsx
217
+ import { AppShell, StudioSidebar } from "@timbal-ai/timbal-react";
218
+
219
+ function MyShell() {
220
+ const [agent, setAgent] = useState("agent-a");
221
+ return (
222
+ <AppShell sidebar={<StudioSidebar selectedId={agent} onSelect={setAgent} />}>
223
+ {/* main content insets + animates with the sidebar */}
224
+ </AppShell>
225
+ );
226
+ }
227
+ ```
228
+
229
+ For a fully custom shell, drive your own offset from `StudioSidebar`'s `onInsetChange` callback, which fires with the live inset width (px) whenever the collapse state changes.
191
230
 
192
231
  ### Drop-in shell (header + agent picker)
193
232
 
@@ -826,6 +865,64 @@ For a fully custom header, combine `useWorkforces` with `TimbalChat` instead of
826
865
 
827
866
  ---
828
867
 
868
+ ## Dashboard + side copilot (`./app`)
869
+
870
+ Compose a data UI with a **floating** copilot — main content stays full width:
871
+
872
+ ```tsx
873
+ import {
874
+ AppShell,
875
+ AppShellTopbar,
876
+ AppCopilotProvider,
877
+ AppChatPanel,
878
+ Page,
879
+ Section,
880
+ } from "@timbal-ai/timbal-react/app";
881
+
882
+ export function OperationsApp() {
883
+ return (
884
+ <AppCopilotProvider value={{ page: "Operations", tab: "overview" }}>
885
+ <AppShell
886
+ sidebar={<StudioSidebar /* … */ />}
887
+ topbar={<AppShellTopbar actions={<ModeToggle />} />}
888
+ chat={
889
+ <AppChatPanel workforceId="your-workforce-id" />
890
+ }
891
+ chatTriggerLabel="Assistant"
892
+ chatCollapsible
893
+ >
894
+ <Page title="Operations">{/* dashboard */}</Page>
895
+ </AppShell>
896
+ </AppCopilotProvider>
897
+ );
898
+ }
899
+ ```
900
+
901
+ The shell renders a rounded floating panel (bottom-right) and a **text-only** pill trigger — no sidebar column, no chat icons. Use `useAppShellChat()` for a custom trigger; set `hideChatTrigger` if you provide your own.
902
+
903
+ | Piece | Role |
904
+ |-------|------|
905
+ | `AppCopilotProvider` | Page context via `useAppCopilotContext` (not shown in UI) |
906
+ | `AppChatPanel` | Full-height floating thread; dismiss via **X** in the corner |
907
+ | `AppShell` `chat` | Floating overlay — `chatWidth`; optional `chatHeight` (default: stretch top–bottom) |
908
+ | `ChartPanel` `artifact` | Built-in SVG charts without extra imports |
909
+ | `FieldTextarea` / `FieldSelect` / `FieldSwitch` | Settings forms matching `FieldInput` |
910
+ | `AppConfirmDialog` | Delete/export confirmations |
911
+
912
+ Full gallery: [`examples/app-kit`](examples/app-kit) (`bun run example:app`).
913
+
914
+ ---
915
+
916
+ ## Migrating from 0.5 to 0.6
917
+
918
+ - Source layout is now grouped by domain: `src/chat/`, `src/studio/`, `src/app/`, `src/ui/`.
919
+ - Optional subpath imports: `@timbal-ai/timbal-react/chat`, `/studio`, `/ui`, `/app`.
920
+ - Message column helpers moved to the library: import `threadMessageColumnClass` from `./chat` instead of copying class strings.
921
+ - New **app kit** (`./app`): `AppShell`, `Page`, `StatTile`, `DataTable`, etc. See [`examples/app-kit`](examples/app-kit).
922
+ - Newly exported types: `ThreadVariant` (main entry) and the content-part types `ContentPart`, `TextContentPart`, `ToolCallContentPart`, `ThinkingContentPart` (from `./chat`).
923
+
924
+ The main entry still exports the high-level surface (`TimbalChat`, `Thread`, the runtime hooks, …), so existing `import { TimbalChat } from "@timbal-ai/timbal-react"` apps keep working. Some lower-level helpers now live only on the subpath entries (`./chat`, `./ui`, `./studio`, `./app`).
925
+
829
926
  ## Migrating from 0.4 to 0.5
830
927
 
831
928
  `0.5.0` slims the public API to the surface that blueprint apps actually use. Every feature still works — only the export list changed.
@@ -858,6 +955,11 @@ Everything else (the three shells, primitives, hooks, auth, artifact API, design
858
955
 
859
956
  ---
860
957
 
958
+ ## Examples
959
+
960
+ - [`examples/mock-ui`](examples/mock-ui) — chat + artifact gallery (mock `fetch`).
961
+ - [`examples/app-kit`](examples/app-kit) — dashboard / app kit component gallery (no API).
962
+
861
963
  ## Mock UI demo
862
964
 
863
965
  An offline Vite app lives in [`examples/mock-ui`](examples/mock-ui). It uses a scripted mock `fetch` (no API keys) and includes a component gallery for artifacts. See that folder’s README for run instructions.
@@ -876,7 +978,7 @@ Install via a local path reference:
876
978
 
877
979
  Adjust the relative path to where `timbal-react` lives on your machine.
878
980
 
879
- After editing source files, rebuild:
981
+ After editing source files, rebuild `dist/` (Vite does **not** read `src/`):
880
982
 
881
983
  ```bash
882
984
  cd timbal-react
@@ -884,4 +986,26 @@ bun run build # one-off build
884
986
  bun run build:watch # rebuild on every change
885
987
  ```
886
988
 
887
- Vite picks up the new `dist/` automatically via HMR — no reinstall needed.
989
+ ### Vite apps linked with `file:../timbal-react`
990
+
991
+ Without extra config, Vite pre-bundles a **cached** copy under `node_modules/.vite/deps` and your UI will look stuck on an old build.
992
+
993
+ 1. Add the local-dev plugin in `vite.config.ts`:
994
+
995
+ ```ts
996
+ import { timbalReactLocalDev } from "@timbal-ai/timbal-react/vite";
997
+
998
+ export default defineConfig({
999
+ plugins: [timbalReactLocalDev(), /* react(), … */],
1000
+ });
1001
+ ```
1002
+
1003
+ 2. Run dev with a watch build (from your app):
1004
+
1005
+ ```bash
1006
+ node ../timbal-react/scripts/dev-linked.mjs vite
1007
+ ```
1008
+
1009
+ Or use the `dev` script in `blueprint-ui-dashboard` / examples (already wired).
1010
+
1011
+ One-time if you still see stale UI: `rm -rf node_modules/.vite` then restart dev.