@dust-tt/sparkle 0.2.474-rc → 0.2.474-rc-5

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.
@@ -19,32 +19,6 @@ const positionVariants = cva("s-flex s-absolute", {
19
19
  },
20
20
  });
21
21
 
22
- const sizeVariants = cva("s-relative", {
23
- variants: {
24
- size: {
25
- md: "s-h-6 s-w-6",
26
- lg: "s-h-8 s-w-8 s-p-0.5",
27
- xl: "s-h-10 s-w-10",
28
- },
29
- },
30
- defaultVariants: {
31
- size: "lg",
32
- },
33
- });
34
-
35
- const iconSizeVariants = cva("s-absolute", {
36
- variants: {
37
- size: {
38
- md: "s-bottom-0 s-right-0",
39
- lg: "s-bottom-0 s-right-0",
40
- xl: "s-bottom-0 s-right-0",
41
- },
42
- },
43
- defaultVariants: {
44
- size: "lg",
45
- },
46
- });
47
-
48
22
  export interface DoubleIconProps extends VariantProps<typeof positionVariants> {
49
23
  mainIconProps: IconProps;
50
24
  secondaryIconProps: IconProps;
@@ -67,33 +41,3 @@ export const DoubleIcon = ({
67
41
  </div>
68
42
  );
69
43
  };
70
-
71
- export interface SimpleDoubleIconProps
72
- extends VariantProps<typeof sizeVariants> {
73
- mainIcon: React.ComponentType;
74
- secondaryIcon: React.ComponentType;
75
- size?: "md" | "lg" | "xl";
76
- className?: string;
77
- }
78
-
79
- export const SimpleDoubleIcon = ({
80
- mainIcon,
81
- secondaryIcon,
82
- className,
83
- size = "lg",
84
- }: SimpleDoubleIconProps) => {
85
- return (
86
- <div className={cn(sizeVariants({ size }), className)}>
87
- <Icon
88
- className="s-text-foreground dark:s-text-foreground-night"
89
- size={size === "md" ? "sm" : size === "lg" ? "md" : "lg"}
90
- visual={mainIcon}
91
- />
92
- <Icon
93
- size={size === "md" ? "xs" : size === "lg" ? "xs" : "md"}
94
- visual={secondaryIcon}
95
- className={cn("s-absolute", iconSizeVariants({ size }))}
96
- />
97
- </div>
98
- );
99
- };
@@ -3,8 +3,10 @@ import { cva } from "class-variance-authority";
3
3
  import * as React from "react";
4
4
  import { useRef } from "react";
5
5
 
6
+ import { DoubleIcon } from "@sparkle/components/DoubleIcon";
6
7
  import { Icon } from "@sparkle/components/Icon";
7
8
  import { LinkWrapper, LinkWrapperProps } from "@sparkle/components/LinkWrapper";
9
+ import { ScrollArea } from "@sparkle/components/ScrollArea";
8
10
  import { SearchInput, SearchInputProps } from "@sparkle/components/SearchInput";
9
11
  import { CheckIcon, ChevronRightIcon, CircleIcon } from "@sparkle/icons/app";
10
12
  import { cn } from "@sparkle/lib/utils";
@@ -20,7 +22,7 @@ export const menuStyleClasses = {
20
22
  "s-border s-border-border dark:s-border-border-night",
21
23
  "s-bg-background dark:s-bg-muted-background-night",
22
24
  "s-text-foreground dark:s-text-foreground-night",
23
- "s-z-50 s-min-w-[8rem] s-overflow-hidden",
25
+ "s-z-50 s-min-w-[8rem]",
24
26
  "data-[state=open]:s-animate-in data-[state=closed]:s-animate-out data-[state=closed]:s-fade-out-0 data-[state=open]:s-fade-in-0 data-[state=closed]:s-zoom-out-95 data-[state=open]:s-zoom-in-95 data-[side=bottom]:s-slide-in-from-top-2 data-[side=left]:s-slide-in-from-right-2 data-[side=right]:s-slide-in-from-left-2 data-[side=top]:s-slide-in-from-bottom-2"
25
27
  ),
26
28
  item: cva(
@@ -83,7 +85,7 @@ const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
83
85
 
84
86
  interface LabelAndIconProps {
85
87
  label: string;
86
- icon?: React.ComponentType | React.ReactNode;
88
+ icon?: React.ComponentType;
87
89
  }
88
90
 
89
91
  type Simplify<T> = { [K in keyof T]: T[K] };
@@ -98,27 +100,19 @@ type MutuallyExclusiveProps<BaseProps, ExtraProps> = Simplify<
98
100
 
99
101
  interface ItemWithLabelIconAndDescriptionProps {
100
102
  label?: string;
101
- icon?: React.ComponentType | React.ReactNode;
103
+ icon?: React.ComponentType;
104
+ extraIcon?: React.ComponentType;
102
105
  description?: string;
103
106
  children?: React.ReactNode;
104
107
  truncate?: boolean;
105
108
  }
106
109
 
107
- const renderIcon = (
108
- icon: React.ComponentType | React.ReactNode,
109
- size: "xs" | "sm" = "xs"
110
- ) => {
111
- if (!icon) {
112
- return null;
113
- }
114
- return typeof icon === "function" ? <Icon size={size} visual={icon} /> : icon;
115
- };
116
-
117
110
  const ItemWithLabelIconAndDescription = <
118
111
  T extends ItemWithLabelIconAndDescriptionProps,
119
112
  >({
120
113
  label,
121
114
  icon,
115
+ extraIcon,
122
116
  description,
123
117
  truncate,
124
118
  children,
@@ -127,7 +121,30 @@ const ItemWithLabelIconAndDescription = <
127
121
  <>
128
122
  {label && (
129
123
  <div className="s-grid s-grid-cols-[auto,1fr,auto] s-items-center s-gap-x-2.5">
130
- {renderIcon(icon, "sm")}
124
+ {(icon || extraIcon) && (
125
+ <div
126
+ className={cn(
127
+ "s-flex",
128
+ description ? "s-items-start s-pt-0.5" : "s-items-center"
129
+ )}
130
+ >
131
+ {icon && extraIcon ? (
132
+ <DoubleIcon
133
+ mainIconProps={{
134
+ visual: icon,
135
+ size: "sm",
136
+ }}
137
+ secondaryIconProps={{
138
+ visual: extraIcon,
139
+ size: "xs",
140
+ }}
141
+ position="bottom-right"
142
+ />
143
+ ) : icon ? (
144
+ <Icon size="sm" visual={icon} />
145
+ ) : null}
146
+ </div>
147
+ )}
131
148
  <div className="s-flex s-flex-col">
132
149
  <span className={truncate ? "s-line-clamp-1" : undefined}>
133
150
  {label}
@@ -170,7 +187,7 @@ const DropdownMenuSubTrigger = React.forwardRef<
170
187
  >
171
188
  {label && (
172
189
  <>
173
- {renderIcon(icon)}
190
+ {icon && <Icon size="xs" visual={icon} />}
174
191
  {label}
175
192
  <span className={menuStyleClasses.subTrigger.default}>
176
193
  <Icon size="xs" visual={ChevronRightIcon} />
@@ -186,12 +203,28 @@ DropdownMenuSubTrigger.displayName =
186
203
  const DropdownMenuSubContent = React.forwardRef<
187
204
  React.ElementRef<typeof DropdownMenuPrimitive.SubContent>,
188
205
  React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubContent>
189
- >(({ className, ...props }, ref) => (
206
+ >(({ className, children, ...props }, ref) => (
190
207
  <DropdownMenuPrimitive.SubContent
191
208
  ref={ref}
192
- className={cn(menuStyleClasses.container, "s-shadow-lg", className)}
209
+ className={cn(
210
+ menuStyleClasses.container,
211
+ "s-flex s-flex-col s-p-0 s-shadow-lg",
212
+ className
213
+ )}
193
214
  {...props}
194
- />
215
+ >
216
+ <ScrollArea
217
+ className="s-w-full s-flex-1"
218
+ hideScrollBar={false}
219
+ orientation="vertical"
220
+ viewportClassName={cn(
221
+ "s-flex-1",
222
+ "s-max-h-[calc(var(--radix-dropdown-menu-content-available-height)-var(--header-height,20px))]"
223
+ )}
224
+ >
225
+ <div className="s-p-1">{children}</div>
226
+ </ScrollArea>
227
+ </DropdownMenuPrimitive.SubContent>
195
228
  ));
196
229
  DropdownMenuSubContent.displayName =
197
230
  DropdownMenuPrimitive.SubContent.displayName;
@@ -200,6 +233,7 @@ interface DropdownMenuContentProps
200
233
  extends React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content> {
201
234
  mountPortal?: boolean;
202
235
  mountPortalContainer?: HTMLElement;
236
+ dropdownHeaders?: React.ReactNode;
203
237
  }
204
238
 
205
239
  const DropdownMenuContent = React.forwardRef<
@@ -212,6 +246,8 @@ const DropdownMenuContent = React.forwardRef<
212
246
  sideOffset = 4,
213
247
  mountPortal = true,
214
248
  mountPortalContainer,
249
+ dropdownHeaders,
250
+ children,
215
251
  ...props
216
252
  },
217
253
  ref
@@ -220,9 +256,26 @@ const DropdownMenuContent = React.forwardRef<
220
256
  <DropdownMenuPrimitive.Content
221
257
  ref={ref}
222
258
  sideOffset={sideOffset}
223
- className={cn(menuStyleClasses.container, "s-shadow-md", className)}
259
+ className={cn(
260
+ menuStyleClasses.container,
261
+ "s-flex s-flex-col s-p-0 s-shadow-md",
262
+ className
263
+ )}
224
264
  {...props}
225
- />
265
+ >
266
+ <div className="s-sticky s-top-0 s-bg-background dark:s-bg-background-night">
267
+ {dropdownHeaders && dropdownHeaders}
268
+ </div>
269
+ <ScrollArea
270
+ className="s-w-full s-flex-1"
271
+ viewportClassName={cn(
272
+ "s-flex-1",
273
+ "s-max-h-[calc(var(--radix-dropdown-menu-content-available-height)-var(--header-height,20px))]"
274
+ )}
275
+ >
276
+ {children}
277
+ </ScrollArea>
278
+ </DropdownMenuPrimitive.Content>
226
279
  );
227
280
 
228
281
  const [container, setContainer] = React.useState<Element | undefined>(
@@ -257,6 +310,7 @@ export type DropdownMenuItemProps = MutuallyExclusiveProps<
257
310
  } & Omit<LinkWrapperProps, "children" | "className">,
258
311
  LabelAndIconProps & {
259
312
  description?: string;
313
+ extraIcon?: React.ComponentType;
260
314
  truncateText?: boolean;
261
315
  }
262
316
  >;
@@ -273,6 +327,7 @@ const DropdownMenuItem = React.forwardRef<
273
327
  className,
274
328
  inset,
275
329
  icon,
330
+ extraIcon,
276
331
  truncateText,
277
332
  label,
278
333
  href,
@@ -308,6 +363,7 @@ const DropdownMenuItem = React.forwardRef<
308
363
  <ItemWithLabelIconAndDescription
309
364
  label={label}
310
365
  icon={icon}
366
+ extraIcon={extraIcon}
311
367
  description={description}
312
368
  truncate={truncateText}
313
369
  >
@@ -79,7 +79,7 @@ export function Tree({
79
79
  const treeItemStyleClasses = {
80
80
  base: "s-group/tree s-flex s-cursor-default s-flex-row s-items-center s-gap-2 s-h-9",
81
81
  isNavigatableBase:
82
- "s-rounded-xl s-pl-1.5 s-pr-3 s-transition-colors s-duration-300 s-ease-out s-cursor-pointer",
82
+ "s-rounded-xl s-pl-1 s-pr-3 s-transition-colors s-duration-300 s-ease-out s-cursor-pointer",
83
83
  isNavigatableUnselected: cn(
84
84
  "s-bg-primary-100/0 dark:s-bg-primary-100-night/0",
85
85
  "hover:s-bg-primary-100 dark:hover:s-bg-primary-100-night"
@@ -2,10 +2,8 @@ import type { Meta } from "@storybook/react";
2
2
  import React from "react";
3
3
 
4
4
  import { DoubleIcon } from "@sparkle/components";
5
- import { SimpleDoubleIcon } from "@sparkle/components/DoubleIcon";
6
5
  import {
7
6
  ChatBubbleBottomCenterTextIcon,
8
- ChatBubbleThoughtIcon,
9
7
  CheckCircleIcon,
10
8
  DocumentIcon,
11
9
  FolderIcon,
@@ -15,7 +13,7 @@ import {
15
13
  StarIcon,
16
14
  UserIcon,
17
15
  } from "@sparkle/icons/app";
18
- import { DriveLogo, NotionLogo, SlackLogo } from "@sparkle/logo";
16
+ import { SlackLogo } from "@sparkle/logo";
19
17
 
20
18
  const meta = {
21
19
  title: "Primitives/DoubleIcon",
@@ -26,57 +24,6 @@ export default meta;
26
24
 
27
25
  export const IconPositions = () => (
28
26
  <div className="s-flex s-flex-col s-gap-8">
29
- <div className="s-flex s-items-center s-gap-8">
30
- <SimpleDoubleIcon
31
- size="xl"
32
- mainIcon={FolderIcon}
33
- secondaryIcon={DriveLogo}
34
- />{" "}
35
- <SimpleDoubleIcon
36
- size="xl"
37
- mainIcon={DocumentIcon}
38
- secondaryIcon={NotionLogo}
39
- />{" "}
40
- <SimpleDoubleIcon
41
- size="xl"
42
- mainIcon={ChatBubbleThoughtIcon}
43
- secondaryIcon={SlackLogo}
44
- />
45
- </div>
46
- <div className="s-flex s-items-center s-gap-8">
47
- <SimpleDoubleIcon
48
- size="lg"
49
- mainIcon={FolderIcon}
50
- secondaryIcon={DriveLogo}
51
- />{" "}
52
- <SimpleDoubleIcon
53
- size="lg"
54
- mainIcon={DocumentIcon}
55
- secondaryIcon={NotionLogo}
56
- />{" "}
57
- <SimpleDoubleIcon
58
- size="lg"
59
- mainIcon={ChatBubbleThoughtIcon}
60
- secondaryIcon={SlackLogo}
61
- />
62
- </div>
63
- <div className="s-flex s-items-center s-gap-8">
64
- <SimpleDoubleIcon
65
- size="md"
66
- mainIcon={FolderIcon}
67
- secondaryIcon={DriveLogo}
68
- />{" "}
69
- <SimpleDoubleIcon
70
- size="md"
71
- mainIcon={DocumentIcon}
72
- secondaryIcon={NotionLogo}
73
- />{" "}
74
- <SimpleDoubleIcon
75
- size="md"
76
- mainIcon={ChatBubbleThoughtIcon}
77
- secondaryIcon={SlackLogo}
78
- />
79
- </div>
80
27
  <div className="s-flex s-items-center s-gap-16">
81
28
  <div className="s-flex s-flex-col s-items-center s-gap-2">
82
29
  <DoubleIcon
@@ -146,6 +93,7 @@ export const IconPositions = () => (
146
93
  <span className="s-text-xs s-text-muted-foreground">top-left</span>
147
94
  </div>
148
95
  </div>
96
+
149
97
  <div className="s-flex s-items-center s-gap-16">
150
98
  <div className="s-flex s-flex-col s-items-center s-gap-2">
151
99
  <DoubleIcon
@@ -2,7 +2,6 @@ import { DropdownMenuCheckboxItemProps } from "@radix-ui/react-dropdown-menu";
2
2
  import type { Meta } from "@storybook/react";
3
3
  import React from "react";
4
4
 
5
- import { SimpleDoubleIcon } from "@sparkle/components/DoubleIcon";
6
5
  import {
7
6
  DropdownMenu,
8
7
  DropdownMenuCheckboxItem,
@@ -13,6 +12,7 @@ import {
13
12
  DropdownMenuPortal,
14
13
  DropdownMenuRadioGroup,
15
14
  DropdownMenuRadioItem,
15
+ DropdownMenuSearchbar,
16
16
  DropdownMenuSeparator,
17
17
  DropdownMenuStaticItem,
18
18
  DropdownMenuSub,
@@ -56,7 +56,6 @@ import {
56
56
  MagnifyingGlassIcon,
57
57
  PlusIcon,
58
58
  RobotIcon,
59
- ScrollArea,
60
59
  SearchInput,
61
60
  SuitcaseIcon,
62
61
  UserGroupIcon,
@@ -156,6 +155,14 @@ function ComplexDropdownDemo() {
156
155
  />
157
156
  <DropdownMenuSeparator />
158
157
  <DropdownMenuItem icon={UserIcon} label="More..." />
158
+ <DropdownMenuItem icon={UserIcon} label="More.." />
159
+ <DropdownMenuItem icon={UserIcon} label="More..." />
160
+ <DropdownMenuItem icon={UserIcon} label="More.." />
161
+ <DropdownMenuItem icon={UserIcon} label="More" />
162
+ <DropdownMenuItem icon={UserIcon} label="More....." />
163
+ <DropdownMenuItem icon={UserIcon} label="More.." />
164
+ <DropdownMenuItem icon={UserIcon} label="More" />
165
+ <DropdownMenuItem icon={UserIcon} label="More...." />
159
166
  </DropdownMenuSubContent>
160
167
  </DropdownMenuPortal>
161
168
  </DropdownMenuSub>
@@ -519,84 +526,77 @@ function AttachFileDemo() {
519
526
  <Button icon={ArrowUpOnSquareIcon} label="Upload File" />
520
527
  </div>
521
528
  <DropdownMenuSeparator />
522
- <ScrollArea className="s-h-[380px]">
523
- {searchText ? (
524
- filteredItems.map((item) => {
525
- const randomMainIcon =
526
- mainIcons[Math.floor(Math.random() * mainIcons.length)];
527
- const randomExtraIcon =
528
- extraIcons[Math.floor(Math.random() * extraIcons.length)];
529
- return (
530
- <DropdownMenuItem
531
- key={item}
532
- label={item}
533
- description="Company Space/Notion"
534
- icon={
535
- <SimpleDoubleIcon
536
- size="lg"
537
- mainIcon={randomMainIcon}
538
- secondaryIcon={randomExtraIcon}
539
- />
540
- }
541
- onClick={() => {
542
- setSelectedItem(item);
543
- setSearchText("");
544
- }}
545
- truncateText
546
- />
547
- );
548
- })
549
- ) : (
550
- <div className="s-flex s-h-full s-w-full s-items-center s-justify-center s-py-8">
551
- <div className="s-flex s-flex-col s-items-center s-justify-center s-gap-0 s-text-center s-text-base s-font-semibold s-text-primary-400">
552
- <Icon visual={MagnifyingGlassIcon} size="sm" />
553
- Search in Dust
554
- </div>
529
+ {searchText ? (
530
+ filteredItems.map((item) => {
531
+ const randomMainIcon =
532
+ mainIcons[Math.floor(Math.random() * mainIcons.length)];
533
+ const randomExtraIcon =
534
+ extraIcons[Math.floor(Math.random() * extraIcons.length)];
535
+ return (
536
+ <DropdownMenuItem
537
+ key={item}
538
+ label={item}
539
+ description="Company Space/Notion"
540
+ icon={randomMainIcon}
541
+ extraIcon={randomExtraIcon}
542
+ onClick={() => {
543
+ setSelectedItem(item);
544
+ setSearchText("");
545
+ }}
546
+ truncateText
547
+ />
548
+ );
549
+ })
550
+ ) : (
551
+ <div className="s-flex s-h-full s-w-full s-items-center s-justify-center s-py-8">
552
+ <div className="s-flex s-flex-col s-items-center s-justify-center s-gap-0 s-text-center s-text-base s-font-semibold s-text-primary-400">
553
+ <Icon visual={MagnifyingGlassIcon} size="sm" />
554
+ Search in Dust
555
555
  </div>
556
- )}
557
- </ScrollArea>
556
+ </div>
557
+ )}
558
558
  </DropdownMenuContent>
559
559
  </DropdownMenu>
560
560
  <DropdownMenu open={openAgents} onOpenChange={setOpenAgents}>
561
561
  <DropdownMenuTrigger asChild>
562
562
  <Button icon={RobotIcon} variant="outline" size="sm" isSelect />
563
563
  </DropdownMenuTrigger>
564
- <DropdownMenuContent className="s-w-[380px]">
565
- <div className="s-flex s-gap-1.5 s-p-1.5">
566
- <SearchInput
564
+ <DropdownMenuContent
565
+ className="s-h-96 s-w-[380px]"
566
+ dropdownHeaders={
567
+ <DropdownMenuSearchbar
567
568
  ref={agentsSearchInputRef}
568
569
  name="search"
569
570
  onChange={() => {}}
570
571
  onKeyDown={() => {}}
571
572
  placeholder="Search Agents"
572
573
  value=""
574
+ button={<Button icon={PlusIcon} label="Create" />}
573
575
  />
574
- <Button icon={PlusIcon} label="Create" />
575
- </div>
576
+ }
577
+ >
576
578
  <DropdownMenuSeparator />
577
- <ScrollArea className="s-h-[380px]">
578
- {filteredAgents.map((agent) => {
579
- return (
580
- <DropdownMenuItem
581
- key={agent.name}
582
- label={agent.name}
583
- description={agent.description}
584
- icon={() => (
585
- <Avatar
586
- size="sm"
587
- emoji={agent.emoji}
588
- backgroundColor={agent.backgroundColor}
589
- />
590
- )}
591
- onClick={() => {
592
- setSelectedItem(agent.name);
593
- setSearchText("");
594
- }}
595
- truncateText
596
- />
597
- );
598
- })}
599
- </ScrollArea>
579
+ {filteredAgents.map((agent) => {
580
+ return (
581
+ <DropdownMenuItem
582
+ key={agent.name}
583
+ label={agent.name}
584
+ description={agent.description}
585
+ icon={() => (
586
+ <Avatar
587
+ size="sm"
588
+ emoji={agent.emoji}
589
+ backgroundColor={agent.backgroundColor}
590
+ />
591
+ )}
592
+ onClick={() => {
593
+ setSelectedItem(agent.name);
594
+ setSearchText("");
595
+ }}
596
+ truncateText
597
+ />
598
+ );
599
+ })}
600
600
  </DropdownMenuContent>
601
601
  </DropdownMenu>
602
602
  <DropdownMenu open={openToolsets} onOpenChange={setOpenToolsets}>
@@ -608,36 +608,36 @@ function AttachFileDemo() {
608
608
  size="sm"
609
609
  />
610
610
  </DropdownMenuTrigger>
611
- <DropdownMenuContent className="s-w-[380px]">
612
- <div className="s-flex s-gap-1.5 s-p-1.5">
613
- <SearchInput
611
+ <DropdownMenuContent
612
+ className="s-h-96 s-w-[380px]"
613
+ dropdownHeaders={
614
+ <DropdownMenuSearchbar
614
615
  ref={toolsetsSearchInputRef}
615
616
  name="search"
616
617
  onChange={() => {}}
617
618
  onKeyDown={() => {}}
618
619
  placeholder="Search Tools"
619
620
  value=""
621
+ button={<Button icon={PlusIcon} label="Add MCP Server" />}
620
622
  />
621
- <Button icon={PlusIcon} label="Add MCP Server" />
622
- </div>
623
+ }
624
+ >
623
625
  <DropdownMenuSeparator />
624
- <ScrollArea className="s-h-[380px]">
625
- {filteredToolsetList.map((toolset) => {
626
- return (
627
- <DropdownMenuItem
628
- key={toolset.name}
629
- label={toolset.name}
630
- description={toolset.description}
631
- icon={() => <Avatar size="sm" icon={toolset.icon} />}
632
- onClick={() => {
633
- setSelectedItem(toolset.name);
634
- setSearchText("");
635
- }}
636
- truncateText
637
- />
638
- );
639
- })}
640
- </ScrollArea>
626
+ {filteredToolsetList.map((toolset) => {
627
+ return (
628
+ <DropdownMenuItem
629
+ key={toolset.name}
630
+ label={toolset.name}
631
+ description={toolset.description}
632
+ icon={() => <Avatar size="sm" icon={toolset.icon} />}
633
+ onClick={() => {
634
+ setSelectedItem(toolset.name);
635
+ setSearchText("");
636
+ }}
637
+ truncateText
638
+ />
639
+ );
640
+ })}
641
641
  </DropdownMenuContent>
642
642
  </DropdownMenu>
643
643
  </div>