rift-ds 1.37.1 → 1.39.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 (81) hide show
  1. package/README.md +3 -3
  2. package/behaviors/shortcuts.js +2 -2
  3. package/behaviors/useFoldedSections.d.ts +17 -0
  4. package/behaviors/useFoldedSections.js +23 -0
  5. package/behaviors/useLayer.d.ts +9 -0
  6. package/behaviors/useLayer.js +4 -3
  7. package/bin/templates/blocks/components/blocks/AppShell.module.css +6 -1
  8. package/bin/templates/blocks/components/blocks/AppShell.tsx +1 -0
  9. package/bin/templates/blocks/components/blocks/DocsShell.tsx +3 -3
  10. package/chat/ChatThreads.d.ts +63 -19
  11. package/chat/ChatThreads.js +119 -32
  12. package/chat/ChatWidget.css +15 -3
  13. package/chat/ChatWidget.d.ts +16 -17
  14. package/chat/ChatWidget.js +40 -7
  15. package/chat/DemoWelcome.d.ts +7 -0
  16. package/chat/DemoWelcome.js +19 -0
  17. package/chat/demo-fixtures.d.ts +1 -1
  18. package/chat/demo-fixtures.js +1 -0
  19. package/chat/rail-seat.d.ts +25 -0
  20. package/chat/rail-seat.js +8 -0
  21. package/chat/registry.json.d.ts +4 -1
  22. package/chat/registry.json.js +1 -1
  23. package/components/AppLayout/AppLayout.d.ts +22 -5
  24. package/components/AppLayout/AppLayout.js +3 -1
  25. package/components/AppSidebar/AppSidebar.css +554 -22
  26. package/components/AppSidebar/AppSidebar.d.ts +145 -14
  27. package/components/AppSidebar/AppSidebar.js +432 -188
  28. package/components/BottomNav/BottomNav.d.ts +2 -1
  29. package/components/Composer/Composer.css +20 -0
  30. package/components/Composer/Composer.d.ts +8 -0
  31. package/components/Composer/Composer.js +2 -0
  32. package/components/DrillMenu/DrillMenu.css +309 -0
  33. package/components/DrillMenu/DrillMenu.d.ts +130 -0
  34. package/components/DrillMenu/DrillMenu.js +177 -0
  35. package/components/DrillMenu/path.d.ts +22 -0
  36. package/components/DrillMenu/path.js +27 -0
  37. package/components/IconButton/IconButton.css +35 -0
  38. package/components/IconButton/IconButton.d.ts +8 -0
  39. package/components/IconButton/IconButton.js +2 -0
  40. package/components/NavList/NavList.d.ts +30 -111
  41. package/components/NavList/NavList.js +4 -228
  42. package/components/PromptSuggestions/PromptSuggestions.css +180 -11
  43. package/components/PromptSuggestions/PromptSuggestions.d.ts +24 -3
  44. package/components/PromptSuggestions/PromptSuggestions.js +35 -9
  45. package/components/ShaderScene/scenes.js +6 -5
  46. package/components/{NavList/NavList.css → SideNav/SideNav.css} +95 -85
  47. package/components/SideNav/SideNav.d.ts +118 -0
  48. package/components/SideNav/SideNav.js +233 -0
  49. package/components/SidebarPanel/SidebarPanel.d.ts +21 -54
  50. package/components/SidebarPanel/SidebarPanel.js +4 -168
  51. package/components/SiteHeader/SiteHeader.css +51 -30
  52. package/components/SiteHeader/SiteHeader.d.ts +45 -7
  53. package/components/SiteHeader/SiteHeader.js +51 -21
  54. package/components/SiteLayout/SiteLayout.css +7 -7
  55. package/components/SiteLayout/SiteLayout.d.ts +1 -1
  56. package/components/{SidebarPanel/SidebarPanel.css → SubNavPanel/SubNavPanel.css} +99 -38
  57. package/components/SubNavPanel/SubNavPanel.d.ts +63 -0
  58. package/components/SubNavPanel/SubNavPanel.js +199 -0
  59. package/components/ThreadHistory/ThreadHistory.css +519 -0
  60. package/components/ThreadHistory/ThreadHistory.d.ts +90 -0
  61. package/components/ThreadHistory/ThreadHistory.js +344 -0
  62. package/components/ThreadPanel/ThreadPanel.css +90 -306
  63. package/components/ThreadPanel/ThreadPanel.d.ts +16 -0
  64. package/components/ThreadPanel/ThreadPanel.js +67 -241
  65. package/components/registry.d.ts +2 -2
  66. package/components/registry.json +58 -30
  67. package/components/registry.json.d.ts +58 -30
  68. package/components/registry.json.js +1 -1
  69. package/index.d.ts +4 -1
  70. package/index.js +10 -2
  71. package/package.json +1 -1
  72. package/tokens/presets/contrast.css +2 -0
  73. package/tokens/presets/coral.css +2 -0
  74. package/tokens/presets/forest.css +8 -0
  75. package/tokens/presets/pink.css +2 -0
  76. package/tokens/presets/violet.css +2 -0
  77. package/tokens/presets/zest.css +4 -0
  78. package/tokens/values.json.js +1 -1
  79. package/components/Nav/Nav.css +0 -57
  80. package/components/Nav/Nav.d.ts +0 -32
  81. package/components/Nav/Nav.js +0 -23
package/README.md CHANGED
@@ -13,7 +13,7 @@ An open source React design system built for AI products and coding agents: comp
13
13
 
14
14
  ## Why Rift DS
15
15
 
16
- - **<!-- component-count -->195<!-- /component-count --> components.** Buttons, forms and tables through to charts, navigation and overlays, each typed and documented with live examples. Every one forwards a ref and your own attributes to its element, state you can own works controlled or uncontrolled (a modal opens when your app says so, by design), and every word a component writes has a prop you can localise. The build checks the first two on every component, and the words wherever they sit in markup. React and React DOM are the only required peer dependencies.
16
+ - **<!-- component-count -->196<!-- /component-count --> components.** Buttons, forms and tables through to charts, navigation and overlays, each typed and documented with live examples. Every one forwards a ref and your own attributes to its element, state you can own works controlled or uncontrolled (a modal opens when your app says so, by design), and every word a component writes has a prop you can localise. The build checks the first two on every component, and the words wherever they sit in markup. React and React DOM are the only required peer dependencies.
17
17
  - **A matching <!-- figma-kit-link -->[Figma kit](https://www.figma.com/community/file/1701820123445795117)<!-- /figma-kit-link -->.** Every component has a page in it, with a sticker sheet of its states, built on variables named after the same tokens. Duplicate it from the Figma Community to design with the same system.
18
18
  - **AI patterns, the whole chat and templates, ready to use.** Composer, streaming chat thread, tool calls, reasoning and thread panel are in the box, the complete AI chat ships assembled as one widget that one command scaffolds, and the docs site has complete template screens built from them.
19
19
  - **Fully themeable.** The shipped themes are complete looks to start from, each in light and dark. One `data-brand` attribute applies a theme, and a few CSS overrides make your own.
@@ -113,13 +113,13 @@ import 'rift-ds/tokens/presets/presets.css';
113
113
 
114
114
  ## Components
115
115
 
116
- <!-- component-count -->195<!-- /component-count --> components, including a chat set for AI products (Chat thread, Composer, Tool call, Reasoning, Thread panel) and Shader field, a WebGL2 ambient background whose light sources read your colour tokens at runtime, so it re-themes with everything else. Details and live examples are on the [docs site](https://rift-ds.com/components).
116
+ <!-- component-count -->196<!-- /component-count --> components, including a chat set for AI products (Chat thread, Composer, Tool call, Reasoning, Thread panel) and Shader field, a WebGL2 ambient background whose light sources read your colour tokens at runtime, so it re-themes with everything else. Details and live examples are on the [docs site](https://rift-ds.com/components).
117
117
 
118
118
  <details>
119
119
  <summary>The full list</summary>
120
120
 
121
121
  <!-- component-list:start -->
122
- Accordion · Action bar · Action card · Action readout · Agent plan · Agent rail · Agent status · AI button · Alert · Alert dialog · Anchor nav · Animated number · App layout · App sidebar · Area chart · Artifact card · Artifact panel · Attachment drop zone · Attachment group · Attachment tile · Attachment viewer · Avatar · Avatar group · Back to top · Badge · Banner · Bar chart · Bento tile · Bento tile art · Bottom nav · Breadcrumb · Button · Button group · Card · Card stack · Carousel · Chat header · Chat marker · Chat message · Chat thread · Checkbox · Checklist · Chip · Code block · Code diff · Colour picker · Combo chart · Combobox · Command palette · Command palette trigger · Composer · Contact card · Context menu · Contribution graph · Copy button · Currency input · Data table · Date input · Date picker · Date range picker · Deadline · Decision row · Description list · Dialog · Divider · Document chip · Document viewer · Drawer · Dropdown · Dropdown menu · Empty state · Entity card · Entity switcher · Error summary · Event calendar · Field · Figure · File input · File row · Filter bar · Form section · Funnel chart · Gantt chart · Gauge · Globe · Grid · Heading · Hover card · Icon · Icon button · Image compare · Input · Inspector colour picker · Inspector dropdown · Inspector input · Inspector section · Inspector segments · Inspector slider · Inspector toggle switch · Instructions · Interrupt card · Kbd · Legend tile · Lightbox · Line chart · Link · Link list · List · Map callout · Map legend · Masked input · Mega menu · Mention · Menu bar · Message actions · Message card · Meter · Model picker · Nav · Nav list · Notification centre · Number input · Org chart · Page header · Pagination · Panel · Pie chart · Pin input · Pixel avatar · Popover · Progress bar · Progressive blur · Prompt suggestions · Prose · Question card · Quote · Radar chart · Radial chart · Radio button · Rating · Reasoning · Resource timeline · Rich dropdown · Scatter chart · Section title · Segmented control · Selection card · Shader field · Shader scene · Sidebar panel · Signature pad · Site footer · Site header · Site layout · Skeleton · Slider · Source chip · Source trail · Sparkline · Spinner · Split button · Split pane · Stack · Stacked bar chart · Stat · Status dot · Stepper · Streaming text · Swatch · Table · Table toolbar · Tabs · Tag input · Text · Textarea · Theme picker · Theme toggle · Thread panel · Thread tabs · Time picker · Timeline · Toast · Toggle group · Toggle switch · Tool call · Toolbar · Tooltip · Top app bar · Tree view · Treemap · Usage card · Waveform · Widget · Wizard · World map
122
+ Accordion · Action bar · Action card · Action readout · Agent plan · Agent rail · Agent status · AI button · Alert · Alert dialog · Anchor nav · Animated number · App layout · App sidebar · Area chart · Artifact card · Artifact panel · Attachment drop zone · Attachment group · Attachment tile · Attachment viewer · Avatar · Avatar group · Back to top · Badge · Banner · Bar chart · Bento tile · Bento tile art · Bottom nav · Breadcrumb · Button · Button group · Card · Card stack · Carousel · Chat header · Chat marker · Chat message · Chat thread · Checkbox · Checklist · Chip · Code block · Code diff · Colour picker · Combo chart · Combobox · Command palette · Command palette trigger · Composer · Contact card · Context menu · Contribution graph · Copy button · Currency input · Data table · Date input · Date picker · Date range picker · Deadline · Decision row · Description list · Dialog · Divider · Document chip · Document viewer · Drawer · Drill menu · Dropdown · Dropdown menu · Empty state · Entity card · Entity switcher · Error summary · Event calendar · Field · Figure · File input · File row · Filter bar · Form section · Funnel chart · Gantt chart · Gauge · Globe · Grid · Heading · Hover card · Icon · Icon button · Image compare · Input · Inspector colour picker · Inspector dropdown · Inspector input · Inspector section · Inspector segments · Inspector slider · Inspector toggle switch · Instructions · Interrupt card · Kbd · Legend tile · Lightbox · Line chart · Link · Link list · List · Map callout · Map legend · Masked input · Mega menu · Mention · Menu bar · Message actions · Message card · Meter · Model picker · Notification centre · Number input · Org chart · Page header · Pagination · Panel · Pie chart · Pin input · Pixel avatar · Popover · Progress bar · Progressive blur · Prompt suggestions · Prose · Question card · Quote · Radar chart · Radial chart · Radio button · Rating · Reasoning · Resource timeline · Rich dropdown · Scatter chart · Section title · Segmented control · Selection card · Shader field · Shader scene · Side nav · Signature pad · Site footer · Site header · Site layout · Skeleton · Slider · Source chip · Source trail · Sparkline · Spinner · Split button · Split pane · Stack · Stacked bar chart · Stat · Status dot · Stepper · Streaming text · Sub-nav panel · Swatch · Table · Table toolbar · Tabs · Tag input · Text · Textarea · Theme picker · Theme toggle · Thread history · Thread panel · Thread tabs · Time picker · Timeline · Toast · Toggle group · Toggle switch · Tool call · Toolbar · Tooltip · Top app bar · Tree view · Treemap · Usage card · Waveform · Widget · Wizard · World map
123
123
  <!-- component-list:end -->
124
124
 
125
125
  </details>
@@ -1,10 +1,10 @@
1
1
  "use client";
2
- import { useRef, useEffect, useSyncExternalStore } from "react";
2
+ import { useSyncExternalStore, useRef, useEffect } from "react";
3
3
  import { MOTION_SHORTCUT_SEQUENCE_MS } from "../tokens/motion.js";
4
4
  import { warnOnce } from "./devWarning.js";
5
5
  import { activeModalPanel } from "./useFocusScope.js";
6
6
  import { hasOpenLayer, openLayerContains } from "./useLayer.js";
7
- import { parseShortcut, detectPlatform, KEY_ALIASES } from "./shortcut-keys.js";
7
+ import { detectPlatform, parseShortcut, KEY_ALIASES } from "./shortcut-keys.js";
8
8
  import { formatShortcut, shortcutAria, shortcutKeys } from "./shortcut-keys.js";
9
9
  const noSubscription = () => () => {
10
10
  };
@@ -0,0 +1,17 @@
1
+ /**
2
+ * The fold state of a nav's titled sections, for a nav whose sections can
3
+ * fold under their headings (AppSidebar's
4
+ * `collapsibleSections`). Sections open by default, so the state is the
5
+ * list of folded ids: controlled through `collapsed`, or kept here from
6
+ * `defaultCollapsed`, with `onChange` told the whole new list either way.
7
+ * SideNav folds its sections its own way (per section, closed by default),
8
+ * so it keeps its own expanded list.
9
+ */
10
+ export declare function useFoldedSections({ collapsed, defaultCollapsed, onChange, }: {
11
+ collapsed?: string[];
12
+ defaultCollapsed?: string[];
13
+ onChange?: (collapsed: string[]) => void;
14
+ }): {
15
+ isFolded: (id: string) => boolean;
16
+ toggle: (id: string) => void;
17
+ };
@@ -0,0 +1,23 @@
1
+ "use client";
2
+ import { useState, useCallback } from "react";
3
+ function useFoldedSections({
4
+ collapsed,
5
+ defaultCollapsed,
6
+ onChange
7
+ }) {
8
+ const [own, setOwn] = useState(() => defaultCollapsed ?? []);
9
+ const current = collapsed ?? own;
10
+ const toggle = useCallback(
11
+ (id) => {
12
+ const next = current.includes(id) ? current.filter((entry) => entry !== id) : [...current, id];
13
+ if (collapsed === void 0) setOwn(next);
14
+ onChange?.(next);
15
+ },
16
+ [current, collapsed, onChange]
17
+ );
18
+ const isFolded = (id) => current.includes(id);
19
+ return { isFolded, toggle };
20
+ }
21
+ export {
22
+ useFoldedSections
23
+ };
@@ -80,6 +80,15 @@ export type LayerHandle = {
80
80
  export declare const openLayerContains: (node: Node) => boolean;
81
81
  /** Whether any layer is open. Escape belongs to the stack while one is, so keyboard shortcuts leave it alone. */
82
82
  export declare const hasOpenLayer: () => boolean;
83
+ /**
84
+ * The stack's Escape: the topmost open layer is dismissed and the key marked
85
+ * handled. Installed on the document while a layer is open; a layer whose
86
+ * keydown would otherwise reach a host first (a drawer inside a chat panel
87
+ * that closes on Escape in its own React handler) calls it from its own
88
+ * keydown, so the stack still decides which layer the key belongs to, and
89
+ * the host sees the key already handled.
90
+ */
91
+ export declare const handleLayerEscape: (event: KeyboardEvent) => void;
83
92
  /**
84
93
  * Register an overlay on the dismissal stack while `open` is true. Options
85
94
  * are read at event time, so a `dismissOnEscape` toggle takes effect without
@@ -6,7 +6,7 @@ let pressOwner = null;
6
6
  const contains = (layer, target) => (layer.optionsRef.current.getElements?.() ?? []).some((el) => el?.contains(target));
7
7
  const openLayerContains = (node) => layers.some((layer) => contains(layer, node));
8
8
  const hasOpenLayer = () => layers.length > 0;
9
- const handleKeyDown = (event) => {
9
+ const handleLayerEscape = (event) => {
10
10
  if (event.key !== "Escape" || event.defaultPrevented) return;
11
11
  const top = layers[layers.length - 1];
12
12
  if (!top) return;
@@ -28,11 +28,11 @@ const handlePointerDown = (event) => {
28
28
  };
29
29
  const syncListeners = () => {
30
30
  if (layers.length > 0 && !listenersInstalled) {
31
- document.addEventListener("keydown", handleKeyDown);
31
+ document.addEventListener("keydown", handleLayerEscape);
32
32
  document.addEventListener("pointerdown", handlePointerDown, true);
33
33
  listenersInstalled = true;
34
34
  } else if (layers.length === 0 && listenersInstalled) {
35
- document.removeEventListener("keydown", handleKeyDown);
35
+ document.removeEventListener("keydown", handleLayerEscape);
36
36
  document.removeEventListener("pointerdown", handlePointerDown, true);
37
37
  listenersInstalled = false;
38
38
  pressOwner = null;
@@ -66,6 +66,7 @@ function useLayer(options) {
66
66
  return { ownsPress };
67
67
  }
68
68
  export {
69
+ handleLayerEscape,
69
70
  hasOpenLayer,
70
71
  openLayerContains,
71
72
  useLayer
@@ -1,7 +1,8 @@
1
1
  /* The app shell's layout, in one of the three app shell modes (flush,
2
2
  floating or inset; AppShell.tsx's SHELL_LAYOUT picks it). Every value is
3
3
  a rift-ds token or a property of its shell recipe, except the sidebar's
4
- own widths (64px collapsed, 280px expanded) and its mobile menu button
4
+ own widths (80px collapsed in panel mode, the default, or 64px in
5
+ accordion mode; 280px expanded) and its mobile menu button
5
6
  (40px), which are the AppSidebar component's geometry. */
6
7
 
7
8
  .shell {
@@ -24,6 +25,10 @@
24
25
  background-color: var(--ds-shell-plane);
25
26
  }
26
27
 
28
+ .shell:has(:global(.ds-app-sidebar--panel-mode:not(.ds-app-sidebar--expanded))) {
29
+ --shell-rail: 80px;
30
+ }
31
+
27
32
  .shell:has(:global(.ds-app-sidebar--expanded)) {
28
33
  --shell-rail: 280px;
29
34
  }
@@ -54,6 +54,7 @@ const PRODUCT_NAME = 'Acme';
54
54
  /** The sidebar's navigation. Give an item an `href` (`'/dashboard'`) to make it a link. */
55
55
  const NAV_SECTIONS: AppSidebarSection[] = [
56
56
  {
57
+ category: 'Main',
57
58
  items: [
58
59
  { key: 'home', label: 'Home', icon: 'home' },
59
60
  { key: 'dashboard', label: 'Dashboard', icon: 'space_dashboard' },
@@ -24,7 +24,7 @@ import { AnchorNav } from 'rift-ds/components/AnchorNav/AnchorNav';
24
24
  import { BackToTop } from 'rift-ds/components/BackToTop/BackToTop';
25
25
  import { Breadcrumb, type BreadcrumbItem } from 'rift-ds/components/Breadcrumb/Breadcrumb';
26
26
  import { CommandPaletteTrigger } from 'rift-ds/components/CommandPaletteTrigger/CommandPaletteTrigger';
27
- import { NavList, type NavListEntry } from 'rift-ds/components/NavList/NavList';
27
+ import { SideNav, type SideNavEntry } from 'rift-ds/components/SideNav/SideNav';
28
28
  import { SiteFooter, type SiteFooterColumn } from 'rift-ds/components/SiteFooter/SiteFooter';
29
29
  import { SiteHeader, type SiteHeaderSection } from 'rift-ds/components/SiteHeader/SiteHeader';
30
30
  import { SiteLayout } from 'rift-ds/components/SiteLayout/SiteLayout';
@@ -47,7 +47,7 @@ const COMPONENT_PAGES = [
47
47
  'Combobox', 'Dialog', 'Drawer', 'Dropdown menu', 'Field', 'Input', 'Menubar', 'Pagination', 'Popover', 'Select',
48
48
  'Slider', 'Switch', 'Table', 'Tabs', 'Toast', 'Tooltip',
49
49
  ];
50
- const NAV: NavListEntry[] = [
50
+ const NAV: SideNavEntry[] = [
51
51
  {
52
52
  type: 'section',
53
53
  label: 'Getting started',
@@ -154,7 +154,7 @@ export function DocsShell({ currentHref, breadcrumb, children }: DocsShellProps)
154
154
  />
155
155
  }
156
156
  sidebar={
157
- <NavList
157
+ <SideNav
158
158
  items={NAV}
159
159
  size="compact"
160
160
  scrollable
@@ -1,45 +1,89 @@
1
1
  import { ReactNode } from 'react';
2
+ import { AppSidebarProps, AppSidebarSection } from '../components/AppSidebar/AppSidebar';
3
+ import { DrillMenuEntry } from '../components/DrillMenu/DrillMenu';
2
4
  import { ThreadPanelProfile, ThreadPanelProps } from '../components/ThreadPanel/ThreadPanel';
3
5
  export interface ChatThreadsProps {
4
- /** The widget seated the rail as a sheet over the conversation rather than beside it. */
6
+ /** Set when a custom `threads` slot seats this rail in the widget's slide-over sheet, where it draws itself expanded; the built-in rail takes its form from the widget. */
5
7
  overlay: boolean;
6
- /** Closes the sheet; a no-op on the inline rail. */
8
+ /** Closes that sheet; a no-op elsewhere. */
7
9
  close: () => void;
8
- /** The brand row's mark, in both seats. */
10
+ /** The brand row's mark. Defaults to a generated pixel avatar seeded by `logoText`. */
9
11
  logo?: ReactNode;
10
- /** The brand row's text. Shown only on the sheet, where the chat header is hidden behind it; the inline rail leaves it out. */
12
+ /** The brand row's text, beside the mark while the rail is expanded. */
11
13
  logoText?: string;
12
- /** The signed-in person, shown on the inline rail. */
14
+ /** The signed-in person, shown at the rail's foot. */
13
15
  profile?: ThreadPanelProfile;
14
- /** Rendered in the rail's footer in both seats (above the profile row on the inline rail; the sheet has none): a theme toggle, a link out. Fades out while the inline rail is collapsed. */
16
+ /** Rendered in the rail's footer above the profile row: a theme toggle, a link out. Fades out while the rail is collapsed. */
15
17
  footerSlot?: ReactNode;
16
- /** Rendered in the inline rail's footer while it is collapsed, in `footerSlot`'s place: the same controls at their smallest, stacked on the rail's axis, crossfading with the full form. The sheet never collapses, so it never shows. */
18
+ /**
19
+ * Let the reader fold the projects, each labelled history group and the
20
+ * host's `sections` under their headings. Every section starts open.
21
+ * @default false
22
+ */
23
+ collapsibleSections?: boolean;
24
+ /** Controlled list of folded sections: `projects`, then each group or section by `id` (else its heading). */
25
+ collapsedSections?: string[];
26
+ /** Sections folded at first (uncontrolled), keyed as `collapsedSections` is. */
27
+ defaultCollapsedSections?: string[];
28
+ /** Fires with the new list of folded sections. */
29
+ onCollapsedSectionsChange?: (collapsedSections: string[]) => void;
30
+ /** Rendered below the profile row, such as a full-width Button back to an index. It fades out while the rail is collapsed. */
31
+ footerAction?: ReactNode;
32
+ /** Rendered in the rail's footer while it is collapsed, in `footerSlot`'s place: the same controls at their smallest, stacked on the rail's axis, crossfading with the full form. */
17
33
  collapsedFooterSlot?: ReactNode;
18
- /** Whether the inline rail can collapse to its icon strip. */
34
+ /**
35
+ * The host's own sections after the history, in AppSidebar's shape: a
36
+ * section of setting rows (Appearance) whose choices open in the side
37
+ * panel beside the rail and drill in on the drawer, as the app rail's do.
38
+ */
39
+ sections?: AppSidebarSection[];
40
+ /** Rows above the sections in the drawer, in DrillMenu's shape, such as a workspace switcher that drills into its choices. */
41
+ drawerTopEntries?: DrillMenuEntry[];
42
+ /** Rows after the sections in the drawer, in DrillMenu's shape. */
43
+ drawerBottomEntries?: DrillMenuEntry[];
44
+ /**
45
+ * Whether the rail can collapse to its icon strip.
46
+ * @default true
47
+ */
19
48
  collapsible?: boolean;
20
49
  /**
21
- * Whether the inline rail starts expanded. Defaults to `false`: it starts
22
- * collapsed to its icon strip. The sheet, and a rail that is not
50
+ * Whether the rail starts expanded. Defaults to `false`: it starts
51
+ * collapsed to its icon strip. The drawer, and a rail that is not
23
52
  * `collapsible`, always show expanded.
24
53
  */
25
54
  defaultExpanded?: boolean;
26
- /** Accessible heading over the history. */
55
+ /** Accessible name of the history inside the rail. */
27
56
  historyLabel?: string;
57
+ /** Accessible name of the rail's navigation landmark. */
58
+ railLabel?: string;
28
59
  /**
29
- * The words the ThreadPanel writes, merged over its English defaults: the
60
+ * The words the rail writes, merged over their English defaults: the
30
61
  * spoken pin and status text ("Pinned", "Working"…), each row's menu
31
62
  * trigger ("Thread options"), the rename field ("Rename thread"), the
32
- * projects header and its add button ("Projects", "New project"), and the
33
- * collapse toggle ("Collapse the panel", "Expand the panel"). The history's
34
- * own name is `historyLabel`.
63
+ * projects heading and its add button ("Projects", "New project"), and the
64
+ * collapse toggle ("Collapse the panel", "Expand the panel", which reach
65
+ * the rail; `railLabels` wins over them). The history's own name is
66
+ * `historyLabel`.
35
67
  */
36
68
  threadPanelLabels?: Pick<ThreadPanelProps, 'statusLabels' | 'pinnedLabel' | 'threadMenuLabel' | 'renameLabel' | 'projectsLabel' | 'newProjectLabel' | 'collapseLabel' | 'expandLabel'>;
69
+ /**
70
+ * The words the rail's shell writes, merged over AppSidebar's English
71
+ * defaults: the collapse toggle, the drawer's close button ("Close
72
+ * navigation"), its menu and back rows ("Menu", "Back to …", "… overview")
73
+ * and the profile's more button ("Profile options").
74
+ */
75
+ railLabels?: Pick<AppSidebarProps, 'collapseLabel' | 'expandLabel' | 'closeLabel' | 'menuLabel' | 'drawerBackLabel' | 'drawerOverviewLabel' | 'profileMoreLabel'>;
37
76
  /** The rows of each thread's menu, by action; a key left out keeps its English. Defaults to "Pin", "Unpin", "Rename" and "Delete". */
38
77
  actionLabels?: Partial<Record<'pin' | 'unpin' | 'rename' | 'delete', string>>;
39
78
  }
40
79
  /**
41
- * The built-in session-history rail: a ThreadPanel over the provider's
42
- * thread lifecycle (`useThreads`). The widget seats it inline on a wide
43
- * host and as a slide-over sheet on a narrow one, and tells it which.
80
+ * The built-in session-history rail: an AppSidebar over the provider's
81
+ * thread lifecycle (`useThreads`), so a chat's rail has the app rail's
82
+ * shell, sizes, side panel and drawer, and only its content is its own.
83
+ * New chat leads, the projects follow as a section with an add action, the
84
+ * history is a section's content (ThreadHistory, the rows ThreadPanel
85
+ * draws), and the host's `sections` come after. The widget seats it and
86
+ * says which form its room allows: the rail beside the conversation, or
87
+ * the drawer over the widget, opened from the header's menu button.
44
88
  */
45
- export declare function ChatThreads({ overlay, close, logo, logoText, profile, footerSlot, collapsedFooterSlot, collapsible, defaultExpanded, historyLabel, threadPanelLabels, actionLabels, }: ChatThreadsProps): import("react").JSX.Element;
89
+ export declare function ChatThreads({ overlay, close, logo, logoText, profile, footerSlot, footerAction, collapsibleSections, collapsedSections: controlledCollapsedSections, defaultCollapsedSections, onCollapsedSectionsChange, collapsedFooterSlot, sections: hostSections, drawerTopEntries, drawerBottomEntries, collapsible, defaultExpanded, historyLabel, railLabel, threadPanelLabels, railLabels, actionLabels, }: ChatThreadsProps): import("react").JSX.Element;
@@ -1,8 +1,11 @@
1
1
  "use client";
2
2
  import { jsx } from "react/jsx-runtime";
3
3
  import { useState, useMemo } from "react";
4
- import { ThreadPanel } from "../components/ThreadPanel/ThreadPanel.js";
4
+ import { AppSidebar } from "../components/AppSidebar/AppSidebar.js";
5
+ import { PixelAvatar } from "../components/PixelAvatar/PixelAvatar.js";
6
+ import { ThreadHistory } from "../components/ThreadHistory/ThreadHistory.js";
5
7
  import { useChatWidget } from "./context.js";
8
+ import { useRailSeat } from "./rail-seat.js";
6
9
  function ChatThreads({
7
10
  overlay,
8
11
  close,
@@ -10,16 +13,34 @@ function ChatThreads({
10
13
  logoText,
11
14
  profile,
12
15
  footerSlot,
16
+ footerAction,
17
+ collapsibleSections = false,
18
+ collapsedSections: controlledCollapsedSections,
19
+ defaultCollapsedSections,
20
+ onCollapsedSectionsChange,
13
21
  collapsedFooterSlot,
22
+ sections: hostSections,
23
+ drawerTopEntries,
24
+ drawerBottomEntries,
14
25
  collapsible = true,
15
26
  defaultExpanded = false,
16
27
  historyLabel = "Chat history",
28
+ railLabel = "Chats",
17
29
  threadPanelLabels,
30
+ railLabels,
18
31
  actionLabels
19
32
  }) {
20
33
  const { threads } = useChatWidget();
34
+ const seat = useRailSeat();
21
35
  const [expanded, setExpanded] = useState(defaultExpanded);
36
+ const [ownCollapsedSections, setOwnCollapsedSections] = useState(() => defaultCollapsedSections ?? []);
37
+ const collapsedSections = controlledCollapsedSections ?? ownCollapsedSections;
38
+ const setCollapsedSections = (next) => {
39
+ if (controlledCollapsedSections === void 0) setOwnCollapsedSections(next);
40
+ onCollapsedSectionsChange?.(next);
41
+ };
22
42
  const hasProjects = threads.projects.length > 0;
43
+ const projectsLabel = threadPanelLabels?.projectsLabel ?? "Projects";
23
44
  const groups = useMemo(() => {
24
45
  if (!actionLabels) return threads.groups;
25
46
  return threads.groups.map((group) => ({
@@ -36,40 +57,106 @@ function ChatThreads({
36
57
  )
37
58
  }));
38
59
  }, [threads.groups, actionLabels]);
60
+ const fixedOpen = !seat && overlay;
61
+ const sections = [
62
+ {
63
+ items: [
64
+ {
65
+ key: "new-chat",
66
+ icon: "edit_square",
67
+ label: threads.newThreadLabel,
68
+ onClick: () => {
69
+ threads.startNew();
70
+ close();
71
+ }
72
+ }
73
+ ]
74
+ },
75
+ ...hasProjects ? [
76
+ {
77
+ id: "projects",
78
+ category: projectsLabel,
79
+ action: {
80
+ label: threadPanelLabels?.newProjectLabel ?? "New project",
81
+ icon: "add",
82
+ onClick: threads.createProject
83
+ },
84
+ items: threads.projects.map((project) => ({
85
+ key: `project-${project.id}`,
86
+ label: project.label,
87
+ ...project.icon ? { icon: project.icon } : { pixelAvatar: project.pixelAvatar ?? project.id },
88
+ value: project.meta,
89
+ href: project.href,
90
+ onClick: () => {
91
+ threads.selectProject(project.id);
92
+ close();
93
+ }
94
+ }))
95
+ }
96
+ ] : [],
97
+ {
98
+ items: [],
99
+ content: ({ closeDrawer }) => /* @__PURE__ */ jsx(
100
+ ThreadHistory,
101
+ {
102
+ "aria-label": historyLabel,
103
+ statusLabels: threadPanelLabels?.statusLabels,
104
+ pinnedLabel: threadPanelLabels?.pinnedLabel,
105
+ threadMenuLabel: threadPanelLabels?.threadMenuLabel,
106
+ renameLabel: threadPanelLabels?.renameLabel,
107
+ groups,
108
+ activeThreadId: threads.activeThreadId,
109
+ onThreadSelect: (id) => {
110
+ threads.select(id);
111
+ closeDrawer();
112
+ close();
113
+ },
114
+ onThreadAction: threads.runAction,
115
+ renamingThreadId: threads.renamingId ?? void 0,
116
+ onThreadRename: threads.rename,
117
+ onRenameCancel: () => threads.setRenamingId(null),
118
+ collapsibleSections,
119
+ collapsedSections,
120
+ onCollapsedSectionsChange: setCollapsedSections
121
+ }
122
+ )
123
+ },
124
+ ...hostSections ?? []
125
+ ];
39
126
  return /* @__PURE__ */ jsx(
40
- ThreadPanel,
127
+ AppSidebar,
41
128
  {
42
- ...threadPanelLabels,
43
- groups,
44
- activeThreadId: threads.activeThreadId,
45
- onThreadSelect: (id) => {
46
- threads.select(id);
47
- close();
48
- },
49
- onThreadAction: threads.runAction,
50
- renamingThreadId: threads.renamingId ?? void 0,
51
- onThreadRename: threads.rename,
52
- onRenameCancel: () => threads.setRenamingId(null),
53
- newThreadLabel: threads.newThreadLabel,
54
- onNewThread: () => {
55
- threads.startNew();
56
- close();
57
- },
58
- historyLabel,
59
- projects: hasProjects ? threads.projects : void 0,
60
- activeProjectId: threads.activeProjectId,
61
- onProjectSelect: (id) => {
62
- threads.selectProject(id);
63
- close();
64
- },
65
- onProjectCreate: hasProjects ? threads.createProject : void 0,
66
- logo,
67
- logoText: overlay ? logoText : void 0,
68
- expanded: overlay || !collapsible ? true : expanded,
69
- onExpandedChange: overlay || !collapsible ? void 0 : setExpanded,
70
- profile: overlay ? void 0 : profile,
129
+ "aria-label": railLabel,
130
+ id: seat?.id,
131
+ className: "ds-chat-widget__history",
132
+ fixed: false,
133
+ responsive: seat?.form ?? "rail",
134
+ layout: seat?.layout,
135
+ showMobileTrigger: false,
136
+ drawerOpen: seat?.drawerOpen ?? false,
137
+ onDrawerOpenChange: seat?.setDrawerOpen,
138
+ subNav: "panel",
139
+ defaultPanelOpen: false,
140
+ foldForPanel: true,
141
+ collapsible: collapsible && !fixedOpen,
142
+ expanded,
143
+ onExpandedChange: setExpanded,
144
+ logo: logo ?? /* @__PURE__ */ jsx(PixelAvatar, { name: logoText ?? railLabel }),
145
+ logoText: logoText ?? "",
146
+ sections,
147
+ activeKey: threads.activeProjectId ? `project-${threads.activeProjectId}` : void 0,
148
+ collapsibleSections,
149
+ collapsedSections,
150
+ onCollapsedSectionsChange: setCollapsedSections,
151
+ collapseLabel: threadPanelLabels?.collapseLabel ?? "Collapse the panel",
152
+ expandLabel: threadPanelLabels?.expandLabel ?? "Expand the panel",
153
+ ...railLabels,
154
+ profile: profile ? { name: profile.name, email: profile.meta, avatar: profile.avatar } : void 0,
71
155
  footerSlot,
72
- collapsedFooterSlot: overlay ? void 0 : collapsedFooterSlot
156
+ collapsedFooterSlot,
157
+ footerAction,
158
+ drawerTopEntries,
159
+ drawerBottomEntries
73
160
  }
74
161
  );
75
162
  }
@@ -304,6 +304,17 @@
304
304
  );
305
305
  }
306
306
 
307
+ /* A set of prompt suggestions in the slot arrives with it, then lands
308
+ item by item: its stagger starts on the slot's own beat, after the
309
+ piece holding it has begun to fade in, instead of running out unseen
310
+ while the slot is still held back. */
311
+ .ds-chat-widget__widgets {
312
+ --ds-prompt-suggestions-entrance-delay: calc(
313
+ var(--ds-chat-widget-welcome-hold, var(--motion-duration-deliberate)) + var(--motion-duration-base) +
314
+ var(--motion-duration-fast)
315
+ );
316
+ }
317
+
307
318
  .ds-chat-widget__widgets .ds-widget-grid > :nth-child(2) { --ds-chat-widget-tile: 1; }
308
319
  .ds-chat-widget__widgets .ds-widget-grid > :nth-child(3) { --ds-chat-widget-tile: 2; }
309
320
  .ds-chat-widget__widgets .ds-widget-grid > :nth-child(4) { --ds-chat-widget-tile: 3; }
@@ -641,9 +652,10 @@
641
652
 
642
653
  /* ============================================
643
654
  THE RAILS — the optional session-history rail (leading) and agent pane
644
- (trailing). Wide widgets seat them inline; narrow ones summon the history
645
- from the header hamburger as a slide-over sheet and the agent pane from a
646
- header button as a bottom sheet, each behind a scrim.
655
+ (trailing). Wide widgets seat them inline; narrow ones open the built-in
656
+ history as AppSidebar's drawer from the header's menu button (a custom
657
+ rail as a slide-over sheet behind a scrim) and the agent pane from a
658
+ header button as a bottom sheet.
647
659
  ============================================ */
648
660
 
649
661
  .ds-chat-widget__rails {
@@ -63,18 +63,16 @@ export interface ChatWidgetProps {
63
63
  /** Narrow insets for phone-width hosts. */
64
64
  compact?: boolean;
65
65
  /**
66
- * Seat the widget as a page in one of the three app shell modes, the ones
67
- * AppLayout draws, for a host where the chat is the page (a chat home)
68
- * rather than a panel over one. `flush` runs the history rail on the
69
- * shell colour behind a hairline with the conversation crisp beside it;
70
- * `floating` lifts the rail into a glass card off the edges; `inset` runs
71
- * the rail flush on the shell colour and seats the conversation and each
72
- * trailing panel in raised surfaces. Left out, the widget draws no shell
73
- * of its own and takes its host's ground, as a docked or floating panel
74
- * does. A widget narrower than the inline rail's 720px threshold has no
75
- * room for a raised mode, so floating and inset lay out flush on the
76
- * solid backdrop there, and below the mobile breakpoint every mode gives
77
- * way to the plain full-screen chat.
66
+ * Seat the widget as a page in one of AppLayout's three shell modes, for a
67
+ * host where the chat is the page (a chat home), not a panel over one.
68
+ * `flush` runs the history rail on the shell colour behind a hairline
69
+ * beside the conversation; `floating` lifts the rail into a glass card;
70
+ * `inset` runs the rail flush and seats the conversation
71
+ * and each trailing panel in raised surfaces. Left out, the widget draws
72
+ * no shell and takes its host's ground, as a docked or floating panel
73
+ * does. Under the inline rail's 720px threshold floating and inset lay
74
+ * out flush on the solid backdrop, and below the mobile breakpoint every
75
+ * mode gives way to the plain full-screen chat.
78
76
  */
79
77
  layout?: ChatLayout;
80
78
  /**
@@ -126,6 +124,8 @@ export interface ChatWidgetProps {
126
124
  composerActions?: ReactNode;
127
125
  /** The composer's gradient ring, Composer's `aiGlow`: `'streaming'` (the default) lights it only while a reply is in flight, `true` also on focus, `false` never. */
128
126
  composerGlow?: boolean | 'streaming';
127
+ /** Composer's `glass`, for a chat on a picture or shader. Off by default. */
128
+ composerGlass?: boolean;
129
129
  /** The models the picker offers. The pick rides on each send as a wire value; the server resolves it. Omit for no picker. */
130
130
  models?: ChatModelOption[];
131
131
  /** The picker's selection before the server has reported its default. Defaults to the first model. */
@@ -143,10 +143,9 @@ export interface ChatWidgetProps {
143
143
  /** What the visitor can reference while typing: one source per trigger
144
144
  character, drawn as tags in the composer and in the sent bubble. */
145
145
  mentions?: MentionSource[];
146
- /** A session-history rail. `true` seats the built-in ChatThreads over the
147
- provider's thread lifecycle; a render prop seats your own. Wide hosts
148
- seat it as an inline left rail, narrow ones summon it from a header
149
- hamburger as a slide-over sheet behind a scrim. */
146
+ /** A session-history rail. `true` seats the built-in ChatThreads, an
147
+ AppSidebar: inline when wide, its drawer from the header when narrow.
148
+ A render prop seats your own, inline or as a slide-over sheet. */
150
149
  threads?: RailSlot;
151
150
  /** Props for the built-in threads rail when `threads` is `true`. */
152
151
  threadsProps?: Omit<ChatThreadsProps, 'overlay' | 'close'>;
@@ -291,4 +290,4 @@ export interface ChatWidgetProps {
291
290
  * a stage card, a whole page). It reads all of its state from ChatProvider,
292
291
  * so the conversation is the same object wherever it shows.
293
292
  */
294
- export declare function ChatWidget({ fullscreenEnabled, layout, backdrop, closeEnabled, placementEnabled, compact, phone, title, flow, placeholder, questionsPlaceholder, showStarters, logo, tagline, starters: startersInput, startersKey, startersPending, composerActions, models, defaultModel, lockedModelDescription, fileAttachments, maxAttachments, maxAttachmentBytes, mentions, threads, threadsProps, tabs, aside, agent, artifacts, context: contextProp, contextClearLabel, contextLabel, contextNote, contextPlacement, attachHint: attachHintText, greetings, placementLabels, agentStatus, artifactPanelTitle, artifactEmptyTitle, artifactEmptyDescription, widgets, widgetsLayout, widgetsWidth, disclaimer, startersLabel, newChatLabel, showAgentLabel, hideAgentLabel, closeAgentLabel, showArtifactLabel, hideArtifactLabel, closeArtifactLabel, placementLabel, enterFullscreenLabel, exitFullscreenLabel, closeLabel, openThreadsLabel, closeThreadsLabel, modelPickerLabel, sendLabel, copyResponseLabel, copiedResponseLabel, copiedAnnouncementLabel, goodResponseLabel, badResponseLabel, followupsLabel, pastedTextLabel, reasoningLabel, awaitingApprovalLabel, composerGlow, tabsProps, composerLabels, attachmentDropZoneLabels, attachmentGroupLabels, renderAttachmentPreview, onAttachmentDownload, chatThreadLabels, modelPickerLabels, artifactPanelLabels, agentRailLabels, questionCardLabels, questionSummaryLabels, codeBlockLabels, promptSuggestionsLabels, }: ChatWidgetProps): import("react").JSX.Element;
293
+ export declare function ChatWidget({ fullscreenEnabled, layout, backdrop, closeEnabled, placementEnabled, compact, phone, title, flow, placeholder, questionsPlaceholder, showStarters, logo, tagline, starters: startersInput, startersKey, startersPending, composerActions, models, defaultModel, lockedModelDescription, fileAttachments, maxAttachments, maxAttachmentBytes, mentions, threads, threadsProps, tabs, aside, agent, artifacts, context: contextProp, contextClearLabel, contextLabel, contextNote, contextPlacement, attachHint: attachHintText, greetings, placementLabels, agentStatus, artifactPanelTitle, artifactEmptyTitle, artifactEmptyDescription, widgets, widgetsLayout, widgetsWidth, disclaimer, startersLabel, newChatLabel, showAgentLabel, hideAgentLabel, closeAgentLabel, showArtifactLabel, hideArtifactLabel, closeArtifactLabel, placementLabel, enterFullscreenLabel, exitFullscreenLabel, closeLabel, openThreadsLabel, closeThreadsLabel, modelPickerLabel, sendLabel, copyResponseLabel, copiedResponseLabel, copiedAnnouncementLabel, goodResponseLabel, badResponseLabel, followupsLabel, pastedTextLabel, reasoningLabel, awaitingApprovalLabel, composerGlow, composerGlass, tabsProps, composerLabels, attachmentDropZoneLabels, attachmentGroupLabels, renderAttachmentPreview, onAttachmentDownload, chatThreadLabels, modelPickerLabels, artifactPanelLabels, agentRailLabels, questionCardLabels, questionSummaryLabels, codeBlockLabels, promptSuggestionsLabels, }: ChatWidgetProps): import("react").JSX.Element;