rift-ds 1.30.0 → 1.32.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 +6 -4
- package/behaviors/chat-card.css +4 -1
- package/behaviors/deferComponent.d.ts +43 -0
- package/behaviors/deferComponent.js +35 -0
- package/behaviors/locale.d.ts +7 -0
- package/behaviors/locale.js +5 -0
- package/behaviors/shell.css +33 -0
- package/bin/rift-ds.mjs +35 -9
- package/bin/templates/blocks/app/planner/PlannerGrid.tsx +58 -0
- package/bin/templates/blocks/app/planner/Requests.tsx +42 -0
- package/bin/templates/blocks/app/planner/page.module.css +17 -0
- package/bin/templates/blocks/app/planner/page.tsx +32 -0
- package/bin/templates/blocks/components/blocks/AppShell.module.css +10 -1
- package/bin/templates/blocks/registry.json +14 -0
- package/bin/templates/chat/app/api/chat/route.actions.ts +108 -0
- package/bin/templates/chat/components/chat/ChatMount.actions.tsx +55 -0
- package/bin/templates/chat/components/chat/ChatMount.tsx +14 -1
- package/bin/templates/chat/components/chat/proposals/ProposalCard.tsx +81 -0
- package/bin/templates/chat/components/chat/proposals/actions.ts +60 -0
- package/bin/templates/chat/components/chat/proposals/confirmation.ts +9 -0
- package/bin/templates/chat/components/chat/proposals/renderers.tsx +9 -0
- package/chat/ChatLauncher.d.ts +13 -2
- package/chat/ChatLauncher.js +52 -29
- package/chat/ChatProvider.d.ts +19 -2
- package/chat/ChatProvider.js +26 -3
- package/chat/ChatWidget.css +23 -4
- package/chat/ChatWidget.d.ts +2 -1
- package/chat/ChatWidget.js +23 -21
- package/chat/actions.d.ts +52 -6
- package/chat/actions.js +53 -5
- package/chat/contextSchema.d.ts +76 -0
- package/chat/contextSchema.js +58 -0
- package/chat/deferredChatWidget.d.ts +10 -0
- package/chat/deferredChatWidget.js +10 -0
- package/chat/index.d.ts +3 -2
- package/chat/index.js +7 -1
- package/chat/registry.json.d.ts +4 -3
- package/chat/registry.json.js +1 -1
- package/chat/server.d.ts +18 -2
- package/chat/server.js +10 -1
- package/chat/suggestions.d.ts +7 -0
- package/chat/suggestions.js +13 -1
- package/chat/types.d.ts +23 -0
- package/chat/useChat.d.ts +2 -2
- package/chat/useChat.js +15 -1
- package/components/Accordion/Accordion.css +8 -0
- package/components/AgentPlan/AgentPlan.css +8 -0
- package/components/AgentRail/AgentRail.css +3 -3
- package/components/AiButton/AiButton.css +19 -0
- package/components/AiButton/AiButton.d.ts +10 -1
- package/components/AiButton/AiButton.js +6 -1
- package/components/AppSidebar/AppSidebar.css +12 -0
- package/components/ArtifactPanel/ArtifactPanel.js +5 -5
- package/components/Attachment/AttachmentViewer.js +7 -7
- package/components/BentoTile/BentoTile.css +1 -1
- package/components/BentoTile/BentoTile.js +5 -5
- package/components/Button/Button.css +28 -1
- package/components/Button/Button.d.ts +7 -2
- package/components/Button/Button.js +7 -3
- package/components/ButtonGroup/ButtonGroup.css +10 -1
- package/components/Chart/RadarChart.js +24 -10
- package/components/ChatHeader/ChatHeader.d.ts +1 -1
- package/components/ChatThread/ChatThread.css +1 -1
- package/components/Chip/Chip.css +26 -0
- package/components/CircularButton/CircularButton.d.ts +16 -96
- package/components/CircularButton/CircularButton.js +11 -94
- package/components/Combobox/Combobox.css +12 -0
- package/components/CommandPalette/CommandPalette.css +1 -1
- package/components/CommandPalette/CommandPalette.js +3 -3
- package/components/CommandPaletteTrigger/CommandPaletteTrigger.css +9 -0
- package/components/CommandPaletteTrigger/CommandPaletteTrigger.d.ts +10 -2
- package/components/CommandPaletteTrigger/CommandPaletteTrigger.js +7 -2
- package/components/Composer/Composer.css +3 -3
- package/components/Composer/Composer.js +9 -9
- package/components/ContextMenu/ContextMenu.css +24 -0
- package/components/DataTable/DataTable.css +19 -4
- package/components/DataTable/DataTable.d.ts +14 -2
- package/components/DataTable/DataTable.js +28 -17
- package/components/DataTable/periodColumns.d.ts +37 -0
- package/components/DataTable/periodColumns.js +48 -0
- package/components/DateInput/DateInput.css +20 -0
- package/components/DatePicker/DatePicker.css +22 -6
- package/components/DatePicker/DatePicker.d.ts +2 -1
- package/components/DatePicker/DatePicker.js +2 -2
- package/components/DateRangePicker/DateRangePicker.js +2 -2
- package/components/DecisionRow/DecisionRow.css +46 -0
- package/components/DecisionRow/DecisionRow.d.ts +62 -0
- package/components/DecisionRow/DecisionRow.js +93 -0
- package/components/DescriptionList/DescriptionListCopy.d.ts +1 -1
- package/components/DescriptionList/DescriptionListCopy.js +3 -3
- package/components/Dialog/Dialog.css +1 -1
- package/components/Dialog/Dialog.js +3 -3
- package/components/DocumentChip/DocumentChip.css +12 -0
- package/components/DocumentViewer/DocumentViewer.js +10 -10
- package/components/Drawer/Drawer.css +1 -1
- package/components/Drawer/Drawer.js +3 -3
- package/components/Dropdown/Dropdown.css +30 -0
- package/components/DropdownMenu/DropdownMenu.css +24 -0
- package/components/EventCalendar/EventCalendar.css +54 -0
- package/components/EventCalendar/EventCalendar.d.ts +27 -5
- package/components/EventCalendar/EventCalendar.js +50 -15
- package/components/FileInput/FileInput.css +9 -0
- package/components/FilterBar/FilterBar.css +12 -0
- package/components/FunnelChart/FunnelChart.js +33 -22
- package/components/Globe/Globe.css +7 -0
- package/components/Globe/Globe.js +1 -1
- package/components/{CircularButton/CircularButton.css → IconButton/IconButton.css} +91 -81
- package/components/IconButton/IconButton.d.ts +108 -0
- package/components/IconButton/IconButton.js +101 -0
- package/components/Input/Input.css +53 -0
- package/components/Input/Input.js +3 -3
- package/components/MaskedInput/MaskedInput.js +3 -3
- package/components/ModelPicker/ModelPicker.css +12 -1
- package/components/NavList/NavList.css +1 -1
- package/components/Pagination/Pagination.css +1 -1
- package/components/QuestionCard/QuestionCard.js +3 -3
- package/components/RadioButton/RadioButton.css +14 -12
- package/components/RichDropdown/RichDropdown.css +7 -0
- package/components/SegmentedControl/SegmentedControl.css +16 -5
- package/components/SegmentedControl/SegmentedControl.js +7 -4
- package/components/SiteHeader/SiteHeader.css +12 -5
- package/components/SiteHeader/SiteHeader.js +3 -3
- package/components/SourceTrail/SourceTrail.css +8 -0
- package/components/SplitButton/SplitButton.css +14 -14
- package/components/SplitButton/SplitButton.js +3 -3
- package/components/Table/Table.css +7 -0
- package/components/Table/Table.js +1 -1
- package/components/TableToolbar/TableToolbar.css +2 -2
- package/components/TableToolbar/TableToolbar.js +36 -37
- package/components/Tabs/Tabs.css +21 -3
- package/components/ThreadPanel/ThreadPanel.css +8 -0
- package/components/ThreadTabs/ThreadTabs.css +7 -0
- package/components/TimePicker/TimePicker.css +12 -0
- package/components/Timeline/Timeline.css +8 -0
- package/components/ToolCall/ToolCall.css +8 -0
- package/components/Tooltip/Tooltip.js +3 -2
- package/components/Widget/Widget.css +2 -0
- package/components/WorldMap/WorldMap.css +15 -0
- package/components/WorldMap/WorldMap.js +61 -6
- package/components/registry.d.ts +3 -1
- package/components/registry.json +39 -13
- package/components/registry.json.d.ts +39 -13
- package/components/registry.json.js +1 -1
- package/index.d.ts +2 -0
- package/index.js +8 -0
- package/package.json +6 -2
- package/tokens/presets/blueprint.css +9 -0
- package/tokens/presets/bubblegum.css +9 -0
- package/tokens/presets/contrast.css +3 -3
- package/tokens/presets/coral.css +3 -3
- package/tokens/presets/ember.css +9 -0
- package/tokens/presets/getaway.css +9 -0
- package/tokens/presets/gold.css +3 -3
- package/tokens/presets/mono.css +3 -3
- package/tokens/presets/pink.css +3 -3
- package/tokens/presets/plum.css +3 -3
- package/tokens/presets/signal.css +9 -0
- package/tokens/presets/smoke.css +9 -0
- package/tokens/presets/velvet.css +9 -0
- package/tokens/presets/violet.css +3 -3
- package/tokens/presets/volt.css +9 -0
- package/tokens/presets/warm.css +3 -3
package/chat/server.d.ts
CHANGED
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
import { default as Anthropic } from '@anthropic-ai/sdk';
|
|
2
|
-
import { ChatCard, ChatFeedbackVerdict, ChatModelOption } from './types';
|
|
2
|
+
import { ChatCard, ChatFeedbackVerdict, ChatModelOption, ChatPageAction } from './types';
|
|
3
3
|
/** What a tool hands back: text for the model, and optionally a card for the visitor. */
|
|
4
|
-
export { defineAction, planAction, skippedText, createConfirmationMark, sanitiseConfirmation, confirmationLine, type ChatAction, type ActionPlan, type ActionConfirmation, type ConfirmationMark, type SanitiseConfirmationOptions, type ConfirmationLineOptions, } from './actions';
|
|
4
|
+
export { defineAction, planAction, skippedText, createConfirmationMark, sanitiseConfirmation, confirmationLine, planSequence, confirmSequence, defineContext, type ChatAction, type ActionPlan, type ActionConfirmation, type ConfirmationMark, type SanitiseConfirmationOptions, type ConfirmationLineOptions, type SequenceStep, type SequencePlan, type ConfirmedStep, type ContextField, type ContextShape, type ContextValues, type ContextSchema, } from './actions';
|
|
5
5
|
export { sanitiseSelection, selectionLines, DEFAULT_SELECTION_LIMITS, type ChatSelection, type SelectionKind, type SelectionLimits, type SelectionLinesOptions } from './selectionContext';
|
|
6
6
|
export interface ChatToolResult {
|
|
7
7
|
/** The tool result the model reads. */
|
|
8
8
|
text: string;
|
|
9
9
|
/** Rich content streamed to the widget as a `card` event, drawn by the provider's renderers. */
|
|
10
10
|
card?: ChatCard;
|
|
11
|
+
/**
|
|
12
|
+
* Changes for the page to make in the browser, streamed as `action` events
|
|
13
|
+
* after the card and run once each by the provider's `pageActions`. An
|
|
14
|
+
* action with no `id` is given one.
|
|
15
|
+
*/
|
|
16
|
+
actions?: (Omit<ChatPageAction, 'id'> & {
|
|
17
|
+
id?: string;
|
|
18
|
+
})[];
|
|
11
19
|
}
|
|
12
20
|
/** What a tool is told about the request it runs in. */
|
|
13
21
|
export interface ChatToolContext {
|
|
@@ -179,6 +187,14 @@ export interface ChatHandlerOptions {
|
|
|
179
187
|
copy?: Partial<ChatHandlerCopy>;
|
|
180
188
|
/** Turns the request's raw `path` into context, or null to drop it. The default accepts lowercase slug paths only. */
|
|
181
189
|
sanitiseContext?: (value: unknown) => string | null;
|
|
190
|
+
/**
|
|
191
|
+
* Cards the reply opens with, sent before the model is called and marked
|
|
192
|
+
* `lead`, so they hold still under the thinking line: the record of a
|
|
193
|
+
* change the reader just confirmed, worked out from the sanitised context.
|
|
194
|
+
* Return none for a request that needs none. A failure sends no lead and
|
|
195
|
+
* the reply goes on.
|
|
196
|
+
*/
|
|
197
|
+
lead?: (context: ChatToolContext) => ChatCard[] | Promise<ChatCard[]>;
|
|
182
198
|
/** Keeps a fire-and-forget promise alive on platforms that end work with the response. */
|
|
183
199
|
waitUntil?: (promise: Promise<unknown>) => void;
|
|
184
200
|
}
|
package/chat/server.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import Anthropic from "@anthropic-ai/sdk";
|
|
2
2
|
import { ASK_USER_INPUT_SCHEMA, sanitizeQuestionSet } from "./questions.js";
|
|
3
3
|
import { SUGGESTION_MAX_CHARS, fitsChip } from "./suggestions.js";
|
|
4
|
-
import { confirmationLine, createConfirmationMark, defineAction, planAction, sanitiseConfirmation, skippedText } from "./actions.js";
|
|
4
|
+
import { confirmSequence, confirmationLine, createConfirmationMark, defineAction, planAction, planSequence, sanitiseConfirmation, skippedText } from "./actions.js";
|
|
5
5
|
import { DEFAULT_SELECTION_LIMITS, sanitiseSelection, selectionLines } from "./selectionContext.js";
|
|
6
|
+
import { defineContext } from "./contextSchema.js";
|
|
6
7
|
const ASK_USER_TOOL_NAME = "ask_user";
|
|
7
8
|
const DEFAULT_ASK_USER_DESCRIPTION = [
|
|
8
9
|
"Offer the person answers to pick for a question your reply has just asked in words.",
|
|
@@ -244,6 +245,8 @@ function createChatHandler(options) {
|
|
|
244
245
|
send({ type: "status", label: copy.reading });
|
|
245
246
|
send({ type: "model", label: serving.label });
|
|
246
247
|
send({ type: "models", default: tierDefault, locked: lockedValues });
|
|
248
|
+
const leads = options.lead ? await Promise.resolve(options.lead(toolContext)).catch(() => []) : [];
|
|
249
|
+
for (const card of leads) send({ type: "card", card: { ...card, lead: true } });
|
|
247
250
|
const reasoning = createReasoningBuffer(
|
|
248
251
|
limits.maxTracePoints,
|
|
249
252
|
(point) => send({ type: "status", label: copy.thinking, point })
|
|
@@ -332,6 +335,9 @@ function createChatHandler(options) {
|
|
|
332
335
|
});
|
|
333
336
|
const result = await runTool(block.name, block.input, toolContext);
|
|
334
337
|
if (result.card) send({ type: "card", card: result.card });
|
|
338
|
+
for (const action of result.actions ?? []) {
|
|
339
|
+
send({ type: "action", action: { ...action, id: action.id ?? crypto.randomUUID() } });
|
|
340
|
+
}
|
|
335
341
|
results.push({ type: "tool_result", tool_use_id: block.id, content: result.text });
|
|
336
342
|
}
|
|
337
343
|
working.push(
|
|
@@ -614,6 +620,7 @@ export {
|
|
|
614
620
|
DEFAULT_CHAT_COPY,
|
|
615
621
|
DEFAULT_CHAT_LIMITS,
|
|
616
622
|
DEFAULT_SELECTION_LIMITS,
|
|
623
|
+
confirmSequence,
|
|
617
624
|
confirmationLine,
|
|
618
625
|
createChatHandler,
|
|
619
626
|
createConfirmationMark,
|
|
@@ -621,9 +628,11 @@ export {
|
|
|
621
628
|
createFollowupsHandler,
|
|
622
629
|
createStartersHandler,
|
|
623
630
|
defineAction,
|
|
631
|
+
defineContext,
|
|
624
632
|
followupsSystemPrompt,
|
|
625
633
|
parseFollowups,
|
|
626
634
|
planAction,
|
|
635
|
+
planSequence,
|
|
627
636
|
sanitiseConfirmation,
|
|
628
637
|
sanitisePath,
|
|
629
638
|
sanitiseSelection,
|
package/chat/suggestions.d.ts
CHANGED
|
@@ -36,3 +36,10 @@
|
|
|
36
36
|
export declare const SUGGESTION_MAX_CHARS = 30;
|
|
37
37
|
/** Whether a suggestion label is one the chip row can actually show. */
|
|
38
38
|
export declare function fitsChip(label: string): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Keeps the suggestions a host wrote that fit the chip row, and warns once in
|
|
41
|
+
* development about each one it drops, naming where it came from. A host's
|
|
42
|
+
* own copy running long is a mistake worth pointing at; a model's suggestion
|
|
43
|
+
* running long is not, so the producers of model output call `fitsChip` alone.
|
|
44
|
+
*/
|
|
45
|
+
export declare function keepFittingSuggestions<T>(items: readonly T[], labelOf: (item: T) => string, where: string): T[];
|
package/chat/suggestions.js
CHANGED
|
@@ -1,9 +1,21 @@
|
|
|
1
|
+
import { warnOnce } from "../behaviors/devWarning.js";
|
|
1
2
|
const SUGGESTION_MAX_CHARS = 30;
|
|
2
3
|
function fitsChip(label) {
|
|
3
4
|
const trimmed = label.trim();
|
|
4
5
|
return trimmed !== "" && trimmed.length <= SUGGESTION_MAX_CHARS;
|
|
5
6
|
}
|
|
7
|
+
function keepFittingSuggestions(items, labelOf, where) {
|
|
8
|
+
return items.filter((item) => {
|
|
9
|
+
const label = labelOf(item);
|
|
10
|
+
if (fitsChip(label)) return true;
|
|
11
|
+
warnOnce(
|
|
12
|
+
`${where}: "${label}" was dropped. A suggestion is one chip and a chip never wraps, so it must fit in ${SUGGESTION_MAX_CHARS} characters (SUGGESTION_MAX_CHARS).`
|
|
13
|
+
);
|
|
14
|
+
return false;
|
|
15
|
+
});
|
|
16
|
+
}
|
|
6
17
|
export {
|
|
7
18
|
SUGGESTION_MAX_CHARS,
|
|
8
|
-
fitsChip
|
|
19
|
+
fitsChip,
|
|
20
|
+
keepFittingSuggestions
|
|
9
21
|
};
|
package/chat/types.d.ts
CHANGED
|
@@ -78,6 +78,22 @@ export interface ChatReply {
|
|
|
78
78
|
answers: string[];
|
|
79
79
|
}[];
|
|
80
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* A change for the page itself, which lives in the browser where a server
|
|
83
|
+
* tool cannot reach: navigation, a table's view, the open tab, the theme. A
|
|
84
|
+
* tool returns it and the handler streams it; the provider runs the
|
|
85
|
+
* `pageActions` handler of the same `name` once, as the event arrives. The
|
|
86
|
+
* page owns what each name may do and checks `input` itself, since it came
|
|
87
|
+
* from the model.
|
|
88
|
+
*/
|
|
89
|
+
export interface ChatPageAction {
|
|
90
|
+
/** Unique within the conversation: the provider runs each id once. */
|
|
91
|
+
id: string;
|
|
92
|
+
/** Which of the provider's `pageActions` runs it. An unknown name is ignored. */
|
|
93
|
+
name: string;
|
|
94
|
+
/** What the handler is handed. Must survive JSON. */
|
|
95
|
+
input?: unknown;
|
|
96
|
+
}
|
|
81
97
|
export type ChatEvent =
|
|
82
98
|
/** A live status step: the AgentStatus label, with an optional reasoning trace point. */
|
|
83
99
|
{
|
|
@@ -143,6 +159,13 @@ export type ChatEvent =
|
|
|
143
159
|
type: 'question';
|
|
144
160
|
set: ChatQuestionSet;
|
|
145
161
|
}
|
|
162
|
+
/** Something for the page to do in the browser (go to a page, set a
|
|
163
|
+
table's view, open a tab), run once by the provider's `pageActions` as
|
|
164
|
+
it arrives. Never re-run when the thread redraws or the panel reopens. */
|
|
165
|
+
| {
|
|
166
|
+
type: 'action';
|
|
167
|
+
action: ChatPageAction;
|
|
168
|
+
}
|
|
146
169
|
/** Terminal: the response is complete. */
|
|
147
170
|
| {
|
|
148
171
|
type: 'done';
|
package/chat/useChat.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { AttachmentItem } from '../components/Attachment/fileTypes';
|
|
3
|
-
import { ChatQuestionAnswer, ChatReply, ChatTransport, ChatTurn, LiveResponse } from './types';
|
|
3
|
+
import { ChatPageAction, ChatQuestionAnswer, ChatReply, ChatTransport, ChatTurn, LiveResponse } from './types';
|
|
4
4
|
/** The copy the hook writes itself: the status line of a reply that has not started, and the reply it shows when a transport ends a turn with nothing to show. */
|
|
5
5
|
export interface ChatPlaceholderCopy {
|
|
6
6
|
/** A completion that produced no text. */
|
|
@@ -82,4 +82,4 @@ export interface ChatState {
|
|
|
82
82
|
* streamed-text choreography. It knows nothing about rendering or about
|
|
83
83
|
* where events come from; the transport decides that.
|
|
84
84
|
*/
|
|
85
|
-
export declare function useChat(transport: ChatTransport, placeholders?: ChatPlaceholderCopy): ChatState;
|
|
85
|
+
export declare function useChat(transport: ChatTransport, placeholders?: ChatPlaceholderCopy, onAction?: (action: ChatPageAction) => void): ChatState;
|
package/chat/useChat.js
CHANGED
|
@@ -11,13 +11,18 @@ const DEFAULT_PLACEHOLDER_COPY = {
|
|
|
11
11
|
failed: "Something went wrong while replying. Try sending that again.",
|
|
12
12
|
thinking: "Thinking"
|
|
13
13
|
};
|
|
14
|
-
function useChat(transport, placeholders = DEFAULT_PLACEHOLDER_COPY) {
|
|
14
|
+
function useChat(transport, placeholders = DEFAULT_PLACEHOLDER_COPY, onAction) {
|
|
15
15
|
const [turns, setTurns] = useState([]);
|
|
16
16
|
const [live, setLive] = useState(null);
|
|
17
17
|
const [modelLabel, setModelLabel] = useState(null);
|
|
18
18
|
const [modelPolicy, setModelPolicy] = useState(null);
|
|
19
19
|
const abortRef = useRef(null);
|
|
20
20
|
const busyRef = useRef(false);
|
|
21
|
+
const onActionRef = useRef(onAction);
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
onActionRef.current = onAction;
|
|
24
|
+
}, [onAction]);
|
|
25
|
+
const ranActionsRef = useRef(/* @__PURE__ */ new Set());
|
|
21
26
|
const historyRef = useRef([]);
|
|
22
27
|
const generationRef = useRef(0);
|
|
23
28
|
useEffect(() => () => abortRef.current?.abort(), []);
|
|
@@ -138,6 +143,15 @@ function useChat(transport, placeholders = DEFAULT_PLACEHOLDER_COPY) {
|
|
|
138
143
|
if (set) current = { ...current, question: set };
|
|
139
144
|
break;
|
|
140
145
|
}
|
|
146
|
+
case "action":
|
|
147
|
+
if (typeof event.action?.id === "string" && typeof event.action.name === "string" && !ranActionsRef.current.has(event.action.id)) {
|
|
148
|
+
ranActionsRef.current.add(event.action.id);
|
|
149
|
+
try {
|
|
150
|
+
onActionRef.current?.(event.action);
|
|
151
|
+
} catch {
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
break;
|
|
141
155
|
case "status":
|
|
142
156
|
update({
|
|
143
157
|
...current,
|
|
@@ -124,3 +124,11 @@
|
|
|
124
124
|
color: var(--color-text-secondary);
|
|
125
125
|
margin: 0;
|
|
126
126
|
}
|
|
127
|
+
|
|
128
|
+
/* Icon side padding, Button's rule (design.md): a glyph's box carries its
|
|
129
|
+
own side bearing, so a side that holds one takes the step below the text
|
|
130
|
+
side. The trigger always ends on its chevron (20 → 16); the leading
|
|
131
|
+
side keeps the panel's inset, the line its content reads from. */
|
|
132
|
+
.ds-accordion__trigger {
|
|
133
|
+
padding-inline-end: var(--padding-400);
|
|
134
|
+
}
|
|
@@ -247,3 +247,11 @@
|
|
|
247
247
|
.ds-agent-plan .material-symbols-rounded {
|
|
248
248
|
color: inherit;
|
|
249
249
|
}
|
|
250
|
+
|
|
251
|
+
/* Icon side padding, Button's rule (design.md): a glyph's box carries its
|
|
252
|
+
own side bearing, so a side that holds one takes the step below the text
|
|
253
|
+
side. The header's chevron end steps in from the card inset; the
|
|
254
|
+
leading side keeps the inset, the line the body below it reads from. */
|
|
255
|
+
.ds-agent-plan__header:has(.ds-agent-plan__chevron) {
|
|
256
|
+
padding-inline-end: calc(var(--ds-chat-card-inset) - var(--padding-100));
|
|
257
|
+
}
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
header rather than sitting in it: the header is a centred identity
|
|
19
19
|
block, and a control in that column would push the portrait off axis. */
|
|
20
20
|
position: relative;
|
|
21
|
-
/*
|
|
21
|
+
/* IconButton's default footprint, named because two rules need it:
|
|
22
22
|
the control itself, and the row the rail reserves for it when there is
|
|
23
23
|
no header underneath it to float over. */
|
|
24
24
|
--ds-agent-rail-control: 40px;
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
|
|
49
49
|
.ds-agent-rail__collapse {
|
|
50
50
|
position: absolute;
|
|
51
|
-
/*
|
|
51
|
+
/* IconButton's default footprint and glyph, so the control sits in
|
|
52
52
|
the same row of controls the host puts along the card's top edge —
|
|
53
53
|
`--ds-agent-rail-collapse-top` is the seat, which a host overrides to
|
|
54
54
|
line the chevron up with its own header row. */
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
padding: 0;
|
|
64
64
|
border: none;
|
|
65
65
|
border-radius: var(--radius-pill);
|
|
66
|
-
/* A tertiary
|
|
66
|
+
/* A tertiary IconButton's exact resting treatment, because that is
|
|
67
67
|
what it sits in a row with: the host's own controls line up opposite it
|
|
68
68
|
on the same baseline, and a dimmer icon tier beside them would read as a
|
|
69
69
|
lesser control rather than the same kind of one. */
|
|
@@ -743,3 +743,22 @@
|
|
|
743
743
|
transition: none;
|
|
744
744
|
}
|
|
745
745
|
}
|
|
746
|
+
|
|
747
|
+
/* Icon side padding, Button's rule: beside the label the icon's box carries
|
|
748
|
+
its own side bearing, so its edge takes the step below the text side
|
|
749
|
+
(20 → 16 at default, 12 → 8 at compact). The busy and status glyphs ride
|
|
750
|
+
the same slot. An icon-only button keeps its even box. */
|
|
751
|
+
.ds-ai-button:not(.ds-ai-button--icon-only):has(.ds-ai-button__icon) {
|
|
752
|
+
padding-inline-start: var(--padding-400);
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
.ds-ai-button--compact:not(.ds-ai-button--icon-only):has(.ds-ai-button__icon) {
|
|
756
|
+
padding-inline-start: var(--padding-200);
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
/* The icon-only form's tooltip names the button; while a panel it opened is
|
|
760
|
+
showing (its own request, a Popover, a sheet) the panel says it all, and
|
|
761
|
+
the bubble would sit on the side the panel takes. */
|
|
762
|
+
.ds-tooltip:has(> .ds-ai-button[aria-expanded='true']) .ds-tooltip__panel {
|
|
763
|
+
display: none;
|
|
764
|
+
}
|
|
@@ -21,8 +21,17 @@ type AiButtonOwnProps = {
|
|
|
21
21
|
label?: string;
|
|
22
22
|
/** Leading icon — Material Symbol name (string) or custom element (ReactNode) */
|
|
23
23
|
icon?: string | React.ReactNode;
|
|
24
|
-
/** Draws the button
|
|
24
|
+
/** Draws the button holding only its icon, on an even box, for a tight bar. The label stays as its accessible name. */
|
|
25
25
|
iconOnly?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* The hover and focus tooltip of the icon-only form, which names itself as
|
|
28
|
+
* IconButton does: by default it carries `label`. Pass a string to show
|
|
29
|
+
* different wording, or `false` to opt out. A button with a `summary`
|
|
30
|
+
* shows none, since its panel opens on the same hover.
|
|
31
|
+
*/
|
|
32
|
+
tooltip?: string | false;
|
|
33
|
+
/** Which side the tooltip opens on. `start` and `end` follow the reading direction. */
|
|
34
|
+
tooltipPosition?: 'top' | 'bottom' | 'left' | 'right' | 'start' | 'end';
|
|
26
35
|
/** Button size */
|
|
27
36
|
size?: 'default' | 'compact';
|
|
28
37
|
/** Whether the button is disabled */
|
|
@@ -8,6 +8,7 @@ import { AgentStatusMark } from "../AgentStatus/AgentStatus.js";
|
|
|
8
8
|
import { PromptSuggestions } from "../PromptSuggestions/PromptSuggestions.js";
|
|
9
9
|
import { Skeleton } from "../Skeleton/Skeleton.js";
|
|
10
10
|
import { StreamingText } from "../StreamingText/StreamingText.js";
|
|
11
|
+
import { Tooltip } from "../Tooltip/Tooltip.js";
|
|
11
12
|
import { MOTION_FEEDBACK_RESET_MS, MOTION_SUMMARY_THINK_MS, MOTION_SUMMARY_REVEAL_MS, MOTION_HOVER_EXIT_GRACE_MS, MOTION_HOVER_SHOW_DELAY_MS } from "../../tokens/motion.js";
|
|
12
13
|
import "../../behaviors/visually-hidden.css";
|
|
13
14
|
import "./AiButton.css";
|
|
@@ -27,6 +28,8 @@ const AiButton = React.forwardRef(
|
|
|
27
28
|
label = "Ask AI",
|
|
28
29
|
icon = "auto_awesome",
|
|
29
30
|
iconOnly = false,
|
|
31
|
+
tooltip,
|
|
32
|
+
tooltipPosition = "top",
|
|
30
33
|
size = "default",
|
|
31
34
|
disabled,
|
|
32
35
|
state: status,
|
|
@@ -187,7 +190,7 @@ const AiButton = React.forwardRef(
|
|
|
187
190
|
) }),
|
|
188
191
|
/* @__PURE__ */ jsx("span", { className: iconOnly ? "ds-visually-hidden" : `${baseClass}__text`, children: label })
|
|
189
192
|
] });
|
|
190
|
-
const
|
|
193
|
+
const bareControl = href && !disabled ? /* @__PURE__ */ jsx(
|
|
191
194
|
Link,
|
|
192
195
|
{
|
|
193
196
|
...rest,
|
|
@@ -215,6 +218,8 @@ const AiButton = React.forwardRef(
|
|
|
215
218
|
children: content
|
|
216
219
|
}
|
|
217
220
|
);
|
|
221
|
+
const tooltipContent = !iconOnly || summary || tooltip === false ? null : tooltip ?? label;
|
|
222
|
+
const control = tooltipContent ? /* @__PURE__ */ jsx(Tooltip, { content: tooltipContent, position: tooltipPosition, children: bareControl }) : bareControl;
|
|
218
223
|
const announcer = status !== void 0 ? /* @__PURE__ */ jsx("span", { className: "ds-visually-hidden", role: "status", children: { ...DEFAULT_STATUS_LABELS, ...statusLabels }[status] }) : null;
|
|
219
224
|
const requestPanel = request ? /* @__PURE__ */ jsx(
|
|
220
225
|
"aside",
|
|
@@ -82,6 +82,18 @@
|
|
|
82
82
|
border-inline-end-color: transparent;
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
+
/* The inset rail and its side panel are the plane's own colour, so on a
|
|
86
|
+
wide screen they are drawn clear and the plane shows through. Filled,
|
|
87
|
+
they stack above the page and paint over the side of the raised
|
|
88
|
+
surface's shadow that falls on them, leaving a straight cut beside the
|
|
89
|
+
surface. The phone drawer keeps its fill (its own rule below). */
|
|
90
|
+
@media not (max-width: 768px) {
|
|
91
|
+
.ds-app-sidebar--inset:not(.ds-app-sidebar--mobile-open),
|
|
92
|
+
.ds-app-sidebar__panel--inset {
|
|
93
|
+
background-color: transparent;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
85
97
|
/* ============================================
|
|
86
98
|
TOP SECTION — logo + nav
|
|
87
99
|
============================================ */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsxs, jsx } from "react/jsx-runtime";
|
|
3
3
|
import React, { useId, useState } from "react";
|
|
4
|
-
import {
|
|
4
|
+
import { IconButton } from "../IconButton/IconButton.js";
|
|
5
5
|
import { CodeBlock } from "../CodeBlock/CodeBlock.js";
|
|
6
6
|
import { SegmentedControl } from "../SegmentedControl/SegmentedControl.js";
|
|
7
7
|
import "./ArtifactPanel.css";
|
|
@@ -80,22 +80,22 @@ const ArtifactPanel = React.forwardRef(
|
|
|
80
80
|
),
|
|
81
81
|
actions,
|
|
82
82
|
onExpandedChange && /* @__PURE__ */ jsx(
|
|
83
|
-
|
|
83
|
+
IconButton,
|
|
84
84
|
{
|
|
85
85
|
icon: expanded ? "collapse_content" : "expand_content",
|
|
86
86
|
variant: "tertiary",
|
|
87
|
-
|
|
87
|
+
label: expanded ? collapseLabel : expandLabel,
|
|
88
88
|
tooltipPosition: "bottom",
|
|
89
89
|
"aria-pressed": expanded,
|
|
90
90
|
onClick: () => onExpandedChange(!expanded)
|
|
91
91
|
}
|
|
92
92
|
),
|
|
93
93
|
onClose && /* @__PURE__ */ jsx(
|
|
94
|
-
|
|
94
|
+
IconButton,
|
|
95
95
|
{
|
|
96
96
|
icon: "close",
|
|
97
97
|
variant: "tertiary",
|
|
98
|
-
|
|
98
|
+
label: closeLabel,
|
|
99
99
|
tooltipPosition: "bottom",
|
|
100
100
|
onClick: onClose
|
|
101
101
|
}
|
|
@@ -3,7 +3,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import React, { useId, useRef, useState } from "react";
|
|
4
4
|
import ReactDOM from "react-dom";
|
|
5
5
|
import { Button } from "../Button/Button.js";
|
|
6
|
-
import {
|
|
6
|
+
import { IconButton } from "../IconButton/IconButton.js";
|
|
7
7
|
import { formatBytes } from "./fileTypes.js";
|
|
8
8
|
import { DocumentViewer } from "../DocumentViewer/DocumentViewer.js";
|
|
9
9
|
import { renderTypeMark } from "./typeMark.js";
|
|
@@ -181,12 +181,12 @@ const AttachmentViewer = React.forwardRef(
|
|
|
181
181
|
}
|
|
182
182
|
),
|
|
183
183
|
dismissible && /* @__PURE__ */ jsx(
|
|
184
|
-
|
|
184
|
+
IconButton,
|
|
185
185
|
{
|
|
186
186
|
icon: "close",
|
|
187
187
|
variant: "tertiary",
|
|
188
188
|
size: "compact",
|
|
189
|
-
|
|
189
|
+
label: closeLabel,
|
|
190
190
|
tooltip: false,
|
|
191
191
|
onClick: () => onOpenChange(false)
|
|
192
192
|
}
|
|
@@ -195,26 +195,26 @@ const AttachmentViewer = React.forwardRef(
|
|
|
195
195
|
/* @__PURE__ */ jsx("div", { className: `${baseClass}__stage`, children: stage }),
|
|
196
196
|
total > 1 && /* @__PURE__ */ jsxs("div", { className: `${baseClass}__footer`, children: [
|
|
197
197
|
/* @__PURE__ */ jsx(
|
|
198
|
-
|
|
198
|
+
IconButton,
|
|
199
199
|
{
|
|
200
200
|
icon: "chevron_left",
|
|
201
201
|
variant: "secondary",
|
|
202
202
|
tone: "neutral",
|
|
203
203
|
size: "compact",
|
|
204
|
-
|
|
204
|
+
label: previousLabel,
|
|
205
205
|
tooltip: false,
|
|
206
206
|
onClick: () => step(-1)
|
|
207
207
|
}
|
|
208
208
|
),
|
|
209
209
|
/* @__PURE__ */ jsx("span", { className: `${baseClass}__position`, "aria-live": "polite", children: positionText }),
|
|
210
210
|
/* @__PURE__ */ jsx(
|
|
211
|
-
|
|
211
|
+
IconButton,
|
|
212
212
|
{
|
|
213
213
|
icon: "chevron_right",
|
|
214
214
|
variant: "secondary",
|
|
215
215
|
tone: "neutral",
|
|
216
216
|
size: "compact",
|
|
217
|
-
|
|
217
|
+
label: nextLabel,
|
|
218
218
|
tooltip: false,
|
|
219
219
|
onClick: () => step(1)
|
|
220
220
|
}
|
|
@@ -364,7 +364,7 @@
|
|
|
364
364
|
|
|
365
365
|
/* The handle sits on the content inset, centred on the heading's first
|
|
366
366
|
line, so it reads as part of the heading row whatever the type scale.
|
|
367
|
-
32px is
|
|
367
|
+
32px is IconButton's compact size. */
|
|
368
368
|
.ds-bento-tile__toggle {
|
|
369
369
|
position: absolute;
|
|
370
370
|
top: calc(var(--_inset) + (var(--font-heading-2-line-height) - 32px) / 2);
|
|
@@ -3,7 +3,7 @@ import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
|
3
3
|
import React, { useState, useRef, useId, useCallback, useLayoutEffect } from "react";
|
|
4
4
|
import ReactDOM, { flushSync } from "react-dom";
|
|
5
5
|
import "./BentoTile.css";
|
|
6
|
-
import {
|
|
6
|
+
import { IconButton } from "../IconButton/IconButton.js";
|
|
7
7
|
import { ShaderField } from "../ShaderField/ShaderField.js";
|
|
8
8
|
import { BentoTileArt } from "./BentoTileArt.js";
|
|
9
9
|
import { useMounted } from "../../behaviors/useMounted.js";
|
|
@@ -192,14 +192,14 @@ const BentoTile = React.forwardRef(
|
|
|
192
192
|
expandable && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
193
193
|
/* @__PURE__ */ jsx("span", { className: `${base}__hit`, onClick: openOverlay, "aria-hidden": "true" }),
|
|
194
194
|
/* @__PURE__ */ jsx(
|
|
195
|
-
|
|
195
|
+
IconButton,
|
|
196
196
|
{
|
|
197
197
|
ref: triggerRef,
|
|
198
198
|
icon: "open_in_full",
|
|
199
199
|
variant: awake ? "primary" : "secondary",
|
|
200
200
|
tone: awake ? void 0 : "neutral",
|
|
201
201
|
size: "compact",
|
|
202
|
-
|
|
202
|
+
label,
|
|
203
203
|
tooltip: false,
|
|
204
204
|
"aria-haspopup": "dialog",
|
|
205
205
|
"aria-expanded": open,
|
|
@@ -276,14 +276,14 @@ function BentoTileOverlay({ title, titleId, panelName, toggleName, closeLabel, o
|
|
|
276
276
|
style: { viewTransitionName: panelName },
|
|
277
277
|
children: [
|
|
278
278
|
/* @__PURE__ */ jsx(
|
|
279
|
-
|
|
279
|
+
IconButton,
|
|
280
280
|
{
|
|
281
281
|
ref: closeRef,
|
|
282
282
|
icon: "close_fullscreen",
|
|
283
283
|
variant: "secondary",
|
|
284
284
|
tone: "neutral",
|
|
285
285
|
size: "compact",
|
|
286
|
-
|
|
286
|
+
label: closeLabel,
|
|
287
287
|
tooltip: false,
|
|
288
288
|
className: "ds-bento-tile-overlay__close",
|
|
289
289
|
onClick: onClose,
|
|
@@ -64,6 +64,33 @@
|
|
|
64
64
|
padding-block: 0;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
/* ============================================
|
|
68
|
+
ICON SIDE PADDING
|
|
69
|
+
An icon's box carries its own side bearing, so
|
|
70
|
+
beside a label the icon's edge reads one step
|
|
71
|
+
wider than the text's at the same padding. The
|
|
72
|
+
icon side takes the step below: 20 → 16 at
|
|
73
|
+
default, 12 → 8 at compact. The spinner in the
|
|
74
|
+
leading slot counts as an icon. An icon-only
|
|
75
|
+
button keeps its even padding.
|
|
76
|
+
============================================ */
|
|
77
|
+
|
|
78
|
+
.ds-button--icon-start {
|
|
79
|
+
padding-inline-start: var(--padding-400);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.ds-button--icon-end {
|
|
83
|
+
padding-inline-end: var(--padding-400);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.ds-button--compact.ds-button--icon-start {
|
|
87
|
+
padding-inline-start: var(--padding-200);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.ds-button--compact.ds-button--icon-end {
|
|
91
|
+
padding-inline-end: var(--padding-200);
|
|
92
|
+
}
|
|
93
|
+
|
|
67
94
|
.ds-button--compact .ds-button__icon {
|
|
68
95
|
/* Figma: compact icons are 20px (vs 24px default). */
|
|
69
96
|
--icon-size: var(--ds-button-icon-size, var(--icon-size-500));
|
|
@@ -558,7 +585,7 @@
|
|
|
558
585
|
|
|
559
586
|
/* The spinner is a box, not a glyph: left inline in the icon slot, it sits
|
|
560
587
|
on the text baseline and the strut's descender pushes it above centre.
|
|
561
|
-
Flex centres it geometrically — the same fix as
|
|
588
|
+
Flex centres it geometrically — the same fix as IconButton's loading
|
|
562
589
|
icon. */
|
|
563
590
|
.ds-button--loading .ds-button__icon {
|
|
564
591
|
display: inline-flex;
|
|
@@ -36,6 +36,12 @@ type ButtonOwnProps = {
|
|
|
36
36
|
tone?: 'default' | 'neutral' | 'destructive';
|
|
37
37
|
/** Button size */
|
|
38
38
|
size?: 'default' | 'compact';
|
|
39
|
+
/**
|
|
40
|
+
* Draws the button holding only its icon, on an even box. The label stays
|
|
41
|
+
* as its accessible name. For an icon action that also names itself on
|
|
42
|
+
* hover, use IconButton, which wears a tooltip.
|
|
43
|
+
*/
|
|
44
|
+
iconOnly?: boolean;
|
|
39
45
|
/** Whether the button is disabled */
|
|
40
46
|
disabled?: boolean;
|
|
41
47
|
/**
|
|
@@ -93,8 +99,7 @@ type ButtonOwnProps = {
|
|
|
93
99
|
/**
|
|
94
100
|
* Legacy toggle for showing the text label.
|
|
95
101
|
*
|
|
96
|
-
* @deprecated
|
|
97
|
-
* an icon-only button will simply omit `label`.
|
|
102
|
+
* @deprecated Use `iconOnly`, the spelling the button family shares.
|
|
98
103
|
*/
|
|
99
104
|
text?: boolean;
|
|
100
105
|
};
|
|
@@ -33,6 +33,7 @@ const Button = React.forwardRef(
|
|
|
33
33
|
variant,
|
|
34
34
|
tone,
|
|
35
35
|
size = "default",
|
|
36
|
+
iconOnly = false,
|
|
36
37
|
disabled,
|
|
37
38
|
loading,
|
|
38
39
|
glass,
|
|
@@ -45,7 +46,7 @@ const Button = React.forwardRef(
|
|
|
45
46
|
priority,
|
|
46
47
|
state,
|
|
47
48
|
icon,
|
|
48
|
-
text = true,
|
|
49
|
+
text: textProp = true,
|
|
49
50
|
...rest
|
|
50
51
|
}, ref) => {
|
|
51
52
|
const baseClass = "ds-button";
|
|
@@ -57,10 +58,13 @@ const Button = React.forwardRef(
|
|
|
57
58
|
);
|
|
58
59
|
}
|
|
59
60
|
const label = labelProp ?? childText ?? "Button";
|
|
61
|
+
const text = textProp && !iconOnly;
|
|
60
62
|
const resolvedVariant = resolveButtonCell(variant ?? priority ?? "primary", tone);
|
|
61
63
|
const isDisabled = disabled ?? state === "disabled";
|
|
62
64
|
const resolvedState = state ?? (isDisabled ? "disabled" : "default");
|
|
63
65
|
const isLoading = Boolean(loading);
|
|
66
|
+
const spinnerSize = size === "compact" ? "sm" : "md";
|
|
67
|
+
const leftIcon = isLoading ? /* @__PURE__ */ jsx(Spinner, { size: spinnerSize, tone: "inherit" }) : iconLeft || icon;
|
|
64
68
|
const classes = [
|
|
65
69
|
baseClass,
|
|
66
70
|
`${baseClass}--${resolvedVariant}`,
|
|
@@ -68,11 +72,11 @@ const Button = React.forwardRef(
|
|
|
68
72
|
`${baseClass}--${size}`,
|
|
69
73
|
isLoading && `${baseClass}--loading`,
|
|
70
74
|
glass && `${baseClass}--glass`,
|
|
75
|
+
text && label && leftIcon && `${baseClass}--icon-start`,
|
|
76
|
+
text && label && iconRight && `${baseClass}--icon-end`,
|
|
71
77
|
className
|
|
72
78
|
].filter(Boolean).join(" ");
|
|
73
79
|
const iconClass = "material-symbols-rounded";
|
|
74
|
-
const spinnerSize = size === "compact" ? "sm" : "md";
|
|
75
|
-
const leftIcon = isLoading ? /* @__PURE__ */ jsx(Spinner, { size: spinnerSize, tone: "inherit" }) : iconLeft || icon;
|
|
76
80
|
const renderIcon = (iconProp, position) => {
|
|
77
81
|
const positionClass = position === "right" ? ` ${baseClass}__icon--right` : "";
|
|
78
82
|
if (typeof iconProp === "string") {
|
|
@@ -7,7 +7,12 @@
|
|
|
7
7
|
/* Layout */
|
|
8
8
|
display: inline-flex; /* Hug content instead of stretch */
|
|
9
9
|
width: auto; /* Don't stretch to full width */
|
|
10
|
-
|
|
10
|
+
max-width: 100%;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/* A button never shrinks to fit: a label cut mid-word is unreadable. */
|
|
14
|
+
.ds-button-group > * {
|
|
15
|
+
flex: none;
|
|
11
16
|
}
|
|
12
17
|
|
|
13
18
|
/* ============================================
|
|
@@ -19,6 +24,10 @@
|
|
|
19
24
|
flex-direction: row;
|
|
20
25
|
gap: var(--gap-500); /* Figma: --gap/lg (20px) */
|
|
21
26
|
align-items: flex-start;
|
|
27
|
+
/* A row wider than its container wraps onto a second line at the tight
|
|
28
|
+
step, so it still reads as one group. */
|
|
29
|
+
flex-wrap: wrap;
|
|
30
|
+
row-gap: var(--gap-200);
|
|
22
31
|
}
|
|
23
32
|
|
|
24
33
|
/* ============================================
|