@terreno/ui 57.8.0 → 57.9.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/dist/AreaChart.d.ts +1 -1
- package/dist/AreaChart.d.ts.map +1 -1
- package/dist/AreaChart.js +70 -22
- package/dist/AreaChart.js.map +1 -1
- package/dist/BarChart.d.ts.map +1 -1
- package/dist/BarChart.js +55 -13
- package/dist/BarChart.js.map +1 -1
- package/dist/ChartCard.d.ts +5 -0
- package/dist/ChartCard.d.ts.map +1 -0
- package/dist/ChartCard.js +18 -0
- package/dist/ChartCard.js.map +1 -0
- package/dist/Common.d.ts +79 -5
- package/dist/Common.d.ts.map +1 -1
- package/dist/Common.js.map +1 -1
- package/dist/DashboardGrid.d.ts +6 -2
- package/dist/DashboardGrid.d.ts.map +1 -1
- package/dist/DashboardGrid.js +43 -10
- package/dist/DashboardGrid.js.map +1 -1
- package/dist/DonutChart.d.ts.map +1 -1
- package/dist/DonutChart.js +20 -10
- package/dist/DonutChart.js.map +1 -1
- package/dist/DropdownMenuItem.d.ts +16 -0
- package/dist/DropdownMenuItem.d.ts.map +1 -0
- package/dist/DropdownMenuItem.js +11 -0
- package/dist/DropdownMenuItem.js.map +1 -0
- package/dist/FilePickerButton.d.ts.map +1 -1
- package/dist/FilePickerButton.js +70 -10
- package/dist/FilePickerButton.js.map +1 -1
- package/dist/GPTChat.d.ts.map +1 -1
- package/dist/GPTChat.js +103 -14
- package/dist/GPTChat.js.map +1 -1
- package/dist/LineChart.d.ts +1 -1
- package/dist/LineChart.d.ts.map +1 -1
- package/dist/LineChart.js +62 -21
- package/dist/LineChart.js.map +1 -1
- package/dist/Scorecard.d.ts +5 -0
- package/dist/Scorecard.d.ts.map +1 -0
- package/dist/Scorecard.js +11 -0
- package/dist/Scorecard.js.map +1 -0
- package/dist/SparklineChart.d.ts +5 -0
- package/dist/SparklineChart.d.ts.map +1 -0
- package/dist/SparklineChart.js +35 -0
- package/dist/SparklineChart.js.map +1 -0
- package/dist/TextField.d.ts.map +1 -1
- package/dist/TextField.js +12 -4
- package/dist/TextField.js.map +1 -1
- package/dist/ToastNotifications.d.ts.map +1 -1
- package/dist/ToastNotifications.js +29 -6
- package/dist/ToastNotifications.js.map +1 -1
- package/dist/WebDropdownMenu.d.ts +2 -1
- package/dist/WebDropdownMenu.d.ts.map +1 -1
- package/dist/WebDropdownMenu.js +2 -6
- package/dist/WebDropdownMenu.js.map +1 -1
- package/dist/charts/ChartFacadeContainer.d.ts +10 -0
- package/dist/charts/ChartFacadeContainer.d.ts.map +1 -0
- package/dist/charts/ChartFacadeContainer.js +10 -0
- package/dist/charts/ChartFacadeContainer.js.map +1 -0
- package/dist/charts/ChartFrame.d.ts +4 -0
- package/dist/charts/ChartFrame.d.ts.map +1 -1
- package/dist/charts/ChartFrame.js +4 -2
- package/dist/charts/ChartFrame.js.map +1 -1
- package/dist/charts/layout.d.ts +9 -2
- package/dist/charts/layout.d.ts.map +1 -1
- package/dist/charts/layout.js +28 -6
- package/dist/charts/layout.js.map +1 -1
- package/dist/charts/scales.d.ts +3 -1
- package/dist/charts/scales.d.ts.map +1 -1
- package/dist/charts/scales.js +7 -7
- package/dist/charts/scales.js.map +1 -1
- package/dist/charts/series.d.ts +15 -0
- package/dist/charts/series.d.ts.map +1 -0
- package/dist/charts/series.js +19 -0
- package/dist/charts/series.js.map +1 -0
- package/dist/charts/types/chartTypes.d.ts +7 -0
- package/dist/charts/types/chartTypes.d.ts.map +1 -1
- package/dist/dashboardGridLayout.d.ts +6 -0
- package/dist/dashboardGridLayout.d.ts.map +1 -1
- package/dist/dashboardGridLayout.js +19 -3
- package/dist/dashboardGridLayout.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lazyBoundaries/heavyOptionalExports.d.ts +9 -0
- package/dist/lazyBoundaries/heavyOptionalExports.d.ts.map +1 -1
- package/dist/lazyBoundaries/heavyOptionalExports.js +6 -0
- package/dist/lazyBoundaries/heavyOptionalExports.js.map +1 -1
- package/dist/resolveDocumentBodyPortalTarget.d.ts +7 -0
- package/dist/resolveDocumentBodyPortalTarget.d.ts.map +1 -0
- package/dist/resolveDocumentBodyPortalTarget.js +12 -0
- package/dist/resolveDocumentBodyPortalTarget.js.map +1 -0
- package/package.json +1 -1
- package/src/AIRequestExplorer.test.tsx +2 -2
- package/src/AreaChart.test.tsx +81 -0
- package/src/AreaChart.tsx +171 -62
- package/src/BarChart.test.tsx +119 -0
- package/src/BarChart.tsx +94 -20
- package/src/ChartCard.test.tsx +79 -0
- package/src/ChartCard.tsx +80 -0
- package/src/Common.ts +69 -2
- package/src/DashboardGrid.test.tsx +98 -1
- package/src/DashboardGrid.tsx +71 -20
- package/src/DonutChart.test.tsx +73 -0
- package/src/DonutChart.tsx +87 -14
- package/src/DropdownMenuItem.tsx +48 -0
- package/src/FilePickerButton.test.tsx +60 -6
- package/src/FilePickerButton.tsx +116 -28
- package/src/GPTChat.test.tsx +133 -6
- package/src/GPTChat.tsx +196 -38
- package/src/LineChart.test.tsx +104 -0
- package/src/LineChart.tsx +154 -58
- package/src/Scorecard.test.tsx +65 -0
- package/src/Scorecard.tsx +45 -0
- package/src/SparklineChart.test.tsx +69 -0
- package/src/SparklineChart.tsx +85 -0
- package/src/TextField.test.tsx +16 -0
- package/src/TextField.tsx +13 -3
- package/src/ToastNotifications.tsx +33 -6
- package/src/ToastNotifications.webModal.test.tsx +285 -0
- package/src/WebDropdownMenu.tsx +3 -7
- package/src/bunSetup.ts +1 -0
- package/src/charts/ChartFacadeContainer.tsx +35 -0
- package/src/charts/ChartFrame.tsx +39 -1
- package/src/charts/layout.test.ts +22 -1
- package/src/charts/layout.ts +37 -4
- package/src/charts/scales.test.ts +33 -0
- package/src/charts/scales.ts +10 -6
- package/src/charts/series.ts +43 -0
- package/src/charts/types/chartTypes.ts +8 -0
- package/src/dashboardGridLayout.test.ts +59 -1
- package/src/dashboardGridLayout.ts +30 -3
- package/src/index.tsx +6 -0
- package/src/lazyBoundaries/heavyOptionalExports.tsx +21 -0
- package/src/resolveDocumentBodyPortalTarget.ts +11 -0
package/src/GPTChat.tsx
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {DateTime} from "luxon";
|
|
1
2
|
import React, {useCallback, useEffect, useRef, useState} from "react";
|
|
2
3
|
import {
|
|
3
4
|
Platform,
|
|
@@ -9,6 +10,8 @@ import {
|
|
|
9
10
|
import {AttachmentPreview} from "./AttachmentPreview";
|
|
10
11
|
import {Box} from "./Box";
|
|
11
12
|
import {Button} from "./Button";
|
|
13
|
+
import {DropdownMenuItem} from "./DropdownMenuItem";
|
|
14
|
+
import {DropdownPanel} from "./DropdownPanel";
|
|
12
15
|
import type {SelectedFile} from "./FilePickerButton";
|
|
13
16
|
import {FilePickerButton} from "./FilePickerButton";
|
|
14
17
|
import {Heading} from "./Heading";
|
|
@@ -228,18 +231,103 @@ const handleDownloadFile = (url: string, filename: string): void => {
|
|
|
228
231
|
document.body.removeChild(link);
|
|
229
232
|
};
|
|
230
233
|
|
|
234
|
+
const IMAGE_EXTENSIONS: Record<string, string> = {
|
|
235
|
+
"image/gif": "gif",
|
|
236
|
+
"image/jpeg": "jpg",
|
|
237
|
+
"image/png": "png",
|
|
238
|
+
"image/webp": "webp",
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
const getImageFilename = (part: ImageContentPart): string => {
|
|
242
|
+
const extension = IMAGE_EXTENSIONS[part.mimeType ?? ""] ?? "png";
|
|
243
|
+
return `image-${DateTime.now().toMillis()}.${extension}`;
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
// Browsers reliably accept only PNG on the clipboard, so other formats are redrawn as PNG.
|
|
247
|
+
const convertBlobToPng = async (blob: Blob): Promise<Blob> => {
|
|
248
|
+
if (blob.type === "image/png") {
|
|
249
|
+
return blob;
|
|
250
|
+
}
|
|
251
|
+
const bitmap = await createImageBitmap(blob);
|
|
252
|
+
const canvas = document.createElement("canvas");
|
|
253
|
+
canvas.width = bitmap.width;
|
|
254
|
+
canvas.height = bitmap.height;
|
|
255
|
+
canvas.getContext("2d")?.drawImage(bitmap, 0, 0);
|
|
256
|
+
return new Promise((resolve, reject) => {
|
|
257
|
+
canvas.toBlob((png) => (png ? resolve(png) : reject(new Error("PNG conversion failed"))));
|
|
258
|
+
});
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
/** Copies the image itself (not a text placeholder) to the clipboard. */
|
|
262
|
+
const copyImageToClipboard = async (part: ImageContentPart): Promise<void> => {
|
|
263
|
+
if (Platform.OS === "web") {
|
|
264
|
+
if (typeof ClipboardItem === "undefined" || !navigator.clipboard?.write) {
|
|
265
|
+
console.warn("Copying images is not supported in this browser");
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
const response = await fetch(part.url);
|
|
269
|
+
const png = await convertBlobToPng(await response.blob());
|
|
270
|
+
await navigator.clipboard.write([new ClipboardItem({"image/png": png})]);
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
const Clipboard = await import("expo-clipboard");
|
|
274
|
+
const base64 = part.url.startsWith("data:") ? part.url.split(",")[1] : undefined;
|
|
275
|
+
if (base64) {
|
|
276
|
+
await Clipboard.setImageAsync(base64);
|
|
277
|
+
} else {
|
|
278
|
+
await Clipboard.setStringAsync(part.url);
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
|
|
282
|
+
const ImageActions = ({part}: {part: ImageContentPart}): React.ReactElement => {
|
|
283
|
+
const handleCopy = useCallback(async (): Promise<void> => {
|
|
284
|
+
try {
|
|
285
|
+
await copyImageToClipboard(part);
|
|
286
|
+
} catch (error) {
|
|
287
|
+
console.warn("Failed to copy image", error);
|
|
288
|
+
}
|
|
289
|
+
}, [part]);
|
|
290
|
+
|
|
291
|
+
const handleDownload = useCallback((): void => {
|
|
292
|
+
handleDownloadFile(part.url, getImageFilename(part));
|
|
293
|
+
}, [part]);
|
|
294
|
+
|
|
295
|
+
return (
|
|
296
|
+
<Box direction="row" gap={1} testID="gpt-image-actions">
|
|
297
|
+
<IconButton
|
|
298
|
+
accessibilityLabel="Copy image"
|
|
299
|
+
iconName="copy"
|
|
300
|
+
onClick={handleCopy}
|
|
301
|
+
testID="gpt-copy-image"
|
|
302
|
+
variant="ghost"
|
|
303
|
+
/>
|
|
304
|
+
{Platform.OS === "web" ? (
|
|
305
|
+
<IconButton
|
|
306
|
+
accessibilityLabel="Download image"
|
|
307
|
+
iconName="download"
|
|
308
|
+
onClick={handleDownload}
|
|
309
|
+
testID="gpt-download-image"
|
|
310
|
+
variant="ghost"
|
|
311
|
+
/>
|
|
312
|
+
) : null}
|
|
313
|
+
</Box>
|
|
314
|
+
);
|
|
315
|
+
};
|
|
316
|
+
|
|
231
317
|
const MessageContentParts = ({parts}: {parts: MessageContentPart[]}): React.ReactElement => {
|
|
232
318
|
return (
|
|
233
319
|
<Box gap={2}>
|
|
234
320
|
{parts.map((part, index) => {
|
|
235
321
|
if (part.type === "image") {
|
|
236
322
|
return (
|
|
237
|
-
<
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
323
|
+
<Box gap={1} key={`content-${index}`}>
|
|
324
|
+
<RNImage
|
|
325
|
+
resizeMode="contain"
|
|
326
|
+
source={{uri: part.url}}
|
|
327
|
+
style={{borderRadius: 8, height: 400, maxWidth: 800, minWidth: 400, width: "100%"}}
|
|
328
|
+
/>
|
|
329
|
+
<ImageActions part={part} />
|
|
330
|
+
</Box>
|
|
243
331
|
);
|
|
244
332
|
}
|
|
245
333
|
if (part.type === "file") {
|
|
@@ -464,25 +552,44 @@ const HistoryItemTitle = ({
|
|
|
464
552
|
);
|
|
465
553
|
}
|
|
466
554
|
return (
|
|
467
|
-
<
|
|
468
|
-
{history.
|
|
469
|
-
|
|
555
|
+
<Box flex="grow" minWidth={0}>
|
|
556
|
+
<Text color={history.id === currentHistoryId ? "inverted" : "primary"} size="sm" truncate>
|
|
557
|
+
{history.title ?? "New Chat"}
|
|
558
|
+
</Text>
|
|
559
|
+
</Box>
|
|
470
560
|
);
|
|
471
561
|
};
|
|
472
562
|
|
|
473
|
-
const
|
|
563
|
+
const HistoryItemActions = ({
|
|
474
564
|
editingHistoryId,
|
|
475
565
|
handleFinishRename,
|
|
476
566
|
handleStartRename,
|
|
477
567
|
history,
|
|
568
|
+
isSelected,
|
|
569
|
+
onDeleteHistory,
|
|
478
570
|
onUpdateTitle,
|
|
479
571
|
}: {
|
|
480
572
|
editingHistoryId: string | null;
|
|
481
573
|
handleFinishRename: () => void;
|
|
482
574
|
handleStartRename: (id: string, title: string) => void;
|
|
483
575
|
history: GPTChatHistory;
|
|
576
|
+
isSelected: boolean;
|
|
577
|
+
onDeleteHistory: (id: string) => void;
|
|
484
578
|
onUpdateTitle?: (id: string, title: string) => void;
|
|
485
|
-
}): React.ReactElement
|
|
579
|
+
}): React.ReactElement => {
|
|
580
|
+
const [isMenuOpen, setIsMenuOpen] = useState(false);
|
|
581
|
+
const title = history.title ?? "New Chat";
|
|
582
|
+
|
|
583
|
+
const handleRename = useCallback((): void => {
|
|
584
|
+
setIsMenuOpen(false);
|
|
585
|
+
handleStartRename(history.id, history.title ?? "");
|
|
586
|
+
}, [handleStartRename, history.id, history.title]);
|
|
587
|
+
|
|
588
|
+
const handleDelete = useCallback((): void => {
|
|
589
|
+
setIsMenuOpen(false);
|
|
590
|
+
onDeleteHistory(history.id);
|
|
591
|
+
}, [history.id, onDeleteHistory]);
|
|
592
|
+
|
|
486
593
|
if (editingHistoryId === history.id) {
|
|
487
594
|
return (
|
|
488
595
|
<IconButton
|
|
@@ -493,16 +600,45 @@ const HistoryItemActionButton = ({
|
|
|
493
600
|
/>
|
|
494
601
|
);
|
|
495
602
|
}
|
|
496
|
-
|
|
497
|
-
return null;
|
|
498
|
-
}
|
|
603
|
+
|
|
499
604
|
return (
|
|
500
|
-
<
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
605
|
+
<DropdownPanel
|
|
606
|
+
align="auto"
|
|
607
|
+
isOpen={isMenuOpen}
|
|
608
|
+
onOpenChange={setIsMenuOpen}
|
|
609
|
+
renderTrigger={({toggle}) => (
|
|
610
|
+
<IconButton
|
|
611
|
+
accessibilityLabel={`Chat actions: ${title}`}
|
|
612
|
+
iconName="ellipsis-vertical"
|
|
613
|
+
onClick={toggle}
|
|
614
|
+
testID={`gpt-history-menu-${history.id}`}
|
|
615
|
+
variant={isSelected ? "primary" : "ghost"}
|
|
616
|
+
/>
|
|
617
|
+
)}
|
|
618
|
+
showActionButtons={false}
|
|
619
|
+
testID={`gpt-history-menu-panel-${history.id}`}
|
|
620
|
+
width={180}
|
|
621
|
+
>
|
|
622
|
+
<Box gap={1}>
|
|
623
|
+
{onUpdateTitle ? (
|
|
624
|
+
<DropdownMenuItem
|
|
625
|
+
accessibilityLabel={`Rename chat: ${title}`}
|
|
626
|
+
iconName="pen-to-square"
|
|
627
|
+
label="Rename"
|
|
628
|
+
onClick={handleRename}
|
|
629
|
+
testID={`gpt-rename-history-${history.id}`}
|
|
630
|
+
/>
|
|
631
|
+
) : null}
|
|
632
|
+
<DropdownMenuItem
|
|
633
|
+
accessibilityLabel={`Delete chat: ${title}`}
|
|
634
|
+
color="error"
|
|
635
|
+
iconName="trash-can"
|
|
636
|
+
label="Delete"
|
|
637
|
+
onClick={handleDelete}
|
|
638
|
+
testID={`gpt-delete-history-${history.id}`}
|
|
639
|
+
/>
|
|
640
|
+
</Box>
|
|
641
|
+
</DropdownPanel>
|
|
506
642
|
);
|
|
507
643
|
};
|
|
508
644
|
|
|
@@ -569,7 +705,7 @@ const AssistantActions = ({
|
|
|
569
705
|
message,
|
|
570
706
|
onRateFeedback,
|
|
571
707
|
}: {
|
|
572
|
-
handleCopyMessage: (
|
|
708
|
+
handleCopyMessage: (message: GPTChatMessage) => void;
|
|
573
709
|
index: number;
|
|
574
710
|
message: GPTChatMessage;
|
|
575
711
|
onRateFeedback?: (promptIndex: number, rating: "up" | "down" | null) => void;
|
|
@@ -583,7 +719,7 @@ const AssistantActions = ({
|
|
|
583
719
|
<IconButton
|
|
584
720
|
accessibilityLabel="Copy message"
|
|
585
721
|
iconName="copy"
|
|
586
|
-
onClick={() => handleCopyMessage(message
|
|
722
|
+
onClick={() => handleCopyMessage(message)}
|
|
587
723
|
testID={`gpt-copy-msg-${index}`}
|
|
588
724
|
/>
|
|
589
725
|
</Box>
|
|
@@ -657,7 +793,7 @@ const MessageList = ({
|
|
|
657
793
|
onRateFeedback,
|
|
658
794
|
}: {
|
|
659
795
|
currentMessages: GPTChatMessage[];
|
|
660
|
-
handleCopyMessage: (
|
|
796
|
+
handleCopyMessage: (message: GPTChatMessage) => void;
|
|
661
797
|
onRateFeedback?: (promptIndex: number, rating: "up" | "down" | null) => void;
|
|
662
798
|
}): React.ReactElement => {
|
|
663
799
|
return (
|
|
@@ -858,6 +994,11 @@ const ApiKeyModal = ({
|
|
|
858
994
|
// Main Component
|
|
859
995
|
// ============================================================
|
|
860
996
|
|
|
997
|
+
/** Pixels of content below the viewport before "Scroll to bottom" appears. */
|
|
998
|
+
const SCROLL_TO_BOTTOM_THRESHOLD = 100;
|
|
999
|
+
/** Height the composer grows to before its text scrolls. */
|
|
1000
|
+
const COMPOSER_MAX_HEIGHT = 200;
|
|
1001
|
+
|
|
861
1002
|
export const GPTChat = ({
|
|
862
1003
|
attachments = [],
|
|
863
1004
|
availableModels,
|
|
@@ -943,9 +1084,21 @@ export const GPTChat = ({
|
|
|
943
1084
|
return () => el.removeEventListener("keydown", handler);
|
|
944
1085
|
}, [inputElement]);
|
|
945
1086
|
|
|
946
|
-
|
|
1087
|
+
// Image-only replies have no meaningful text, so copy the image instead of a placeholder.
|
|
1088
|
+
const handleCopyMessage = useCallback(async (message: GPTChatMessage) => {
|
|
1089
|
+
const firstImage = message.contentParts?.find(
|
|
1090
|
+
(part): part is ImageContentPart => part.type === "image"
|
|
1091
|
+
);
|
|
1092
|
+
if (firstImage && !message.content.trim()) {
|
|
1093
|
+
try {
|
|
1094
|
+
await copyImageToClipboard(firstImage);
|
|
1095
|
+
} catch (error) {
|
|
1096
|
+
console.warn("Failed to copy image", error);
|
|
1097
|
+
}
|
|
1098
|
+
return;
|
|
1099
|
+
}
|
|
947
1100
|
const Clipboard = await import("expo-clipboard");
|
|
948
|
-
await Clipboard.setStringAsync(
|
|
1101
|
+
await Clipboard.setStringAsync(message.content);
|
|
949
1102
|
}, []);
|
|
950
1103
|
|
|
951
1104
|
const scrollToBottom = useCallback(() => {
|
|
@@ -963,12 +1116,17 @@ export const GPTChat = ({
|
|
|
963
1116
|
const handleScroll = useCallback((offsetY: number) => {
|
|
964
1117
|
scrollOffsetRef.current = offsetY;
|
|
965
1118
|
const distanceFromBottom = contentHeightRef.current - offsetY - viewportHeightRef.current;
|
|
966
|
-
setIsScrolledUp(distanceFromBottom >
|
|
1119
|
+
setIsScrolledUp(distanceFromBottom > SCROLL_TO_BOTTOM_THRESHOLD);
|
|
967
1120
|
}, []);
|
|
968
1121
|
|
|
1122
|
+
// Growing content (a streaming reply) must not count as the user scrolling up, but content
|
|
1123
|
+
// that shrinks to fit the viewport (switching to a short or empty chat) clears the flag.
|
|
969
1124
|
const handleContentLayout = useCallback(
|
|
970
|
-
(
|
|
971
|
-
contentHeightRef.current =
|
|
1125
|
+
(event: {nativeEvent: {layout: {height: number; width: number; x: number; y: number}}}) => {
|
|
1126
|
+
contentHeightRef.current = event.nativeEvent.layout.height;
|
|
1127
|
+
if (contentHeightRef.current <= viewportHeightRef.current + SCROLL_TO_BOTTOM_THRESHOLD) {
|
|
1128
|
+
setIsScrolledUp(false);
|
|
1129
|
+
}
|
|
972
1130
|
},
|
|
973
1131
|
[]
|
|
974
1132
|
);
|
|
@@ -1095,21 +1253,16 @@ export const GPTChat = ({
|
|
|
1095
1253
|
history={history}
|
|
1096
1254
|
setEditingTitle={setEditingTitle}
|
|
1097
1255
|
/>
|
|
1098
|
-
<Box
|
|
1099
|
-
<
|
|
1256
|
+
<Box marginLeft={1}>
|
|
1257
|
+
<HistoryItemActions
|
|
1100
1258
|
editingHistoryId={editingHistoryId}
|
|
1101
1259
|
handleFinishRename={handleFinishRename}
|
|
1102
1260
|
handleStartRename={handleStartRename}
|
|
1103
1261
|
history={history}
|
|
1262
|
+
isSelected={history.id === currentHistoryId}
|
|
1263
|
+
onDeleteHistory={onDeleteHistory}
|
|
1104
1264
|
onUpdateTitle={onUpdateTitle}
|
|
1105
1265
|
/>
|
|
1106
|
-
<IconButton
|
|
1107
|
-
accessibilityLabel={`Delete chat: ${history.title ?? "New Chat"}`}
|
|
1108
|
-
iconName="trash"
|
|
1109
|
-
onClick={() => onDeleteHistory(history.id)}
|
|
1110
|
-
testID={`gpt-delete-history-${history.id}`}
|
|
1111
|
-
variant="destructive"
|
|
1112
|
-
/>
|
|
1113
1266
|
</Box>
|
|
1114
1267
|
</Box>
|
|
1115
1268
|
))}
|
|
@@ -1143,7 +1296,10 @@ export const GPTChat = ({
|
|
|
1143
1296
|
</Box>
|
|
1144
1297
|
</Box>
|
|
1145
1298
|
|
|
1146
|
-
<ScrollToBottomButton
|
|
1299
|
+
<ScrollToBottomButton
|
|
1300
|
+
isScrolledUp={isScrolledUp && !isEmptyChat}
|
|
1301
|
+
scrollToBottom={scrollToBottom}
|
|
1302
|
+
/>
|
|
1147
1303
|
<AttachmentSection attachments={attachments} onRemoveAttachment={onRemoveAttachment} />
|
|
1148
1304
|
|
|
1149
1305
|
{/* Input */}
|
|
@@ -1171,7 +1327,9 @@ export const GPTChat = ({
|
|
|
1171
1327
|
<TextArea
|
|
1172
1328
|
blurOnSubmit={false}
|
|
1173
1329
|
disabled={isStreaming}
|
|
1330
|
+
grow
|
|
1174
1331
|
inputRef={handleInputRef}
|
|
1332
|
+
maxHeight={COMPOSER_MAX_HEIGHT}
|
|
1175
1333
|
onChange={setInputValue}
|
|
1176
1334
|
placeholder="Type a message..."
|
|
1177
1335
|
testID="gpt-input"
|
package/src/LineChart.test.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {describe, expect, it, spyOn} from "bun:test";
|
|
2
2
|
import {act, fireEvent} from "@testing-library/react-native";
|
|
3
|
+
import {assert} from "chai";
|
|
3
4
|
import {Linking} from "react-native";
|
|
4
5
|
|
|
5
6
|
import {LineChart} from "./LineChart";
|
|
@@ -11,7 +12,110 @@ const POINTS = [
|
|
|
11
12
|
{label: "C", value: 100},
|
|
12
13
|
];
|
|
13
14
|
|
|
15
|
+
const SERIES = [
|
|
16
|
+
{data: POINTS, id: "rank", label: "Search lost IS (rank)"},
|
|
17
|
+
{
|
|
18
|
+
data: POINTS.map((point) => ({...point, value: point.value / 2})),
|
|
19
|
+
id: "share",
|
|
20
|
+
label: "Search impr. share",
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
data: POINTS.map((point) => ({...point, value: point.value / 4})),
|
|
24
|
+
id: "budget",
|
|
25
|
+
label: "Search lost IS (budget)",
|
|
26
|
+
},
|
|
27
|
+
];
|
|
28
|
+
|
|
14
29
|
describe("LineChart", () => {
|
|
30
|
+
it("applies explicit tick rotation and chart-card header shortcuts", async (): Promise<void> => {
|
|
31
|
+
let pressCount = 0;
|
|
32
|
+
const {getByTestId, getByText} = renderWithTheme(
|
|
33
|
+
<LineChart
|
|
34
|
+
data={POINTS}
|
|
35
|
+
onPeriodPress={(): void => {
|
|
36
|
+
pressCount += 1;
|
|
37
|
+
}}
|
|
38
|
+
periodLabel="Last 30 days"
|
|
39
|
+
testID="chart"
|
|
40
|
+
title="Search share"
|
|
41
|
+
xTickPolicy="rotate"
|
|
42
|
+
/>
|
|
43
|
+
);
|
|
44
|
+
const tickStyle = getByTestId("chart.xtick.0").props.style;
|
|
45
|
+
const tickStyles = Array.isArray(tickStyle) ? tickStyle : [tickStyle];
|
|
46
|
+
|
|
47
|
+
assert.isTrue(tickStyles.some((style) => Array.isArray(style?.transform)));
|
|
48
|
+
assert.exists(getByText("Search share"));
|
|
49
|
+
assert.exists(getByText("Last 30 days"));
|
|
50
|
+
fireEvent.press(getByTestId("chart.card.period-clickable"));
|
|
51
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
52
|
+
assert.equal(pressCount, 1);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it("renders one path and legend item per named series", () => {
|
|
56
|
+
const {getByTestId, getByText} = renderWithTheme(
|
|
57
|
+
<LineChart data={[]} series={SERIES} testID="chart" />
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
for (let index = 0; index < SERIES.length; index += 1) {
|
|
61
|
+
assert.exists(getByTestId(`chart.series.${index}.path`));
|
|
62
|
+
assert.exists(getByTestId(`chart.series.${index}.marker.0`));
|
|
63
|
+
assert.exists(getByTestId(`chart.legend.${index}`));
|
|
64
|
+
assert.exists(getByTestId(`chart.legend.${index}.swatch`));
|
|
65
|
+
const legendStyle = getByTestId(`chart.legend.${index}.item`).props.style;
|
|
66
|
+
const legendStyles = Array.isArray(legendStyle) ? legendStyle : [legendStyle];
|
|
67
|
+
assert.isTrue(
|
|
68
|
+
legendStyles.some(
|
|
69
|
+
(style: {flexGrow?: number; minWidth?: number} | undefined) =>
|
|
70
|
+
style?.flexGrow === 1 && style.minWidth === 0
|
|
71
|
+
)
|
|
72
|
+
);
|
|
73
|
+
assert.exists(getByText(SERIES[index]?.label ?? ""));
|
|
74
|
+
}
|
|
75
|
+
assert.isBelow(
|
|
76
|
+
getByTestId("chart.series.0.marker.2").props.cy,
|
|
77
|
+
getByTestId("chart.series.2.marker.2").props.cy
|
|
78
|
+
);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it("identifies the active series in a multi-series tooltip", async (): Promise<void> => {
|
|
82
|
+
const {getByTestId, getByText} = renderWithTheme(
|
|
83
|
+
<LineChart data={[]} series={SERIES} testID="chart" />
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
await act(async () => {
|
|
87
|
+
fireEvent.press(getByTestId("chart.series.1.point.1-clickable"));
|
|
88
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
assert.exists(getByText("Search impr. share — B: 25"));
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it("renders a dotted comparison path on the shared scale", () => {
|
|
95
|
+
const {getByTestId} = renderWithTheme(
|
|
96
|
+
<LineChart comparisonData={POINTS} data={POINTS} testID="chart" />
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
assert.isString(getByTestId("chart.comparison").props.strokeDasharray);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it("renders comparison-only data instead of the empty state", () => {
|
|
103
|
+
const {getByTestId, queryByText} = renderWithTheme(
|
|
104
|
+
<LineChart comparisonData={POINTS} data={[]} testID="chart" />
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
assert.exists(getByTestId("chart.comparison"));
|
|
108
|
+
assert.notExists(queryByText("No data"));
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it("shows the empty state when every named series is empty", () => {
|
|
112
|
+
const {getByText} = renderWithTheme(
|
|
113
|
+
<LineChart data={POINTS} series={[{data: [], id: "empty", label: "Empty"}]} />
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
assert.exists(getByText("No data"));
|
|
117
|
+
});
|
|
118
|
+
|
|
15
119
|
it("renders one mark testID per point", () => {
|
|
16
120
|
const {getByTestId, queryByTestId} = renderWithTheme(
|
|
17
121
|
<LineChart data={POINTS} testID="chart" />
|