rift-ds 1.38.0 → 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.
- package/README.md +3 -3
- package/behaviors/shortcuts.js +2 -2
- package/behaviors/useFoldedSections.d.ts +17 -0
- package/behaviors/useFoldedSections.js +23 -0
- package/behaviors/useLayer.d.ts +9 -0
- package/behaviors/useLayer.js +4 -3
- package/chat/ChatThreads.d.ts +63 -19
- package/chat/ChatThreads.js +119 -32
- package/chat/ChatWidget.css +15 -3
- package/chat/ChatWidget.d.ts +16 -17
- package/chat/ChatWidget.js +40 -7
- package/chat/DemoWelcome.d.ts +7 -0
- package/chat/DemoWelcome.js +19 -0
- package/chat/demo-fixtures.d.ts +1 -1
- package/chat/demo-fixtures.js +1 -0
- package/chat/rail-seat.d.ts +25 -0
- package/chat/rail-seat.js +8 -0
- package/chat/registry.json.d.ts +4 -1
- package/chat/registry.json.js +1 -1
- package/components/AppLayout/AppLayout.d.ts +13 -1
- package/components/AppLayout/AppLayout.js +2 -0
- package/components/AppSidebar/AppSidebar.css +357 -11
- package/components/AppSidebar/AppSidebar.d.ts +92 -4
- package/components/AppSidebar/AppSidebar.js +319 -155
- package/components/Composer/Composer.css +20 -0
- package/components/Composer/Composer.d.ts +8 -0
- package/components/Composer/Composer.js +2 -0
- package/components/DrillMenu/DrillMenu.css +7 -0
- package/components/DrillMenu/DrillMenu.d.ts +6 -0
- package/components/DrillMenu/DrillMenu.js +2 -1
- package/components/PromptSuggestions/PromptSuggestions.css +180 -11
- package/components/PromptSuggestions/PromptSuggestions.d.ts +24 -3
- package/components/PromptSuggestions/PromptSuggestions.js +35 -9
- package/components/ShaderScene/scenes.js +6 -5
- package/components/SubNavPanel/SubNavPanel.css +21 -0
- package/components/SubNavPanel/SubNavPanel.js +19 -2
- package/components/ThreadHistory/ThreadHistory.css +519 -0
- package/components/ThreadHistory/ThreadHistory.d.ts +90 -0
- package/components/ThreadHistory/ThreadHistory.js +344 -0
- package/components/ThreadPanel/ThreadPanel.css +90 -306
- package/components/ThreadPanel/ThreadPanel.d.ts +16 -0
- package/components/ThreadPanel/ThreadPanel.js +67 -241
- package/components/registry.json +24 -4
- package/components/registry.json.d.ts +24 -4
- package/components/registry.json.js +1 -1
- package/index.d.ts +1 -0
- package/index.js +2 -0
- package/package.json +1 -1
- package/tokens/presets/contrast.css +2 -0
- package/tokens/presets/coral.css +2 -0
- package/tokens/presets/forest.css +8 -0
- package/tokens/presets/pink.css +2 -0
- package/tokens/presets/violet.css +2 -0
- package/tokens/presets/zest.css +4 -0
- package/tokens/values.json.js +1 -1
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 -->
|
|
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 -->
|
|
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 · 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 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>
|
package/behaviors/shortcuts.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useRef, useEffect
|
|
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 {
|
|
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
|
+
};
|
package/behaviors/useLayer.d.ts
CHANGED
|
@@ -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
|
package/behaviors/useLayer.js
CHANGED
|
@@ -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
|
|
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",
|
|
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",
|
|
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
|
package/chat/ChatThreads.d.ts
CHANGED
|
@@ -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
|
-
/**
|
|
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
|
|
8
|
+
/** Closes that sheet; a no-op elsewhere. */
|
|
7
9
|
close: () => void;
|
|
8
|
-
/** The brand row's mark
|
|
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
|
|
12
|
+
/** The brand row's text, beside the mark while the rail is expanded. */
|
|
11
13
|
logoText?: string;
|
|
12
|
-
/** The signed-in person, shown
|
|
14
|
+
/** The signed-in person, shown at the rail's foot. */
|
|
13
15
|
profile?: ThreadPanelProfile;
|
|
14
|
-
/** Rendered in the rail's footer
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
|
22
|
-
* collapsed to its icon strip. The
|
|
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
|
|
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
|
|
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
|
|
33
|
-
* collapse toggle ("Collapse the panel", "Expand the panel"
|
|
34
|
-
* own name is
|
|
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:
|
|
42
|
-
* thread lifecycle (`useThreads`)
|
|
43
|
-
*
|
|
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;
|
package/chat/ChatThreads.js
CHANGED
|
@@ -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 {
|
|
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
|
-
|
|
127
|
+
AppSidebar,
|
|
41
128
|
{
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
},
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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
|
|
156
|
+
collapsedFooterSlot,
|
|
157
|
+
footerAction,
|
|
158
|
+
drawerTopEntries,
|
|
159
|
+
drawerBottomEntries
|
|
73
160
|
}
|
|
74
161
|
);
|
|
75
162
|
}
|
package/chat/ChatWidget.css
CHANGED
|
@@ -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
|
|
645
|
-
|
|
646
|
-
|
|
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 {
|
package/chat/ChatWidget.d.ts
CHANGED
|
@@ -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
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
* `
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
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
|
|
147
|
-
|
|
148
|
-
|
|
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;
|