@dust-tt/sparkle 0.2.587 → 0.2.589-rc-1
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/cjs/index.js +1 -1
- package/dist/esm/components/Button.d.ts +1 -1
- package/dist/esm/components/Button.d.ts.map +1 -1
- package/dist/esm/components/Button.js +9 -8
- package/dist/esm/components/Button.js.map +1 -1
- package/dist/esm/components/Card.d.ts +1 -1
- package/dist/esm/components/ContextItem.d.ts +2 -1
- package/dist/esm/components/ContextItem.d.ts.map +1 -1
- package/dist/esm/components/ContextItem.js +4 -3
- package/dist/esm/components/ContextItem.js.map +1 -1
- package/dist/esm/components/ConversationMessage.js +2 -2
- package/dist/esm/components/ConversationMessage.js.map +1 -1
- package/dist/esm/components/ToolCard.d.ts +13 -0
- package/dist/esm/components/ToolCard.d.ts.map +1 -0
- package/dist/esm/components/ToolCard.js +20 -0
- package/dist/esm/components/ToolCard.js.map +1 -0
- package/dist/esm/components/index.d.ts +1 -0
- package/dist/esm/components/index.d.ts.map +1 -1
- package/dist/esm/components/index.js +1 -0
- package/dist/esm/components/index.js.map +1 -1
- package/dist/esm/stories/Button.stories.d.ts +4 -0
- package/dist/esm/stories/Button.stories.d.ts.map +1 -1
- package/dist/esm/stories/Button.stories.js +5 -0
- package/dist/esm/stories/Button.stories.js.map +1 -1
- package/dist/esm/stories/ContextItem.stories.d.ts.map +1 -1
- package/dist/esm/stories/ContextItem.stories.js +1 -1
- package/dist/esm/stories/ContextItem.stories.js.map +1 -1
- package/dist/esm/stories/ToolCard.stories.d.ts +7 -0
- package/dist/esm/stories/ToolCard.stories.d.ts.map +1 -0
- package/dist/esm/stories/ToolCard.stories.js +12 -0
- package/dist/esm/stories/ToolCard.stories.js.map +1 -0
- package/dist/sparkle.css +4 -0
- package/package.json +1 -1
- package/src/components/Button.tsx +14 -9
- package/src/components/ContextItem.tsx +11 -2
- package/src/components/ConversationMessage.tsx +2 -2
- package/src/components/ToolCard.tsx +82 -0
- package/src/components/index.ts +1 -0
- package/src/stories/Button.stories.tsx +5 -0
- package/src/stories/ContextItem.stories.tsx +1 -0
- package/src/stories/ToolCard.stories.tsx +37 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
import { Avatar, Button, Card, Chip } from "@sparkle/components/";
|
|
4
|
+
import { PlusIcon } from "@sparkle/icons/app/";
|
|
5
|
+
import { cn } from "@sparkle/lib/utils";
|
|
6
|
+
|
|
7
|
+
const FADE_TRANSITION_CLASSES =
|
|
8
|
+
"s-transition-opacity s-duration-300 s-ease-in-out";
|
|
9
|
+
|
|
10
|
+
export interface ToolCardProps {
|
|
11
|
+
icon: React.ComponentType;
|
|
12
|
+
label: string;
|
|
13
|
+
description: string;
|
|
14
|
+
isSelected: boolean;
|
|
15
|
+
canAdd: boolean;
|
|
16
|
+
cantAddReason?: string;
|
|
17
|
+
onClick?: () => void;
|
|
18
|
+
className?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const ToolCard = React.forwardRef<HTMLDivElement, ToolCardProps>(
|
|
22
|
+
(
|
|
23
|
+
{
|
|
24
|
+
icon,
|
|
25
|
+
label,
|
|
26
|
+
description,
|
|
27
|
+
isSelected,
|
|
28
|
+
canAdd,
|
|
29
|
+
cantAddReason,
|
|
30
|
+
onClick,
|
|
31
|
+
className,
|
|
32
|
+
},
|
|
33
|
+
ref
|
|
34
|
+
) => {
|
|
35
|
+
return (
|
|
36
|
+
<Card
|
|
37
|
+
ref={ref}
|
|
38
|
+
variant={isSelected ? "secondary" : "primary"}
|
|
39
|
+
onClick={canAdd && !isSelected ? onClick : undefined}
|
|
40
|
+
disabled={!canAdd || isSelected}
|
|
41
|
+
className={cn("s-h-24 s-p-3", className)}
|
|
42
|
+
>
|
|
43
|
+
<div className="s-flex s-w-full s-flex-col">
|
|
44
|
+
<div className="s-mb-2 s-flex s-items-start s-justify-between s-gap-2">
|
|
45
|
+
<div className="s-flex s-items-center s-gap-2">
|
|
46
|
+
<Avatar icon={icon} size="sm" />
|
|
47
|
+
<span className="s-text-sm s-font-medium">{label}</span>
|
|
48
|
+
{isSelected && (
|
|
49
|
+
<Chip
|
|
50
|
+
size="xs"
|
|
51
|
+
color="green"
|
|
52
|
+
label="ADDED"
|
|
53
|
+
className={cn(FADE_TRANSITION_CLASSES, "s-opacity-100")}
|
|
54
|
+
/>
|
|
55
|
+
)}
|
|
56
|
+
</div>
|
|
57
|
+
{canAdd && !isSelected && (
|
|
58
|
+
<Button
|
|
59
|
+
size="xs"
|
|
60
|
+
variant="outline"
|
|
61
|
+
icon={PlusIcon}
|
|
62
|
+
label="Add"
|
|
63
|
+
className={cn(FADE_TRANSITION_CLASSES, "s-flex-shrink-0")}
|
|
64
|
+
/>
|
|
65
|
+
)}
|
|
66
|
+
{!canAdd && cantAddReason && (
|
|
67
|
+
<div className="s-flex-shrink-0 s-text-xs s-italic s-text-muted-foreground dark:s-text-muted-foreground-night">
|
|
68
|
+
{cantAddReason}
|
|
69
|
+
</div>
|
|
70
|
+
)}
|
|
71
|
+
</div>
|
|
72
|
+
<div className="s-line-clamp-2 s-h-10 s-overflow-hidden s-text-sm s-text-muted-foreground dark:s-text-muted-foreground-night">
|
|
73
|
+
{description}
|
|
74
|
+
</div>
|
|
75
|
+
</div>
|
|
76
|
+
</Card>
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
);
|
|
80
|
+
ToolCard.displayName = "ToolCard";
|
|
81
|
+
|
|
82
|
+
|
package/src/components/index.ts
CHANGED
|
@@ -174,6 +174,7 @@ export { default as Spinner } from "./Spinner";
|
|
|
174
174
|
export { FlexSplitButton, SplitButton } from "./SplitButton";
|
|
175
175
|
export { Tabs, TabsContent, TabsList, TabsTrigger } from "./Tabs";
|
|
176
176
|
export { ReadOnlyTextArea, TextArea } from "./TextArea";
|
|
177
|
+
export { ToolCard } from "./ToolCard";
|
|
177
178
|
export {
|
|
178
179
|
Tooltip,
|
|
179
180
|
TooltipContent,
|
|
@@ -59,6 +59,10 @@ const meta = {
|
|
|
59
59
|
description: "Whether the button should display a counter",
|
|
60
60
|
control: "boolean",
|
|
61
61
|
},
|
|
62
|
+
briefPulse: {
|
|
63
|
+
description: "Whether the button should display a brief pulse",
|
|
64
|
+
control: "boolean",
|
|
65
|
+
},
|
|
62
66
|
counterValue: {
|
|
63
67
|
description: "Value to display in the counter (if isCounter is true)",
|
|
64
68
|
control: "text",
|
|
@@ -88,6 +92,7 @@ export const ExampleButton: Story = {
|
|
|
88
92
|
isLoading: false,
|
|
89
93
|
isPulsing: false,
|
|
90
94
|
isSelect: false,
|
|
95
|
+
briefPulse: false,
|
|
91
96
|
disabled: false,
|
|
92
97
|
isCounter: false,
|
|
93
98
|
counterValue: "1",
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { Meta } from "@storybook/react";
|
|
2
|
+
import React from "react";
|
|
3
|
+
|
|
4
|
+
import { ToolCard } from "@sparkle/components";
|
|
5
|
+
import { BookOpenIcon, CommandLineIcon } from "@sparkle/icons/app";
|
|
6
|
+
|
|
7
|
+
const meta: Meta<typeof ToolCard> = {
|
|
8
|
+
title: "Modules/ToolCard",
|
|
9
|
+
component: ToolCard,
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export default meta;
|
|
13
|
+
|
|
14
|
+
export const Examples = () => (
|
|
15
|
+
<div className="s-grid s-grid-cols-2 s-gap-3">
|
|
16
|
+
{/* Not added */}
|
|
17
|
+
<ToolCard
|
|
18
|
+
icon={BookOpenIcon}
|
|
19
|
+
label="Image Generation"
|
|
20
|
+
description="Agent can generate images (GPT Image 1)."
|
|
21
|
+
isSelected={false}
|
|
22
|
+
canAdd={true}
|
|
23
|
+
onClick={() => console.log("Add Image Generation")}
|
|
24
|
+
/>
|
|
25
|
+
|
|
26
|
+
{/* Added */}
|
|
27
|
+
<ToolCard
|
|
28
|
+
icon={CommandLineIcon}
|
|
29
|
+
label="Reasoning"
|
|
30
|
+
description="Agent can decide to trigger a reasoning model for complex tasks."
|
|
31
|
+
isSelected={true}
|
|
32
|
+
canAdd={false}
|
|
33
|
+
/>
|
|
34
|
+
</div>
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
|