rift-ds 1.20.0 → 1.22.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/chat/AssistantTurn.js +4 -2
- package/chat/ChatLauncher.js +3 -0
- package/chat/ChatWidget.d.ts +3 -1
- package/chat/ChatWidget.js +13 -7
- package/chat/TurnContent.d.ts +3 -3
- package/chat/agentState.d.ts +14 -0
- package/chat/agentState.js +29 -0
- package/chat/artifacts.d.ts +5 -0
- package/chat/artifacts.js +3 -1
- package/chat/index.d.ts +1 -0
- package/chat/index.js +2 -0
- package/chat/server.js +5 -0
- package/chat/types.d.ts +12 -2
- package/chat/useChat.js +16 -5
- package/components/Composer/Composer.css +21 -18
- package/components/Composer/Composer.d.ts +4 -4
- package/components/Composer/Composer.js +3 -2
- package/components/DataTable/DataTable.js +64 -29
- package/components/DataTable/tableContext.d.ts +2 -0
- package/components/TableToolbar/TableToolbar.js +7 -4
- package/components/ThemeToggle/colorMode.d.ts +10 -0
- package/components/ThemeToggle/colorMode.js +19 -5
- package/package.json +1 -1
- package/tokens/motion.d.ts +2 -0
- package/tokens/motion.js +2 -0
package/chat/AssistantTurn.js
CHANGED
|
@@ -12,6 +12,7 @@ import { useChatWidget } from "./context.js";
|
|
|
12
12
|
import { DOCK_QUERY } from "./queries.js";
|
|
13
13
|
import { FollowupSuggestions } from "./FollowupSuggestions.js";
|
|
14
14
|
import { ResponseActions } from "./ResponseActions.js";
|
|
15
|
+
import { turnCards } from "./artifacts.js";
|
|
15
16
|
import { TurnCard } from "./TurnContent.js";
|
|
16
17
|
import { TurnQuestion } from "./TurnQuestion.js";
|
|
17
18
|
const CodeBlockLabelsContext = createContext(void 0);
|
|
@@ -60,7 +61,8 @@ function AssistantTurn({
|
|
|
60
61
|
const durationSeconds = live ? live.durationSeconds : turn?.durationSeconds;
|
|
61
62
|
const text = live ? live.text : turn?.text ?? "";
|
|
62
63
|
const content = live ? live.content : turn?.content;
|
|
63
|
-
const
|
|
64
|
+
const source = live ?? turn;
|
|
65
|
+
const cards = source ? turnCards(source) : [];
|
|
64
66
|
const { turns, live: liveTurn, freshFollowupsId } = useChatWidget();
|
|
65
67
|
const followupsPending = !!turn && turn.text !== "" && !!turn.exchangeId && !turn.followups && !turn.question && !liveTurn && turns[turns.length - 1]?.id === turn.id;
|
|
66
68
|
return /* @__PURE__ */ jsx(
|
|
@@ -92,7 +94,7 @@ function AssistantTurn({
|
|
|
92
94
|
}
|
|
93
95
|
),
|
|
94
96
|
content,
|
|
95
|
-
card
|
|
97
|
+
cards.map((card, index) => /* @__PURE__ */ jsx(TurnCard, { card }, index)),
|
|
96
98
|
text !== "" && /* @__PURE__ */ jsx(CodeBlockLabelsContext.Provider, { value: labels?.codeBlock, children: /* @__PURE__ */ jsx(Prose, { children: /* @__PURE__ */ jsx(ReactMarkdown, { remarkPlugins: [remarkGfm], components: markdownComponents, children: text }) }) }),
|
|
97
99
|
turn?.question && /* @__PURE__ */ jsx(TurnQuestion, { turn, labels: labels?.questionCard })
|
|
98
100
|
] })
|
package/chat/ChatLauncher.js
CHANGED
|
@@ -4,6 +4,7 @@ import { useSyncExternalStore, useLayoutEffect, useRef, useEffect, useState } fr
|
|
|
4
4
|
import { useScrollLock } from "../behaviors/useScrollLock.js";
|
|
5
5
|
import { AiButton } from "../components/AiButton/AiButton.js";
|
|
6
6
|
import { ChatWidget } from "./ChatWidget.js";
|
|
7
|
+
import { useChatAgentState } from "./agentState.js";
|
|
7
8
|
import { useChatWidget } from "./context.js";
|
|
8
9
|
import { isFloatDragStart, FLOAT_EDGE_GAP, FLOAT_MAX_SCALE, dockWidthFromDrag, clampFloatPosition } from "./placement.js";
|
|
9
10
|
import { DOCK_QUERY, TAKEOVER_QUERY } from "./queries.js";
|
|
@@ -48,6 +49,7 @@ function ChatLauncher({
|
|
|
48
49
|
surface = "raised"
|
|
49
50
|
}) {
|
|
50
51
|
const { open, setOpen, panelPhase, view, side, floating, returnFocusRef, send } = useChatWidget();
|
|
52
|
+
const agentState = useChatAgentState();
|
|
51
53
|
const launchSuggestion = (id) => {
|
|
52
54
|
const chip = summary?.chips?.find((c) => c.id === id);
|
|
53
55
|
if (!chip) return;
|
|
@@ -251,6 +253,7 @@ function ChatLauncher({
|
|
|
251
253
|
...aiButtonLabels,
|
|
252
254
|
label,
|
|
253
255
|
icon,
|
|
256
|
+
state: agentState,
|
|
254
257
|
"aria-expanded": false,
|
|
255
258
|
"aria-controls": panelId,
|
|
256
259
|
summary: summary ? {
|
package/chat/ChatWidget.d.ts
CHANGED
|
@@ -114,6 +114,8 @@ export interface ChatWidgetProps {
|
|
|
114
114
|
artifacts?: boolean;
|
|
115
115
|
/** The composer's context note, naming what the chat is looking at. Omit for none. The note's wording comes from `contextNote`. */
|
|
116
116
|
contextLabel?: string | null;
|
|
117
|
+
/** Where the context note sits: `above` the composer, or `inside` it, at the top of the shell, which brings the two-row composer. */
|
|
118
|
+
contextPlacement?: 'above' | 'inside';
|
|
117
119
|
/** The composer's context note, written from `contextLabel`. Defaults to `Looking at “<title>”`. */
|
|
118
120
|
contextNote?: (title: string) => string;
|
|
119
121
|
/** The second line of the drop overlay with attachments on, written from the limits: the largest file as text ("50 MB"), the most files per message, and the largest file in bytes for a host that formats sizes itself. Defaults to `Up to <maxSize> each · <maxFiles> files max`. */
|
|
@@ -226,4 +228,4 @@ export interface ChatWidgetProps {
|
|
|
226
228
|
* a stage card, a whole page). It reads all of its state from ChatProvider,
|
|
227
229
|
* so the conversation is the same object wherever it shows.
|
|
228
230
|
*/
|
|
229
|
-
export declare function ChatWidget({ fullscreenEnabled, closeEnabled, placementEnabled, compact, phone, title, flow, placeholder, questionsPlaceholder, showStarters, logo, tagline, starters: startersInput, startersKey, composerActions, models, defaultModel, lockedModelDescription, fileAttachments, maxAttachments, maxAttachmentBytes, mentions, threads, threadsProps, tabs, aside, agent, artifacts, contextLabel, contextNote, 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, tabsProps, composerLabels, attachmentDropZoneLabels, attachmentGroupLabels, chatThreadLabels, modelPickerLabels, artifactPanelLabels, agentRailLabels, questionCardLabels, questionSummaryLabels, codeBlockLabels, promptSuggestionsLabels, }: ChatWidgetProps): import("react").JSX.Element;
|
|
231
|
+
export declare function ChatWidget({ fullscreenEnabled, closeEnabled, placementEnabled, compact, phone, title, flow, placeholder, questionsPlaceholder, showStarters, logo, tagline, starters: startersInput, startersKey, composerActions, models, defaultModel, lockedModelDescription, fileAttachments, maxAttachments, maxAttachmentBytes, mentions, threads, threadsProps, tabs, aside, agent, artifacts, 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, tabsProps, composerLabels, attachmentDropZoneLabels, attachmentGroupLabels, chatThreadLabels, modelPickerLabels, artifactPanelLabels, agentRailLabels, questionCardLabels, questionSummaryLabels, codeBlockLabels, promptSuggestionsLabels, }: ChatWidgetProps): import("react").JSX.Element;
|
package/chat/ChatWidget.js
CHANGED
|
@@ -16,7 +16,7 @@ import { ModelPicker } from "../components/ModelPicker/ModelPicker.js";
|
|
|
16
16
|
import { PromptSuggestions } from "../components/PromptSuggestions/PromptSuggestions.js";
|
|
17
17
|
import { MOTION_SUGGESTIONS_THINK_MS, MOTION_SCROLL_SETTLE_MS } from "../tokens/motion.js";
|
|
18
18
|
import { AssistantTurn } from "./AssistantTurn.js";
|
|
19
|
-
import { cardArtifact } from "./artifacts.js";
|
|
19
|
+
import { turnCards, cardArtifact } from "./artifacts.js";
|
|
20
20
|
import { ChatAgentPane } from "./ChatAgentPane.js";
|
|
21
21
|
import { ChatArtifactPane } from "./ChatArtifactPane.js";
|
|
22
22
|
import { ChatTabs } from "./ChatTabs.js";
|
|
@@ -72,6 +72,7 @@ function ChatWidget({
|
|
|
72
72
|
artifacts = false,
|
|
73
73
|
contextLabel,
|
|
74
74
|
contextNote = defaultContextNote,
|
|
75
|
+
contextPlacement = "above",
|
|
75
76
|
attachHint: attachHintText = defaultAttachHint,
|
|
76
77
|
greetings,
|
|
77
78
|
placementLabels,
|
|
@@ -175,6 +176,7 @@ function ChatWidget({
|
|
|
175
176
|
const lockedValues = modelPolicy?.locked ?? [];
|
|
176
177
|
const pick = chosenModel && !lockedValues.includes(chosenModel) ? chosenModel : null;
|
|
177
178
|
const pickerValue = pick ?? modelPolicy?.default ?? defaultModel ?? models?.[0]?.value;
|
|
179
|
+
const composerHasActions = fileAttachments || Boolean(composerActions) || (models?.length ?? 0) > 0 || Boolean(contextLabel) && contextPlacement === "inside";
|
|
178
180
|
const pickerModels = (models ?? []).map((option) => ({
|
|
179
181
|
value: option.value,
|
|
180
182
|
label: option.label,
|
|
@@ -309,8 +311,11 @@ function ChatWidget({
|
|
|
309
311
|
};
|
|
310
312
|
const latestArtifact = useMemo(() => {
|
|
311
313
|
for (let index = turns.length - 1; index >= 0; index -= 1) {
|
|
312
|
-
const
|
|
313
|
-
|
|
314
|
+
const cards = turnCards(turns[index]);
|
|
315
|
+
for (let card = cards.length - 1; card >= 0; card -= 1) {
|
|
316
|
+
const found = cardArtifact(cards[card]);
|
|
317
|
+
if (found) return found;
|
|
318
|
+
}
|
|
314
319
|
}
|
|
315
320
|
return null;
|
|
316
321
|
}, [turns]);
|
|
@@ -321,7 +326,7 @@ function ChatWidget({
|
|
|
321
326
|
}, [asideWide]);
|
|
322
327
|
useEffect(() => {
|
|
323
328
|
if (!artifacts) return;
|
|
324
|
-
const carrying = turns.filter((turn) =>
|
|
329
|
+
const carrying = turns.filter((turn) => turnCards(turn).some((card) => cardArtifact(card)));
|
|
325
330
|
if (seenArtifactTurns.current === null) {
|
|
326
331
|
seenArtifactTurns.current = new Set(carrying.map((turn) => turn.id));
|
|
327
332
|
return;
|
|
@@ -329,7 +334,7 @@ function ChatWidget({
|
|
|
329
334
|
for (const turn of carrying) {
|
|
330
335
|
if (seenArtifactTurns.current.has(turn.id)) continue;
|
|
331
336
|
seenArtifactTurns.current.add(turn.id);
|
|
332
|
-
const arrived =
|
|
337
|
+
const arrived = turnCards(turn).map((card) => cardArtifact(card)).filter(Boolean).pop();
|
|
333
338
|
if (arrived && asideWideRef.current) openArtifact(arrived);
|
|
334
339
|
}
|
|
335
340
|
}, [artifacts, turns, openArtifact]);
|
|
@@ -571,7 +576,7 @@ function ChatWidget({
|
|
|
571
576
|
role: "user",
|
|
572
577
|
attachments: turn.attachments ? /* @__PURE__ */ jsx(AttachmentGroup, { ...attachmentGroupLabels, align: "end", items: turn.attachments }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
573
578
|
turn.content,
|
|
574
|
-
turn.card
|
|
579
|
+
turnCards(turn).map((card, index) => /* @__PURE__ */ jsx(TurnCard, { card }, index))
|
|
575
580
|
] }),
|
|
576
581
|
children: turn.reply ? /* @__PURE__ */ jsx(ReplyBody, { reply: turn.reply, text: turn.text, missingLabel: questionSummaryLabels?.missingLabel }) : mentions && turn.text ? /* @__PURE__ */ jsx(MentionText, { text: turn.text, sources: mentions }) : turn.text
|
|
577
582
|
},
|
|
@@ -597,6 +602,7 @@ function ChatWidget({
|
|
|
597
602
|
placeholder: questionsOpen ? questionsPlaceholder : placeholder,
|
|
598
603
|
disabled: questionsOpen,
|
|
599
604
|
sendLabel,
|
|
605
|
+
inline: composerHasActions ? false : "chat",
|
|
600
606
|
aiGlow: true,
|
|
601
607
|
value: draft,
|
|
602
608
|
onValueChange: setDraft,
|
|
@@ -605,7 +611,7 @@ function ChatWidget({
|
|
|
605
611
|
onStop: stop,
|
|
606
612
|
context: contextLabel ? contextNote(contextLabel) : void 0,
|
|
607
613
|
contextIcon: "description",
|
|
608
|
-
contextPlacement
|
|
614
|
+
contextPlacement,
|
|
609
615
|
mentions,
|
|
610
616
|
...fileAttachments ? {
|
|
611
617
|
files: queue.items,
|
package/chat/TurnContent.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ChatCard } from './types';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
* renderer draws nothing
|
|
5
|
-
*
|
|
3
|
+
* One of a turn's cards, drawn through the provider's renderers. A kind with
|
|
4
|
+
* no renderer draws nothing, so an unknown kind degrades to the words alone,
|
|
5
|
+
* or to nothing on a reply that is only a card. The one
|
|
6
6
|
* built-in kind is the artifact, drawn as its tile unless the host has
|
|
7
7
|
* taken the kind over with a renderer of its own.
|
|
8
8
|
*/
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AgentStatusState } from '../components/AgentStatus/AgentStatusPatterns';
|
|
2
|
+
/**
|
|
3
|
+
* What the agent is doing right now, in AgentStatus's vocabulary, for whatever
|
|
4
|
+
* opens the chat: pass it to an AiButton's `state`, so a reply keeps showing
|
|
5
|
+
* its progress on the button after the panel is closed. Read it under a
|
|
6
|
+
* ChatProvider, from something that stays mounted while the panel is open, so
|
|
7
|
+
* the end of a reply is only reported once.
|
|
8
|
+
*
|
|
9
|
+
* `thinking` until the first words, `working` once words or rich content are
|
|
10
|
+
* arriving, `waiting` while a question stands unanswered, then `done` or
|
|
11
|
+
* `error` for a beat as a reply ends. A reply the visitor stopped, or a chat
|
|
12
|
+
* they reset, goes straight back to `idle`.
|
|
13
|
+
*/
|
|
14
|
+
export declare function useChatAgentState(): AgentStatusState;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useState, useEffect } from "react";
|
|
3
|
+
import { MOTION_FEEDBACK_RESET_MS } from "../tokens/motion.js";
|
|
4
|
+
import { useChatWidget } from "./context.js";
|
|
5
|
+
function useChatAgentState() {
|
|
6
|
+
const { live, turns } = useChatWidget();
|
|
7
|
+
const [ended, setEnded] = useState(null);
|
|
8
|
+
const last = turns[turns.length - 1];
|
|
9
|
+
const inFlight = live !== null;
|
|
10
|
+
const [wasInFlight, setWasInFlight] = useState(inFlight);
|
|
11
|
+
if (wasInFlight !== inFlight) {
|
|
12
|
+
setWasInFlight(inFlight);
|
|
13
|
+
const reported = !inFlight && last?.role === "assistant" && last.outcome !== "stopped";
|
|
14
|
+
setEnded(reported ? last.outcome === "failed" ? "error" : "done" : null);
|
|
15
|
+
}
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
if (!ended) return;
|
|
18
|
+
const timer = setTimeout(() => setEnded(null), MOTION_FEEDBACK_RESET_MS);
|
|
19
|
+
return () => clearTimeout(timer);
|
|
20
|
+
}, [ended]);
|
|
21
|
+
if (live) {
|
|
22
|
+
return live.phase === "thinking" && !live.content && !live.cards?.length ? "thinking" : "working";
|
|
23
|
+
}
|
|
24
|
+
if (last?.role === "assistant" && last.question && !last.answers) return "waiting";
|
|
25
|
+
return ended ?? "idle";
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
useChatAgentState
|
|
29
|
+
};
|
package/chat/artifacts.d.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { ChatArtifact, ChatCard } from './types';
|
|
2
2
|
/** The artifact a card carries, or null when it is some other kind of card. */
|
|
3
3
|
export declare const cardArtifact: (card: ChatCard | undefined) => ChatArtifact | null;
|
|
4
|
+
/** The cards a turn draws: all it carried, or the one set by hand. */
|
|
5
|
+
export declare const turnCards: (turn: {
|
|
6
|
+
card?: ChatCard;
|
|
7
|
+
cards?: ChatCard[];
|
|
8
|
+
}) => ChatCard[];
|
|
4
9
|
/** Wraps an artifact as the card a transport sends. */
|
|
5
10
|
export declare const artifactCard: (artifact: ChatArtifact) => ChatCard;
|
package/chat/artifacts.js
CHANGED
|
@@ -4,11 +4,13 @@ const isArtifact = (data) => {
|
|
|
4
4
|
return typeof candidate === "object" && candidate !== null && typeof candidate.id === "string" && typeof candidate.title === "string" && typeof candidate.kind === "string";
|
|
5
5
|
};
|
|
6
6
|
const cardArtifact = (card) => card?.kind === ARTIFACT_CARD_KIND && isArtifact(card.data) ? card.data : null;
|
|
7
|
+
const turnCards = (turn) => turn.cards ?? (turn.card ? [turn.card] : []);
|
|
7
8
|
const artifactCard = (artifact) => ({
|
|
8
9
|
kind: ARTIFACT_CARD_KIND,
|
|
9
10
|
data: artifact
|
|
10
11
|
});
|
|
11
12
|
export {
|
|
12
13
|
artifactCard,
|
|
13
|
-
cardArtifact
|
|
14
|
+
cardArtifact,
|
|
15
|
+
turnCards
|
|
14
16
|
};
|
package/chat/index.d.ts
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
export { ChatProvider, type ChatProviderProps } from './ChatProvider';
|
|
17
17
|
export { ChatWidget, type ChatWidgetProps, type ChatAgentOptions, type RailSlot } from './ChatWidget';
|
|
18
18
|
export { ChatLauncher, CHAT_PANEL_ID, type ChatLauncherProps } from './ChatLauncher';
|
|
19
|
+
export { useChatAgentState } from './agentState';
|
|
19
20
|
export { ChatThreads, type ChatThreadsProps } from './ChatThreads';
|
|
20
21
|
export { ChatTabs, type ChatTabsProps } from './ChatTabs';
|
|
21
22
|
export { ChatAgentPane, type ChatAgentPaneProps } from './ChatAgentPane';
|
package/chat/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ChatProvider } from "./ChatProvider.js";
|
|
2
2
|
import { ChatWidget } from "./ChatWidget.js";
|
|
3
3
|
import { CHAT_PANEL_ID, ChatLauncher } from "./ChatLauncher.js";
|
|
4
|
+
import { useChatAgentState } from "./agentState.js";
|
|
4
5
|
import { ChatThreads } from "./ChatThreads.js";
|
|
5
6
|
import { ChatTabs } from "./ChatTabs.js";
|
|
6
7
|
import { ChatAgentPane } from "./ChatAgentPane.js";
|
|
@@ -95,6 +96,7 @@ export {
|
|
|
95
96
|
serverGreeting,
|
|
96
97
|
subscribeClock,
|
|
97
98
|
useChat,
|
|
99
|
+
useChatAgentState,
|
|
98
100
|
useChatWidget,
|
|
99
101
|
useTakeoverViewport,
|
|
100
102
|
useThreads
|
package/chat/server.js
CHANGED
|
@@ -252,6 +252,7 @@ function createChatHandler(options) {
|
|
|
252
252
|
let final;
|
|
253
253
|
for (let call = 0; ; call += 1) {
|
|
254
254
|
const lastCall = call === maxModelCalls - 1;
|
|
255
|
+
let passWroteText = false;
|
|
255
256
|
const stream = client.messages.stream(
|
|
256
257
|
{
|
|
257
258
|
model: serving.id,
|
|
@@ -277,7 +278,11 @@ function createChatHandler(options) {
|
|
|
277
278
|
reasoning.close();
|
|
278
279
|
streamedText = true;
|
|
279
280
|
firstTextMs = Date.now() - startedAt;
|
|
281
|
+
} else if (!passWroteText && answerText !== "") {
|
|
282
|
+
answerText += "\n\n";
|
|
283
|
+
send({ type: "delta", text: "\n\n" });
|
|
280
284
|
}
|
|
285
|
+
passWroteText = true;
|
|
281
286
|
answerText += event.delta.text;
|
|
282
287
|
send({ type: "delta", text: event.delta.text });
|
|
283
288
|
} else if (event.delta.type === "thinking_delta") {
|
package/chat/types.d.ts
CHANGED
|
@@ -219,9 +219,15 @@ export interface ChatTurn {
|
|
|
219
219
|
content?: ReactNode;
|
|
220
220
|
/**
|
|
221
221
|
* Rich content rendered with the turn through the provider's `renderers`,
|
|
222
|
-
* carried from a transport's `card` event. Drawn where `content` is
|
|
222
|
+
* carried from a transport's `card` event. Drawn where `content` is, and
|
|
223
|
+
* enough on its own: a reply may be a card with no text. With several, this
|
|
224
|
+
* is the latest.
|
|
223
225
|
*/
|
|
224
226
|
card?: ChatCard;
|
|
227
|
+
/** Every card the reply carried, in arrival order. Absent on a turn set by hand with `card`, which draws that one. */
|
|
228
|
+
cards?: ChatCard[];
|
|
229
|
+
/** How the reply ended, when it did not simply finish: `failed` for a failure the visitor was shown, `stopped` when they stopped it. */
|
|
230
|
+
outcome?: 'failed' | 'stopped';
|
|
225
231
|
/**
|
|
226
232
|
* Questions this assistant turn asks, drawn under it as a QuestionCard in
|
|
227
233
|
* place of follow-ups. Carried from a transport's `question` event.
|
|
@@ -270,8 +276,12 @@ export interface LiveResponse {
|
|
|
270
276
|
followups?: string[];
|
|
271
277
|
/** The transport's `content` event, drawn on the live reply and carried into the committed turn. */
|
|
272
278
|
content?: ReactNode;
|
|
273
|
-
/** The transport's `card` event, drawn on the live reply and carried into the committed turn. */
|
|
279
|
+
/** The transport's latest `card` event, drawn on the live reply and carried into the committed turn. */
|
|
274
280
|
card?: ChatCard;
|
|
281
|
+
/** Every `card` event so far, in arrival order, carried into the committed turn. */
|
|
282
|
+
cards?: ChatCard[];
|
|
283
|
+
/** How the reply ended, when it did not simply finish, carried into the committed turn. */
|
|
284
|
+
outcome?: 'failed' | 'stopped';
|
|
275
285
|
/** Carried from the transport's `question` event into the committed turn. */
|
|
276
286
|
question?: ChatQuestionSet;
|
|
277
287
|
}
|
package/chat/useChat.js
CHANGED
|
@@ -52,6 +52,8 @@ function useChat(transport, placeholders = DEFAULT_PLACEHOLDER_COPY) {
|
|
|
52
52
|
followups: finished.followups,
|
|
53
53
|
content: finished.content,
|
|
54
54
|
card: finished.card,
|
|
55
|
+
cards: finished.cards,
|
|
56
|
+
outcome: finished.outcome,
|
|
55
57
|
question: finished.question,
|
|
56
58
|
durationSeconds: finished.durationSeconds ?? Math.max(1, Math.round((Date.now() - startedAt) / 1e3))
|
|
57
59
|
}
|
|
@@ -128,7 +130,7 @@ function useChat(transport, placeholders = DEFAULT_PLACEHOLDER_COPY) {
|
|
|
128
130
|
update({ ...current, content: event.node });
|
|
129
131
|
break;
|
|
130
132
|
case "card":
|
|
131
|
-
update({ ...current, card: event.card });
|
|
133
|
+
update({ ...current, card: event.card, cards: [...current.cards ?? [], event.card] });
|
|
132
134
|
break;
|
|
133
135
|
case "question": {
|
|
134
136
|
const set = sanitizeQuestionSet(event.set, `${current.id}-questions`);
|
|
@@ -158,7 +160,8 @@ function useChat(transport, placeholders = DEFAULT_PLACEHOLDER_COPY) {
|
|
|
158
160
|
current = {
|
|
159
161
|
...current,
|
|
160
162
|
phase: "streaming",
|
|
161
|
-
durationSeconds: current.durationSeconds ?? 1
|
|
163
|
+
durationSeconds: current.durationSeconds ?? 1,
|
|
164
|
+
outcome: event.type === "error" ? "failed" : current.outcome
|
|
162
165
|
};
|
|
163
166
|
reveal.showWhole(event.type === "notice" ? event.text : event.message);
|
|
164
167
|
break;
|
|
@@ -174,21 +177,29 @@ function useChat(transport, placeholders = DEFAULT_PLACEHOLDER_COPY) {
|
|
|
174
177
|
}
|
|
175
178
|
reveal.cancel();
|
|
176
179
|
if (generation !== generationRef.current) return;
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
+
const stopped = controller.signal.aborted;
|
|
181
|
+
if (stopped) current = { ...current, outcome: "stopped" };
|
|
182
|
+
if (current.text !== "") {
|
|
180
183
|
commit(current, startedAt, current.text);
|
|
184
|
+
} else if (current.content || current.cards?.length || current.question) {
|
|
185
|
+
commit(current, startedAt, null);
|
|
186
|
+
} else if (stopped) {
|
|
187
|
+
commit({ ...current, text: placeholders.stopped }, startedAt, null);
|
|
188
|
+
} else {
|
|
189
|
+
commit({ ...current, text: placeholders.empty, outcome: "failed" }, startedAt, null);
|
|
181
190
|
}
|
|
182
191
|
} catch (err) {
|
|
183
192
|
reveal.flush();
|
|
184
193
|
if (generation !== generationRef.current) ;
|
|
185
194
|
else if (controller.signal.aborted) {
|
|
195
|
+
current = { ...current, outcome: "stopped" };
|
|
186
196
|
if (current.text === "") {
|
|
187
197
|
commit({ ...current, text: placeholders.stopped }, startedAt, null);
|
|
188
198
|
} else {
|
|
189
199
|
commit(current, startedAt, current.text);
|
|
190
200
|
}
|
|
191
201
|
} else {
|
|
202
|
+
current = { ...current, outcome: "failed" };
|
|
192
203
|
if (current.text === "") {
|
|
193
204
|
commit({ ...current, text: placeholders.failed }, startedAt, null);
|
|
194
205
|
} else {
|
|
@@ -465,7 +465,7 @@
|
|
|
465
465
|
color: var(--color-input-text-primary);
|
|
466
466
|
/* Growth cap: the shell owns the block padding, so the cap is rows × line-height.
|
|
467
467
|
--ds-composer-max-rows is set inline from the maxRows prop. */
|
|
468
|
-
max-height: calc(var(--ds-composer-max-rows,
|
|
468
|
+
max-height: calc(var(--ds-composer-max-rows, 12) * var(--font-paragraph-line-height));
|
|
469
469
|
overflow-y: auto;
|
|
470
470
|
}
|
|
471
471
|
|
|
@@ -635,35 +635,22 @@
|
|
|
635
635
|
}
|
|
636
636
|
|
|
637
637
|
/* ============================================
|
|
638
|
-
COMPACT: the
|
|
638
|
+
COMPACT: the mini composer's smaller text. Its height and button are in the
|
|
639
|
+
INLINE section below; no other composer takes this density.
|
|
639
640
|
============================================ */
|
|
640
641
|
.ds-composer--compact {
|
|
641
|
-
--ds-composer-send-size: var(--control-height-compact);
|
|
642
642
|
--ds-composer-text-inset: var(--padding-300);
|
|
643
|
-
/* Concentric on this density's tighter ring. */
|
|
644
|
-
--ds-composer-radius: calc(
|
|
645
|
-
min(var(--radius-pill), var(--ds-composer-send-size) / 2) + var(--padding-100) + var(--border-025)
|
|
646
|
-
);
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
.ds-composer--compact .ds-composer__content {
|
|
650
|
-
padding-block: var(--padding-200) var(--padding-100);
|
|
651
|
-
height: calc(var(--ds-composer-text-height, var(--font-paragraph-sm-line-height)) + var(--padding-200) + var(--padding-100));
|
|
652
643
|
}
|
|
653
644
|
|
|
654
645
|
.ds-composer--compact .ds-composer__textarea {
|
|
655
646
|
font-size: var(--font-paragraph-sm-size);
|
|
656
647
|
line-height: var(--font-paragraph-sm-line-height);
|
|
657
648
|
letter-spacing: var(--font-paragraph-sm-letter-spacing);
|
|
658
|
-
max-height: calc(var(--ds-composer-max-rows,
|
|
659
|
-
}
|
|
660
|
-
|
|
661
|
-
.ds-composer--compact .ds-composer__footer {
|
|
662
|
-
padding: var(--padding-100);
|
|
649
|
+
max-height: calc(var(--ds-composer-max-rows, 12) * var(--font-paragraph-sm-line-height));
|
|
663
650
|
}
|
|
664
651
|
|
|
665
652
|
/* ============================================
|
|
666
|
-
INLINE: one row at the control height
|
|
653
|
+
INLINE: one row at the control height, growing up to `maxRows`, the send
|
|
667
654
|
button on the text's line.
|
|
668
655
|
The shell is an input here, so it does not float, and the button sits
|
|
669
656
|
inside the height, concentric on a thinner ring.
|
|
@@ -745,3 +732,19 @@
|
|
|
745
732
|
width: var(--ds-composer-send-size);
|
|
746
733
|
height: var(--ds-composer-send-size);
|
|
747
734
|
}
|
|
735
|
+
|
|
736
|
+
/* INLINE IN A CHAT: the same one row, built out from a full-size send button
|
|
737
|
+
rather than down from a control height, because this is the page's main
|
|
738
|
+
input and not a field lined up with others. */
|
|
739
|
+
.ds-composer--inline-chat {
|
|
740
|
+
--ds-composer-ring: var(--padding-150);
|
|
741
|
+
--ds-composer-send-size: var(--control-height-default);
|
|
742
|
+
--ds-composer-control: calc(var(--ds-composer-send-size) + var(--ds-composer-ring) * 2 + var(--border-025) * 2);
|
|
743
|
+
--ds-composer-radius: calc(
|
|
744
|
+
min(var(--radius-pill), var(--ds-composer-send-size) / 2) + var(--ds-composer-ring) + var(--border-025)
|
|
745
|
+
);
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
.ds-composer--inline-chat .ds-composer__footer {
|
|
749
|
+
padding: var(--ds-composer-ring);
|
|
750
|
+
}
|
|
@@ -32,11 +32,11 @@ type ComposerOwnProps = {
|
|
|
32
32
|
streaming?: boolean;
|
|
33
33
|
/** Fires when the stop button is pressed while `streaming`. */
|
|
34
34
|
onStop?: () => void;
|
|
35
|
-
/** The density, matching a table's or a bar's: `compact`
|
|
35
|
+
/** The mini composer's density (`inline` as `true`), matching a table's or a bar's: `compact` takes the smaller text, height and button. Every other composer has the one size, so it ignores this. */
|
|
36
36
|
size?: 'default' | 'compact';
|
|
37
|
-
/** One row with the send button on the text's line
|
|
38
|
-
inline?: boolean;
|
|
39
|
-
/** Growth cap in text rows before the textarea scrolls internally. Defaults to
|
|
37
|
+
/** One row with the send button on the text's line. `true` makes the shell exactly `size`'s control height, so it lines up with an Input or a table's toolbar: the mini composer, for AI input inside other content such as a table, never for a chat. `chat` gives the button a full-size control and room around it: for a chat with nothing to seat in a footer. Above one row (`maxRows`), typing grows the shell with the send button held in the bottom corner. A placeholder stays on one line and ends in an ellipsis. */
|
|
38
|
+
inline?: boolean | 'chat';
|
|
39
|
+
/** Growth cap in text rows before the textarea scrolls internally. Defaults to 12 in a chat composer, or 3 in the mini composer. */
|
|
40
40
|
maxRows?: number;
|
|
41
41
|
/**
|
|
42
42
|
* While focused, the shell wears AiButton's slowly rotating gradient ring
|
|
@@ -36,7 +36,7 @@ const Composer = React.forwardRef(
|
|
|
36
36
|
onStop,
|
|
37
37
|
size = "default",
|
|
38
38
|
inline = false,
|
|
39
|
-
maxRows = inline ?
|
|
39
|
+
maxRows = inline === true ? 3 : 12,
|
|
40
40
|
aiGlow = false,
|
|
41
41
|
context,
|
|
42
42
|
contextIcon,
|
|
@@ -364,8 +364,9 @@ const Composer = React.forwardRef(
|
|
|
364
364
|
const classes = [
|
|
365
365
|
baseClass,
|
|
366
366
|
aiGlow ? `${baseClass}--ai-glow` : "",
|
|
367
|
-
size === "compact" ? `${baseClass}--compact` : "",
|
|
367
|
+
inline === true && size === "compact" ? `${baseClass}--compact` : "",
|
|
368
368
|
inline ? `${baseClass}--inline` : "",
|
|
369
|
+
inline === "chat" ? `${baseClass}--inline-chat` : "",
|
|
369
370
|
streaming ? `${baseClass}--streaming` : "",
|
|
370
371
|
disabled ? `${baseClass}--disabled` : "",
|
|
371
372
|
dragging ? `${baseClass}--dragging` : "",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
3
|
-
import React, { useMemo, useState, useEffect, useRef, useId, useLayoutEffect, useCallback } from "react";
|
|
3
|
+
import React, { useMemo, useState, useEffect, useRef, useId, useLayoutEffect, useDeferredValue, useCallback } from "react";
|
|
4
4
|
import { useTable, tableFeatures, columnVisibilityFeature, columnPinningFeature, columnOrderingFeature, rowSelectionFeature, globalFilteringFeature, columnFilteringFeature, rowSortingFeature, createFilteredRowModel, createSortedRowModel } from "@tanstack/react-table";
|
|
5
5
|
import { DropdownMenu } from "../DropdownMenu/DropdownMenu.js";
|
|
6
6
|
import { Dropdown } from "../Dropdown/Dropdown.js";
|
|
@@ -125,6 +125,17 @@ const valueComparator = (collator) => (a, b) => {
|
|
|
125
125
|
if (typeof a === "boolean" && typeof b === "boolean") return Number(a) - Number(b);
|
|
126
126
|
return collator.compare(String(a), String(b));
|
|
127
127
|
};
|
|
128
|
+
const SEARCH_TEXT = /* @__PURE__ */ new WeakMap();
|
|
129
|
+
const searchTextOf = (rows, row) => {
|
|
130
|
+
let texts = SEARCH_TEXT.get(rows);
|
|
131
|
+
if (!texts) SEARCH_TEXT.set(rows, texts = /* @__PURE__ */ new WeakMap());
|
|
132
|
+
let text = texts.get(row);
|
|
133
|
+
if (text === void 0) {
|
|
134
|
+
text = Object.values(row.values).filter((cell) => cell != null).map(String).join("\0").toLowerCase();
|
|
135
|
+
texts.set(row, text);
|
|
136
|
+
}
|
|
137
|
+
return text;
|
|
138
|
+
};
|
|
128
139
|
const ENGINE_FEATURES = tableFeatures({
|
|
129
140
|
rowSortingFeature,
|
|
130
141
|
sortedRowModel: createSortedRowModel(),
|
|
@@ -503,7 +514,7 @@ function DataTable({
|
|
|
503
514
|
}),
|
|
504
515
|
[columnKeys, compareValues]
|
|
505
516
|
);
|
|
506
|
-
const needle = search.trim().toLowerCase();
|
|
517
|
+
const needle = useDeferredValue(search.trim().toLowerCase());
|
|
507
518
|
const sortingKey = JSON.stringify(
|
|
508
519
|
currentSorts.filter((entry) => byKey.has(entry.key)).map((entry) => ({ id: entry.key, desc: entry.direction === "desc" }))
|
|
509
520
|
);
|
|
@@ -540,18 +551,21 @@ function DataTable({
|
|
|
540
551
|
rowSelection: engineSelection
|
|
541
552
|
},
|
|
542
553
|
/* The search matches any raw value on the row, displayed or not, case
|
|
543
|
-
insensitively, as it always has:
|
|
544
|
-
|
|
545
|
-
|
|
554
|
+
insensitively, as it always has: the test reads the whole row, so it
|
|
555
|
+
runs once, from one column. The engine asks once per eligible column
|
|
556
|
+
until one passes, so with every column eligible a row that does not
|
|
557
|
+
match reads all its values once per column. */
|
|
558
|
+
getColumnCanGlobalFilter: (column) => column.id === columns[0]?.key,
|
|
546
559
|
globalFilterFn: (row, _columnId, value) => {
|
|
547
|
-
|
|
548
|
-
return
|
|
549
|
-
(cell) => cell != null && String(cell).toLowerCase().includes(term)
|
|
550
|
-
);
|
|
560
|
+
if (row.columnFilters && Object.values(row.columnFilters).includes(false)) return false;
|
|
561
|
+
return searchTextOf(rows, row.original).includes(String(value ?? ""));
|
|
551
562
|
}
|
|
552
563
|
});
|
|
553
564
|
const engineRows = table.getSortedRowModel().rows;
|
|
554
|
-
const sortedRows =
|
|
565
|
+
const sortedRows = useMemo(
|
|
566
|
+
() => manual ? orderedRows : engineRows.map((row) => row.original),
|
|
567
|
+
[manual, orderedRows, engineRows]
|
|
568
|
+
);
|
|
555
569
|
const matchCount = manual ? Math.max(rowCountProp ?? rows.length, rows.length) : sortedRows.length;
|
|
556
570
|
const groupKey = groupingState.find((key) => byKey.get(key)?.groupable);
|
|
557
571
|
const groupCol = groupKey ? byKey.get(groupKey) : void 0;
|
|
@@ -597,7 +611,7 @@ function DataTable({
|
|
|
597
611
|
return;
|
|
598
612
|
}
|
|
599
613
|
announce(resultsLabel(matchCount), true);
|
|
600
|
-
}, [
|
|
614
|
+
}, [needle]);
|
|
601
615
|
const filtered = useRef(false);
|
|
602
616
|
const filtersKey = JSON.stringify(filters);
|
|
603
617
|
useEffect(() => {
|
|
@@ -615,7 +629,8 @@ function DataTable({
|
|
|
615
629
|
announce(pageAnnouncement(next, pageCount, first, last, matchCount));
|
|
616
630
|
};
|
|
617
631
|
const visibleIds = visibleRows.map((row) => row.id);
|
|
618
|
-
const
|
|
632
|
+
const selectedSet = new Set(currentSelection);
|
|
633
|
+
const selectedVisible = visibleIds.filter((id) => selectedSet.has(id));
|
|
619
634
|
const allVisibleSelected = visibleIds.length > 0 && selectedVisible.length === visibleIds.length;
|
|
620
635
|
const someVisibleSelected = selectedVisible.length > 0 && !allVisibleSelected;
|
|
621
636
|
const toggleAllVisible = (checked) => {
|
|
@@ -979,14 +994,29 @@ function DataTable({
|
|
|
979
994
|
}
|
|
980
995
|
});
|
|
981
996
|
};
|
|
997
|
+
const columnScanKey = columns.map((col) => [col.key, col.type ?? "", col.options ? "1" : ""].join("")).join("\0");
|
|
998
|
+
const columnScans = useMemo(() => {
|
|
999
|
+
const scans = /* @__PURE__ */ new Map();
|
|
1000
|
+
for (const spec of columnScanKey.split("\0")) {
|
|
1001
|
+
const [key, type, hasOptions] = spec.split("");
|
|
1002
|
+
const typedKind = type ? TYPE_DEFAULTS[type].filter : void 0;
|
|
1003
|
+
if (typedKind && (hasOptions || typedKind !== "enum" && typedKind !== "tags")) {
|
|
1004
|
+
scans.set(key, { kind: typedKind, choices: [] });
|
|
1005
|
+
continue;
|
|
1006
|
+
}
|
|
1007
|
+
const values = rows.map((row) => row.values[key]);
|
|
1008
|
+
const kind = typedKind ?? kindOf(values, Boolean(hasOptions));
|
|
1009
|
+
const choices = !hasOptions && (kind === "enum" || kind === "tags") ? [
|
|
1010
|
+
...new Set(
|
|
1011
|
+
values.flat().filter((value) => value != null && value !== "").map(String)
|
|
1012
|
+
)
|
|
1013
|
+
].sort((a, b) => collator.compare(a, b)).map((value) => ({ value, label: value })) : [];
|
|
1014
|
+
scans.set(key, { kind, choices });
|
|
1015
|
+
}
|
|
1016
|
+
return scans;
|
|
1017
|
+
}, [columnScanKey, rows, collator]);
|
|
982
1018
|
const toolbarColumns = columns.map((col) => {
|
|
983
|
-
const
|
|
984
|
-
const kind = col.type ? TYPE_DEFAULTS[col.type].filter : kindOf(values, Boolean(col.options));
|
|
985
|
-
const choices = col.options ?? (kind === "enum" || kind === "tags" ? [
|
|
986
|
-
...new Set(
|
|
987
|
-
values.flat().filter((value) => value != null && value !== "").map(String)
|
|
988
|
-
)
|
|
989
|
-
].sort((a, b) => collator.compare(a, b)).map((value) => ({ value, label: value })) : []);
|
|
1019
|
+
const { kind, choices } = columnScans.get(col.key);
|
|
990
1020
|
return {
|
|
991
1021
|
key: col.key,
|
|
992
1022
|
label: headerText(col),
|
|
@@ -997,12 +1027,13 @@ function DataTable({
|
|
|
997
1027
|
sortable: Boolean(col.sortable),
|
|
998
1028
|
groupable: Boolean(col.groupable),
|
|
999
1029
|
kind,
|
|
1000
|
-
options: choices
|
|
1030
|
+
options: col.options ?? choices
|
|
1001
1031
|
};
|
|
1002
1032
|
});
|
|
1003
1033
|
const [headerFilter, setHeaderFilter] = useState(null);
|
|
1004
1034
|
const [countClaimed, setCountClaimed] = useState(false);
|
|
1005
1035
|
const [selectionClaimed, setSelectionClaimed] = useState(false);
|
|
1036
|
+
const [commandLanding, setCommandLanding] = useState(false);
|
|
1006
1037
|
const openHeaderFilter = (key) => {
|
|
1007
1038
|
const existing = filters.find((filter2) => filter2.column === key);
|
|
1008
1039
|
if (existing) {
|
|
@@ -1089,6 +1120,7 @@ function DataTable({
|
|
|
1089
1120
|
reportedKey.current = currentKey;
|
|
1090
1121
|
viewCallback.current?.(JSON.parse(JSON.stringify(currentView)));
|
|
1091
1122
|
}, [currentKey]);
|
|
1123
|
+
const matchingIds = useMemo(() => sortedRows.map((row) => row.id), [sortedRows]);
|
|
1092
1124
|
const tableContext = {
|
|
1093
1125
|
columns: toolbarColumns,
|
|
1094
1126
|
filters,
|
|
@@ -1102,7 +1134,7 @@ function DataTable({
|
|
|
1102
1134
|
selectable,
|
|
1103
1135
|
selectedIds: currentSelection,
|
|
1104
1136
|
setSelectedIds: setSelection,
|
|
1105
|
-
matchingIds
|
|
1137
|
+
matchingIds,
|
|
1106
1138
|
size,
|
|
1107
1139
|
setSize,
|
|
1108
1140
|
shown: matchCount,
|
|
@@ -1122,7 +1154,8 @@ function DataTable({
|
|
|
1122
1154
|
setAllGroupsOpen: (open) => setCollapsedGroups(open ? [] : (groups ?? []).map((group) => group.key)),
|
|
1123
1155
|
view: currentView,
|
|
1124
1156
|
applyView,
|
|
1125
|
-
viewMatches: (view) => viewKey(fullView(view)) === currentKey
|
|
1157
|
+
viewMatches: (view) => viewKey(fullView(view)) === currentKey,
|
|
1158
|
+
setCommandLanding
|
|
1126
1159
|
};
|
|
1127
1160
|
const [menuKey, setMenuKey] = useState(null);
|
|
1128
1161
|
const menuItems = (key) => {
|
|
@@ -1727,6 +1760,7 @@ function DataTable({
|
|
|
1727
1760
|
loadMore.current = onLoadMore;
|
|
1728
1761
|
});
|
|
1729
1762
|
const rowCount = visibleRows.length;
|
|
1763
|
+
const pageRowSet = new Set(pageRows);
|
|
1730
1764
|
const scrollsInFrame = virtual || maxHeight !== void 0;
|
|
1731
1765
|
useEffect(() => {
|
|
1732
1766
|
const node = loadingRef.current;
|
|
@@ -1748,7 +1782,7 @@ function DataTable({
|
|
|
1748
1782
|
const expanded = !collapsedGroups.includes(group.key);
|
|
1749
1783
|
const label = groupLabel(group.key);
|
|
1750
1784
|
const ids = group.rows.map((row) => row.id);
|
|
1751
|
-
const chosen = ids.filter((id) =>
|
|
1785
|
+
const chosen = ids.filter((id) => selectedSet.has(id)).length;
|
|
1752
1786
|
const raw = group.rows[0]?.values[groupKey] ?? null;
|
|
1753
1787
|
return /* @__PURE__ */ jsxs("tr", { className: `ds-table__row ${baseClass}__group-row`, "data-group-row": "", children: [
|
|
1754
1788
|
utilityKeys.map((key) => {
|
|
@@ -1839,7 +1873,7 @@ function DataTable({
|
|
|
1839
1873
|
visibleKeys.map((key) => {
|
|
1840
1874
|
const col = byKey.get(key);
|
|
1841
1875
|
const pick = totalPick(col);
|
|
1842
|
-
const values = sortedRows.map((row) => row.values[key]);
|
|
1876
|
+
const values = pick === "none" ? [] : sortedRows.map((row) => row.values[key]);
|
|
1843
1877
|
const text = pick === "none" ? "" : typeof col.aggregate === "function" && !totalsState[key] ? col.aggregate(values, sortedRows) : resultText(col, calculate(pick, values));
|
|
1844
1878
|
const offered = TOTALS.filter((total) => !NUMERIC_TOTALS.has(total) || numericColumn(col));
|
|
1845
1879
|
return /* @__PURE__ */ jsx(
|
|
@@ -1887,7 +1921,7 @@ function DataTable({
|
|
|
1887
1921
|
] }) });
|
|
1888
1922
|
const columnCount = utilityKeys.length + visibleKeys.length + (layoutReady ? 1 : 0) + (showActions ? 1 : 0);
|
|
1889
1923
|
const bodyRow = (row, slot, part = "both") => {
|
|
1890
|
-
const isSelected = selectable &&
|
|
1924
|
+
const isSelected = selectable && selectedSet.has(row.id);
|
|
1891
1925
|
const name = rowName(row);
|
|
1892
1926
|
const expandedHere = Boolean(renderDetail) && expandedState.includes(row.id);
|
|
1893
1927
|
const detailId = `${tableId}-detail-${row.id}`;
|
|
@@ -2244,8 +2278,9 @@ function DataTable({
|
|
|
2244
2278
|
/* @__PURE__ */ jsx(Spinner, { size: "sm", tone: "neutral" }),
|
|
2245
2279
|
/* @__PURE__ */ jsx("span", { children: loadWords.loadingMore })
|
|
2246
2280
|
] }) }) });
|
|
2247
|
-
const firstLoad = loading && rows.length === 0 && !error;
|
|
2281
|
+
const firstLoad = (loading && rows.length === 0 || commandLanding) && !error;
|
|
2248
2282
|
const refreshing = loading && rows.length > 0;
|
|
2283
|
+
const searching = !manual && rows.length > 0 && search.trim().toLowerCase() !== needle;
|
|
2249
2284
|
const retryButton = onRetry && /* @__PURE__ */ jsx(Button, { variant: "secondary", tone: "neutral", size: "compact", iconLeft: "refresh", label: loadWords.retry, onClick: onRetry });
|
|
2250
2285
|
const skeletonRows = Array.from({ length: pageSize ?? 5 }, (_, index) => /* @__PURE__ */ jsxs("tr", { className: `ds-table__row ${baseClass}__skeleton-row`, "aria-hidden": "true", children: [
|
|
2251
2286
|
utilityKeys.map((key) => /* @__PURE__ */ jsx("td", { className: "ds-table__cell" }, key)),
|
|
@@ -2292,12 +2327,12 @@ function DataTable({
|
|
|
2292
2327
|
error && rows.length > 0 && /* @__PURE__ */ jsx(Banner, { variant: "error", title: loadWords.errorTitle, action: retryButton || void 0, className: `${baseClass}__banner`, children: error }),
|
|
2293
2328
|
firstLoad && /* @__PURE__ */ jsx("span", { className: "ds-visually-hidden", role: "status", children: loadWords.loading }),
|
|
2294
2329
|
visibleRows.length > 0 || firstLoad ? /* @__PURE__ */ jsxs(ScrollRegion, { className: `ds-table__wrapper ${baseClass}__frame`, style: frameStyle, onNode: setFrameEl, children: [
|
|
2295
|
-
refreshing && /* @__PURE__ */ jsx("div", { className: `${baseClass}__progress`, role: "progressbar", "aria-label": loadWords.loading }),
|
|
2330
|
+
(refreshing || searching) && /* @__PURE__ */ jsx("div", { className: `${baseClass}__progress`, role: "progressbar", "aria-label": loadWords.loading }),
|
|
2296
2331
|
/* @__PURE__ */ jsxs(
|
|
2297
2332
|
"table",
|
|
2298
2333
|
{
|
|
2299
2334
|
ref: setTableEl,
|
|
2300
|
-
"aria-busy": loading || void 0,
|
|
2335
|
+
"aria-busy": loading || commandLanding || searching || void 0,
|
|
2301
2336
|
className: tableClasses,
|
|
2302
2337
|
role: gridMode ? "grid" : stacked ? "table" : void 0,
|
|
2303
2338
|
"aria-rowcount": virtual ? virtualItems.length + 1 : void 0,
|
|
@@ -2332,7 +2367,7 @@ function DataTable({
|
|
|
2332
2367
|
}
|
|
2333
2368
|
)
|
|
2334
2369
|
] }) }),
|
|
2335
|
-
firstLoad ? /* @__PURE__ */ jsx("tbody", { className: "ds-table__body", children: skeletonRows }) : groups ? groups.map((group) => ({ group, onPage: group.rows.filter((row) =>
|
|
2370
|
+
firstLoad ? /* @__PURE__ */ jsx("tbody", { className: "ds-table__body", children: skeletonRows }) : groups ? groups.map((group) => ({ group, onPage: group.rows.filter((row) => pageRowSet.has(row)) })).filter(({ onPage }) => onPage.length > 0).map(({ group, onPage }) => /* @__PURE__ */ jsxs(
|
|
2336
2371
|
"tbody",
|
|
2337
2372
|
{
|
|
2338
2373
|
className: `ds-table__body ${baseClass}__group`,
|
|
@@ -76,6 +76,8 @@ export interface TableContextValue {
|
|
|
76
76
|
view: TableView;
|
|
77
77
|
applyView: (view: TableView) => void;
|
|
78
78
|
viewMatches: (view: TableView) => boolean;
|
|
79
|
+
/** Draws skeleton rows in the body while a toolbar command's answer lands. */
|
|
80
|
+
setCommandLanding: (landing: boolean) => void;
|
|
79
81
|
}
|
|
80
82
|
export declare const TableContext: import('react').Context<TableContextValue | null>;
|
|
81
83
|
/** The surrounding DataTable's state, or null outside one. */
|
|
@@ -24,7 +24,7 @@ import { parseDate, absoluteDate } from "../DataTable/columnTypes.js";
|
|
|
24
24
|
import "../../behaviors/visually-hidden.css";
|
|
25
25
|
import { DEFAULT_FILTER_LABELS, isComplete, VALUELESS, OPERATORS, valueText, newFilterId } from "../DataTable/filterModel.js";
|
|
26
26
|
import { useTableContext } from "../DataTable/tableContext.js";
|
|
27
|
-
import { MOTION_ACTION_DISMISS_MS } from "../../tokens/motion.js";
|
|
27
|
+
import { MOTION_TABLE_COMMAND_SKELETON_MS, MOTION_ACTION_DISMISS_MS } from "../../tokens/motion.js";
|
|
28
28
|
import { BREAKPOINT_PHONE_PX, BREAKPOINT_SHEET_PX, mediaBelow } from "../../tokens/breakpoints.js";
|
|
29
29
|
import "./TableToolbar.css";
|
|
30
30
|
import { mirrorClass } from "../../behaviors/direction.js";
|
|
@@ -140,7 +140,6 @@ function ToolbarPanel({
|
|
|
140
140
|
)
|
|
141
141
|
] });
|
|
142
142
|
}
|
|
143
|
-
const COMMAND_MAX_ROWS = 3;
|
|
144
143
|
function CommandRow({ command, table, labels, size, open, onClose, state, onStateChange }) {
|
|
145
144
|
const { toast, dismiss } = useToast();
|
|
146
145
|
const [text, setText] = useState("");
|
|
@@ -183,7 +182,11 @@ function CommandRow({ command, table, labels, size, open, onClose, state, onStat
|
|
|
183
182
|
if (running.signal.aborted) return;
|
|
184
183
|
const changed = Boolean(result.view) && JSON.stringify(result.view) !== JSON.stringify(before);
|
|
185
184
|
if (changed) {
|
|
185
|
+
latestTable.current.setCommandLanding(true);
|
|
186
186
|
latestTable.current.applyView(result.view);
|
|
187
|
+
await new Promise((resolve) => setTimeout(resolve, MOTION_TABLE_COMMAND_SKELETON_MS));
|
|
188
|
+
latestTable.current.setCommandLanding(false);
|
|
189
|
+
if (running.signal.aborted) return;
|
|
187
190
|
const id = `table-command-${Date.now()}`;
|
|
188
191
|
report({
|
|
189
192
|
id,
|
|
@@ -251,7 +254,6 @@ function CommandRow({ command, table, labels, size, open, onClose, state, onStat
|
|
|
251
254
|
Composer,
|
|
252
255
|
{
|
|
253
256
|
inline: true,
|
|
254
|
-
maxRows: COMMAND_MAX_ROWS,
|
|
255
257
|
size,
|
|
256
258
|
value: text,
|
|
257
259
|
onValueChange: setText,
|
|
@@ -639,7 +641,8 @@ const TableToolbar = React.forwardRef(
|
|
|
639
641
|
const commandTrigger = narrow ? /* @__PURE__ */ jsx(Tooltip, { content: labels.command, children: commandButtonDrawn }) : commandButtonDrawn;
|
|
640
642
|
const matching = table?.matchingIds ?? [];
|
|
641
643
|
const matchingCount = table?.matchingCount ?? matching.length;
|
|
642
|
-
const
|
|
644
|
+
const selectedSet = new Set(table?.selectedIds);
|
|
645
|
+
const allMatching = table?.allMatching ?? (matching.length > 0 && matching.every((id) => selectedSet.has(id)));
|
|
643
646
|
const selection = {
|
|
644
647
|
ids: table?.selectedIds ?? [],
|
|
645
648
|
allMatching,
|
|
@@ -38,5 +38,15 @@ export type ColorModeOptions = {
|
|
|
38
38
|
* is `system`, keeps `data-theme` following the operating system. Render it
|
|
39
39
|
* inline in the document head, before anything paints. Storage being
|
|
40
40
|
* unavailable (a private window) leaves the page on `system`.
|
|
41
|
+
*
|
|
42
|
+
* It also puts the choice back when React wipes it. A hydration failure that
|
|
43
|
+
* reaches the root (a browser extension editing the page before hydration
|
|
44
|
+
* is enough) makes React client-render `<html>`, and taking that element
|
|
45
|
+
* over removes every attribute on it before setting the ones the layout
|
|
46
|
+
* renders. Without a repair the visitor's mode falls back to whatever the
|
|
47
|
+
* layout wrote, or to light. The script watches for its own
|
|
48
|
+
* `data-theme-setting` going missing, or coming back from nothing, and
|
|
49
|
+
* applies the stored choice again. A ThemeToggle change only ever replaces
|
|
50
|
+
* the value, so it never trips the repair.
|
|
41
51
|
*/
|
|
42
52
|
export declare function colorModeScript({ storageKey }?: ColorModeOptions): string;
|
|
@@ -5,17 +5,31 @@ function colorModeScript({ storageKey = DEFAULT_COLOR_MODE_STORAGE_KEY } = {}) {
|
|
|
5
5
|
const key = JSON.stringify(storageKey);
|
|
6
6
|
return `(function () {
|
|
7
7
|
var root = document.documentElement;
|
|
8
|
-
var saved = null;
|
|
9
|
-
try { saved = localStorage.getItem(${key}); } catch (e) {}
|
|
10
|
-
var setting = saved === 'light' || saved === 'dark' ? saved : 'system';
|
|
11
8
|
var media = window.matchMedia('(prefers-color-scheme: dark)');
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
function apply() {
|
|
10
|
+
var saved = null;
|
|
11
|
+
try { saved = localStorage.getItem(${key}); } catch (e) {}
|
|
12
|
+
var setting = saved === 'light' || saved === 'dark' ? saved : 'system';
|
|
13
|
+
root.setAttribute('data-theme-setting', setting);
|
|
14
|
+
root.setAttribute('data-theme', setting === 'system' ? (media.matches ? 'dark' : 'light') : setting);
|
|
15
|
+
}
|
|
16
|
+
apply();
|
|
14
17
|
media.addEventListener('change', function (event) {
|
|
15
18
|
if (root.getAttribute('data-theme-setting') === 'system') {
|
|
16
19
|
root.setAttribute('data-theme', event.matches ? 'dark' : 'light');
|
|
17
20
|
}
|
|
18
21
|
});
|
|
22
|
+
if (typeof MutationObserver === 'undefined') return;
|
|
23
|
+
var observer = new MutationObserver(function (records) {
|
|
24
|
+
var wiped = !root.hasAttribute('data-theme-setting');
|
|
25
|
+
for (var i = 0; !wiped && i < records.length; i++) {
|
|
26
|
+
if (records[i].attributeName === 'data-theme-setting' && records[i].oldValue === null) wiped = true;
|
|
27
|
+
}
|
|
28
|
+
if (!wiped) return;
|
|
29
|
+
apply();
|
|
30
|
+
observer.takeRecords();
|
|
31
|
+
});
|
|
32
|
+
observer.observe(root, { attributes: true, attributeOldValue: true, attributeFilter: ['data-theme-setting'] });
|
|
19
33
|
})();`;
|
|
20
34
|
}
|
|
21
35
|
export {
|
package/package.json
CHANGED
package/tokens/motion.d.ts
CHANGED
|
@@ -20,6 +20,8 @@ export declare const MOTION_HOVER_HIDE_DELAY_MS = 150;
|
|
|
20
20
|
export declare const MOTION_AUTO_DISMISS_MS = 5000;
|
|
21
21
|
/** How long a notification carrying an action, such as an Undo, stays before dismissing itself: time to read it and decide. */
|
|
22
22
|
export declare const MOTION_ACTION_DISMISS_MS = 10000;
|
|
23
|
+
/** How long a table draws skeleton rows as an AI command's answer lands, so the change reads as a change before its result is reported. */
|
|
24
|
+
export declare const MOTION_TABLE_COMMAND_SKELETON_MS = 700;
|
|
23
25
|
/** How long an exiting element's unmount waits for its CSS exit animation — mirrors --motion-duration-base. */
|
|
24
26
|
export declare const MOTION_EXIT_SYNC_MS = 200;
|
|
25
27
|
/** Interval between automatic slide advances. */
|
package/tokens/motion.js
CHANGED
|
@@ -2,6 +2,7 @@ const MOTION_HOVER_SHOW_DELAY_MS = 300;
|
|
|
2
2
|
const MOTION_HOVER_HIDE_DELAY_MS = 150;
|
|
3
3
|
const MOTION_AUTO_DISMISS_MS = 5e3;
|
|
4
4
|
const MOTION_ACTION_DISMISS_MS = 1e4;
|
|
5
|
+
const MOTION_TABLE_COMMAND_SKELETON_MS = 700;
|
|
5
6
|
const MOTION_EXIT_SYNC_MS = 200;
|
|
6
7
|
const MOTION_AUTOPLAY_INTERVAL_MS = 5e3;
|
|
7
8
|
const MOTION_FEEDBACK_RESET_MS = 2e3;
|
|
@@ -49,6 +50,7 @@ export {
|
|
|
49
50
|
MOTION_SUGGESTIONS_THINK_MS,
|
|
50
51
|
MOTION_SUMMARY_REVEAL_MS,
|
|
51
52
|
MOTION_SUMMARY_THINK_MS,
|
|
53
|
+
MOTION_TABLE_COMMAND_SKELETON_MS,
|
|
52
54
|
MOTION_THREAD_NAMING_DELAY_MS,
|
|
53
55
|
MOTION_TOKEN_REREAD_MS
|
|
54
56
|
};
|