@dust-tt/sparkle 0.2.466 → 0.2.469-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.
@@ -32,76 +32,7 @@ export type ButtonVariantType = (typeof BUTTON_VARIANTS)[number];
32
32
  export const BUTTON_SIZES = ["mini", "xs", "sm", "md"] as const;
33
33
  export type ButtonSizeType = (typeof BUTTON_SIZES)[number];
34
34
 
35
- const styleVariants: Record<ButtonVariantType, string> = {
36
- primary: cn(
37
- "s-bg-primary-800 dark:s-bg-primary-800-night",
38
- "s-text-primary-50 dark:s-text-primary-50-night",
39
- "hover:s-bg-primary-light dark:hover:s-bg-primary-dark-night",
40
- "active:s-bg-primary-dark dark:active:s-bg-primary-light-night",
41
- "disabled:s-bg-primary-muted disabled:s-text-highlight-50/60 dark:disabled:s-bg-primary-muted-night"
42
- ),
43
- highlight: cn(
44
- "s-bg-highlight",
45
- "s-text-highlight-50",
46
- "hover:s-bg-highlight-light",
47
- "active:s-bg-highlight-dark",
48
- "disabled:s-bg-highlight-muted disabled:s-text-highlight-50/60 dark:disabled:s-bg-highlight-muted-night"
49
- ),
50
- warning: cn(
51
- "s-bg-warning",
52
- "s-text-warning-50",
53
- "hover:s-bg-warning-light",
54
- "active:s-bg-warning-dark",
55
- "disabled:s-bg-warning-muted disabled:s-text-highlight-50/60 dark:disabled:s-bg-warning-muted-night"
56
- ),
57
- outline: cn(
58
- "s-border",
59
- "s-border-border dark:s-border-border-night",
60
- "s-text-primary dark:s-text-primary-night",
61
- "s-bg-background dark:s-bg-background-night",
62
- "hover:s-text-primary dark:hover:s-text-primary-night",
63
- "hover:s-bg-primary-100 dark:hover:s-bg-primary-900",
64
- "hover:s-border-primary-150 dark:hover:s-border-border-night",
65
- "active:s-bg-primary-300 dark:active:s-bg-primary-900",
66
- "disabled:s-text-primary-muted dark:disabled:s-text-primary-muted-night",
67
- "disabled:s-border-primary-100 dark:disabled:s-border-primary-100-night"
68
- ),
69
- ghost: cn(
70
- "s-border",
71
- "s-border-border/0 dark:s-border-border-night/0",
72
- "s-text-foreground dark:s-text-white",
73
- "hover:s-bg-primary-100 dark:hover:s-bg-primary-900",
74
- "hover:s-text-primary-900 dark:hover:s-text-white",
75
- "hover:s-border-border-dark dark:hover:s-border-border-night",
76
- "active:s-bg-primary-300 dark:active:s-bg-primary-900",
77
- "disabled:s-text-primary-400 dark:disabled:s-text-primary-400-night"
78
- ),
79
- "ghost-secondary": cn(
80
- "s-border",
81
- "s-border-border/0 dark:s-border-border-night/0",
82
- "s-text-muted-foreground dark:s-text-muted-foreground-night",
83
- "hover:s-bg-primary-100 dark:hover:s-bg-primary-900",
84
- "hover:s-text-primary-900 dark:hover:s-text-primary-900-night",
85
- "hover:s-border-border-dark dark:hover:s-border-border-night",
86
- "active:s-bg-primary-300 dark:active:s-bg-primary-900",
87
- "disabled:s-text-primary-400 dark:disabled:s-text-primary-400-night"
88
- ),
89
- };
90
-
91
- const sizeVariants: Record<ButtonSizeType, string> = {
92
- mini: "s-h-7 s-p-1.5 s-rounded-lg s-label-xs s-gap-1.5",
93
- xs: "s-h-7 s-px-2.5 s-rounded-lg s-label-xs s-gap-1.5",
94
- sm: "s-h-9 s-px-3 s-rounded-xl s-label-sm s-gap-2",
95
- md: "s-h-12 s-px-4 s-py-2 s-rounded-2xl s-label-base s-gap-2.5",
96
- };
97
-
98
- const labelVariants: Record<ButtonSizeType, string> = {
99
- mini: "s-label-xs",
100
- xs: "s-label-xs",
101
- sm: "s-label-sm",
102
- md: "s-label-base",
103
- };
104
-
35
+ // Define button styling with cva
105
36
  const buttonVariants = cva(
106
37
  cn(
107
38
  "s-inline-flex s-items-center s-justify-center s-whitespace-nowrap s-ring-offset-background s-transition-colors",
@@ -110,44 +41,124 @@ const buttonVariants = cva(
110
41
  ),
111
42
  {
112
43
  variants: {
113
- variant: styleVariants,
114
- size: sizeVariants,
44
+ variant: {
45
+ primary: cn(
46
+ "s-bg-primary-800 dark:s-bg-primary-800-night",
47
+ "s-text-primary-50 dark:s-text-primary-50-night",
48
+ "hover:s-bg-primary-light dark:hover:s-bg-primary-dark-night",
49
+ "active:s-bg-primary-dark dark:active:s-bg-primary-light-night",
50
+ "disabled:s-bg-primary-muted disabled:s-text-highlight-50/60 dark:disabled:s-bg-primary-muted-night"
51
+ ),
52
+ highlight: cn(
53
+ "s-bg-highlight",
54
+ "s-text-highlight-50",
55
+ "hover:s-bg-highlight-light",
56
+ "active:s-bg-highlight-dark",
57
+ "disabled:s-bg-highlight-muted disabled:s-text-highlight-50/60 dark:disabled:s-bg-highlight-muted-night"
58
+ ),
59
+ warning: cn(
60
+ "s-bg-warning",
61
+ "s-text-warning-50",
62
+ "hover:s-bg-warning-light",
63
+ "active:s-bg-warning-dark",
64
+ "disabled:s-bg-warning-muted disabled:s-text-highlight-50/60 dark:disabled:s-bg-warning-muted-night"
65
+ ),
66
+ outline: cn(
67
+ "s-border",
68
+ "s-border-border dark:s-border-border-night",
69
+ "s-text-primary dark:s-text-primary-night",
70
+ "s-bg-background dark:s-bg-background-night",
71
+ "hover:s-text-primary dark:hover:s-text-primary-night",
72
+ "hover:s-bg-primary-100 dark:hover:s-bg-primary-900",
73
+ "hover:s-border-primary-150 dark:hover:s-border-border-night",
74
+ "active:s-bg-primary-300 dark:active:s-bg-primary-900",
75
+ "disabled:s-text-primary-muted dark:disabled:s-text-primary-muted-night",
76
+ "disabled:s-border-primary-100 dark:disabled:s-border-primary-100-night"
77
+ ),
78
+ ghost: cn(
79
+ "s-border",
80
+ "s-border-border/0 dark:s-border-border-night/0",
81
+ "s-text-foreground dark:s-text-white",
82
+ "hover:s-bg-primary-100 dark:hover:s-bg-primary-900",
83
+ "hover:s-text-primary-900 dark:hover:s-text-white",
84
+ "hover:s-border-border-dark dark:hover:s-border-border-night",
85
+ "active:s-bg-primary-300 dark:active:s-bg-primary-900",
86
+ "disabled:s-text-primary-400 dark:disabled:s-text-primary-400-night"
87
+ ),
88
+ "ghost-secondary": cn(
89
+ "s-border",
90
+ "s-border-border/0 dark:s-border-border-night/0",
91
+ "s-text-muted-foreground dark:s-text-muted-foreground-night",
92
+ "hover:s-bg-primary-100 dark:hover:s-bg-primary-900",
93
+ "hover:s-text-primary-900 dark:hover:s-text-primary-900-night",
94
+ "hover:s-border-border-dark dark:hover:s-border-border-night",
95
+ "active:s-bg-primary-300 dark:active:s-bg-primary-900",
96
+ "disabled:s-text-primary-400 dark:disabled:s-text-primary-400-night"
97
+ ),
98
+ },
99
+ size: {
100
+ mini: "s-h-7 s-p-1.5 s-rounded-lg s-label-xs s-gap-1.5",
101
+ xs: "s-h-7 s-px-2.5 s-rounded-lg s-label-xs s-gap-1.5",
102
+ sm: "s-h-9 s-px-3 s-rounded-xl s-label-sm s-gap-2",
103
+ md: "s-h-12 s-px-4 s-py-2 s-rounded-2xl s-label-base s-gap-2.5",
104
+ },
105
+ },
106
+ defaultVariants: {
107
+ variant: "primary",
108
+ size: "sm",
115
109
  },
116
110
  }
117
111
  );
118
112
 
113
+ const labelVariants = cva("", {
114
+ variants: {
115
+ size: {
116
+ mini: "s-label-xs",
117
+ xs: "s-label-xs",
118
+ sm: "s-label-sm",
119
+ md: "s-label-base",
120
+ },
121
+ },
122
+ defaultVariants: {
123
+ size: "sm",
124
+ },
125
+ });
126
+
119
127
  type SpinnerVariant = NonNullable<SpinnerProps["variant"]>;
120
128
 
121
129
  const spinnerVariantsMap: Record<ButtonVariantType, SpinnerVariant> = {
122
- primary: "light",
123
- highlight: "light",
124
- warning: "light",
125
- outline: "dark",
126
- ghost: "dark",
127
- "ghost-secondary": "dark",
130
+ primary: "gray50",
131
+ highlight: "gray50",
132
+ warning: "gray50",
133
+ outline: "gray500",
134
+ ghost: "gray500",
135
+ "ghost-secondary": "gray400",
128
136
  };
129
137
 
130
- const spinnerVariantsMapIsLoading: Record<ButtonVariantType, SpinnerVariant> = {
131
- primary: "light",
132
- highlight: "light",
133
- warning: "light",
134
- outline: "slate400",
135
- ghost: "slate400",
136
- "ghost-secondary": "dark",
137
- };
138
+ const chevronVariantMap = {
139
+ primary: "s-text-white/70",
140
+ outline: "s-text-foreground/70 dark:s-text-foreground-night/70",
141
+ ghost: "s-text-foreground/70 dark:s-text-foreground-night/70",
142
+ "ghost-secondary": "s-text-foreground/70 dark:s-text-foreground-night/70",
143
+ highlight: "s-text-white/70",
144
+ warning: "s-text-white/70",
145
+ } as const;
138
146
 
139
147
  export interface MetaButtonProps
140
148
  extends React.ButtonHTMLAttributes<HTMLButtonElement>,
141
149
  VariantProps<typeof buttonVariants> {
142
150
  asChild?: boolean;
143
- variant?: ButtonVariantType | null;
144
151
  }
145
152
 
146
153
  const MetaButton = React.forwardRef<HTMLButtonElement, MetaButtonProps>(
147
- ({ className, asChild = false, children, ...props }, ref) => {
154
+ ({ className, asChild = false, variant, size, children, ...props }, ref) => {
148
155
  const Comp = asChild ? Slot : "button";
149
156
  return (
150
- <Comp className={className} ref={ref} {...props}>
157
+ <Comp
158
+ className={cn(buttonVariants({ variant, size, className }))}
159
+ ref={ref}
160
+ {...props}
161
+ >
151
162
  {children}
152
163
  </Comp>
153
164
  );
@@ -204,12 +215,18 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
204
215
  ref
205
216
  ) => {
206
217
  const iconsSize = size === "mini" ? "sm" : size;
207
- const spinnerVariant = isLoading
208
- ? (variant && spinnerVariantsMapIsLoading[variant]) || "slate400"
209
- : (variant && spinnerVariantsMap[variant]) || "slate400";
218
+ const spinnerVariant =
219
+ (variant && spinnerVariantsMap[variant]) || "gray400";
210
220
 
211
221
  const renderIcon = (visual: React.ComponentType, extraClass = "") => (
212
- <Icon visual={visual} size={iconsSize} className={extraClass} />
222
+ <Icon visual={visual} size={iconsSize} className={cn(extraClass)} />
223
+ );
224
+ const renderChevron = (visual: React.ComponentType, extraClass = "") => (
225
+ <Icon
226
+ visual={visual}
227
+ size={iconsSize}
228
+ className={cn(variant ? chevronVariantMap[variant] : "", extraClass)}
229
+ />
213
230
  );
214
231
 
215
232
  const showCounter = isCounter && counterValue != null;
@@ -227,7 +244,10 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
227
244
 
228
245
  {showContainer && (
229
246
  <div
230
- className={cn("s-flex s-items-center s-gap-2", labelVariants[size])}
247
+ className={cn(
248
+ "s-flex s-items-center s-gap-2",
249
+ labelVariants({ size })
250
+ )}
231
251
  >
232
252
  {label}
233
253
  {showCounter && (
@@ -240,7 +260,7 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
240
260
  )}
241
261
  </div>
242
262
  )}
243
- {isSelect && renderIcon(ChevronDownIcon, isLoading ? "" : "-s-mr-1")}
263
+ {isSelect && renderChevron(ChevronDownIcon, isLoading ? "" : "-s-mr-1")}
244
264
  </>
245
265
  );
246
266
 
@@ -248,12 +268,9 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
248
268
  <MetaButton
249
269
  ref={ref}
250
270
  size={size}
271
+ variant={variant}
251
272
  disabled={isLoading || props.disabled}
252
- className={cn(
253
- buttonVariants({ variant, size }),
254
- isPulsing && "s-animate-pulse",
255
- className
256
- )}
273
+ className={cn(isPulsing && "s-animate-pulse", className)}
257
274
  aria-label={ariaLabel || tooltip || label}
258
275
  style={
259
276
  {
@@ -8,6 +8,13 @@ import { LinkWrapper, LinkWrapperProps } from "@sparkle/components/LinkWrapper";
8
8
  import { SearchInput, SearchInputProps } from "@sparkle/components/SearchInput";
9
9
  import { CheckIcon, ChevronRightIcon, CircleIcon } from "@sparkle/icons/app";
10
10
  import { cn } from "@sparkle/lib/utils";
11
+ import {
12
+ TooltipContent,
13
+ TooltipPortal,
14
+ TooltipProvider,
15
+ TooltipRoot,
16
+ TooltipTrigger,
17
+ } from "@sparkle/components/Tooltip";
11
18
 
12
19
  const ITEM_VARIANTS = ["default", "warning"] as const;
13
20
 
@@ -115,50 +122,155 @@ const ItemWithLabelIconAndDescription = <
115
122
  truncate,
116
123
  children,
117
124
  }: T) => {
118
- return (
119
- <>
120
- {label && (
121
- <div className="s-grid s-grid-cols-[auto,1fr,auto] s-items-center s-gap-x-2.5">
122
- {(icon || extraIcon) && (
123
- <div
124
- className={cn(
125
- "s-flex",
126
- description ? "s-items-start s-pt-0.5" : "s-items-center"
127
- )}
128
- >
129
- {icon && extraIcon ? (
130
- <DoubleIcon
131
- mainIconProps={{
132
- visual: icon,
133
- size: "sm",
134
- }}
135
- secondaryIconProps={{
136
- visual: extraIcon,
137
- size: "xs",
138
- }}
139
- position="bottom-right"
140
- />
141
- ) : icon ? (
142
- <Icon size="sm" visual={icon} />
143
- ) : null}
144
- </div>
145
- )}
146
- <div className="s-flex s-flex-col">
147
- <span className={truncate ? "s-line-clamp-1" : undefined}>
148
- {label}
149
- </span>
150
- {description && (
151
- <span
125
+ const labelRef = React.useRef<HTMLSpanElement>(null);
126
+ const descriptionRef = React.useRef<HTMLSpanElement>(null);
127
+ const [showTooltip, setShowTooltip] = React.useState(false);
128
+
129
+ const checkTruncation = React.useCallback(() => {
130
+ let isTruncated = false;
131
+
132
+ if (labelRef.current) {
133
+ isTruncated = labelRef.current.scrollWidth > labelRef.current.clientWidth;
134
+ }
135
+
136
+ if (descriptionRef.current && !isTruncated) {
137
+ isTruncated =
138
+ descriptionRef.current.scrollWidth > descriptionRef.current.clientWidth;
139
+ }
140
+
141
+ setShowTooltip(isTruncated);
142
+ }, []);
143
+
144
+ React.useEffect(() => {
145
+ if (!truncate) {
146
+ return;
147
+ }
148
+
149
+ const observer = new ResizeObserver(checkTruncation);
150
+
151
+ if (labelRef.current) {
152
+ observer.observe(labelRef.current);
153
+ }
154
+
155
+ if (descriptionRef.current) {
156
+ observer.observe(descriptionRef.current);
157
+ }
158
+
159
+ // Initial check
160
+ checkTruncation();
161
+
162
+ return () => observer.disconnect();
163
+ }, [truncate, checkTruncation]);
164
+
165
+ if (!truncate) {
166
+ return (
167
+ <>
168
+ {label && (
169
+ <div className="s-grid s-grid-cols-[auto,1fr,auto] s-items-center s-gap-x-2.5">
170
+ {(icon || extraIcon) && (
171
+ <div
152
172
  className={cn(
153
- menuStyleClasses.description,
154
- truncate && "s-line-clamp-1"
173
+ "s-flex",
174
+ description ? "s-items-start s-pt-0.5" : "s-items-center"
155
175
  )}
156
176
  >
157
- {description}
158
- </span>
177
+ {icon && extraIcon ? (
178
+ <DoubleIcon
179
+ mainIconProps={{
180
+ visual: icon,
181
+ size: "sm",
182
+ }}
183
+ secondaryIconProps={{
184
+ visual: extraIcon,
185
+ size: "xs",
186
+ }}
187
+ position="bottom-right"
188
+ />
189
+ ) : icon ? (
190
+ <Icon size="sm" visual={icon} />
191
+ ) : null}
192
+ </div>
159
193
  )}
194
+ <div className="s-flex s-flex-col">
195
+ <span>{label}</span>
196
+ {description && (
197
+ <span className={menuStyleClasses.description}>
198
+ {description}
199
+ </span>
200
+ )}
201
+ </div>
160
202
  </div>
161
- </div>
203
+ )}
204
+ {children}
205
+ </>
206
+ );
207
+ }
208
+
209
+ return (
210
+ <>
211
+ {label && (
212
+ <TooltipProvider>
213
+ <TooltipRoot>
214
+ <TooltipTrigger asChild>
215
+ <div className="s-grid s-grid-cols-[auto,1fr,auto] s-items-center s-gap-x-2.5">
216
+ {(icon || extraIcon) && (
217
+ <div
218
+ className={cn(
219
+ "s-flex",
220
+ description ? "s-items-start s-pt-0.5" : "s-items-center"
221
+ )}
222
+ >
223
+ {icon && extraIcon ? (
224
+ <DoubleIcon
225
+ mainIconProps={{
226
+ visual: icon,
227
+ size: "sm",
228
+ }}
229
+ secondaryIconProps={{
230
+ visual: extraIcon,
231
+ size: "xs",
232
+ }}
233
+ position="bottom-right"
234
+ />
235
+ ) : icon ? (
236
+ <Icon size="sm" visual={icon} />
237
+ ) : null}
238
+ </div>
239
+ )}
240
+ <div className="s-flex s-flex-col">
241
+ <span ref={labelRef} className="s-line-clamp-1">
242
+ {label}
243
+ </span>
244
+ {description && (
245
+ <span
246
+ ref={descriptionRef}
247
+ className={cn(
248
+ menuStyleClasses.description,
249
+ "s-line-clamp-1"
250
+ )}
251
+ >
252
+ {description}
253
+ </span>
254
+ )}
255
+ </div>
256
+ </div>
257
+ </TooltipTrigger>
258
+ {showTooltip && (
259
+ <TooltipPortal>
260
+ <TooltipContent side="top" align="start" className="s-max-w-sm">
261
+ <div className="s-flex s-flex-col s-gap-1">
262
+ <div>{label}</div>
263
+ {description && (
264
+ <div className={menuStyleClasses.description}>
265
+ {description}
266
+ </div>
267
+ )}
268
+ </div>
269
+ </TooltipContent>
270
+ </TooltipPortal>
271
+ )}
272
+ </TooltipRoot>
273
+ </TooltipProvider>
162
274
  )}
163
275
  {children}
164
276
  </>
@@ -0,0 +1,30 @@
1
+ import type { SVGProps } from "react";
2
+ import * as React from "react";
3
+ const SvgLinear = (props: SVGProps<SVGSVGElement>) => (
4
+ <svg
5
+ width="1em"
6
+ height="1em"
7
+ viewBox="0 0 24 24"
8
+ fill="none"
9
+ xmlns="http://www.w3.org/2000/svg"
10
+ {...props}
11
+ >
12
+ <path
13
+ d="M3.03509 12.9431C3.24245 14.9227 4.10472 16.8468 5.62188 18.364C7.13904 19.8811 9.0631 20.7434 11.0428 20.9508L3.03509 12.9431Z"
14
+ fill="#000000"
15
+ />
16
+ <path
17
+ d="M3 11.4938L12.4921 20.9858C13.2976 20.9407 14.0981 20.7879 14.8704 20.5273L3.4585 9.11548C3.19793 9.88771 3.0451 10.6883 3 11.4938Z"
18
+ fill="#000000"
19
+ />
20
+ <path
21
+ d="M3.86722 8.10999L15.8758 20.1186C16.4988 19.8201 17.0946 19.4458 17.6493 18.9956L4.99021 6.33659C4.54006 6.89125 4.16573 7.487 3.86722 8.10999Z"
22
+ fill="#000000"
23
+ />
24
+ <path
25
+ d="M5.66301 5.59517C9.18091 2.12137 14.8488 2.135 18.3498 5.63604C21.8508 9.13708 21.8645 14.8049 18.3907 18.3228L5.66301 5.59517Z"
26
+ fill="#000000"
27
+ />
28
+ </svg>
29
+ );
30
+ export default SvgLinear;
@@ -22,6 +22,7 @@ export { default as Gpt4Logo } from "./Gpt4";
22
22
  export { default as HubspotLogo } from "./Hubspot";
23
23
  export { default as HuggingFaceLogo } from "./HuggingFace";
24
24
  export { default as IntercomLogo } from "./Intercom";
25
+ export { default as LinearLogo } from "./Linear";
25
26
  export { default as MicrosoftLogo } from "./Microsoft";
26
27
  export { default as MicrosoftExcelLogo } from "./MicrosoftExcel";
27
28
  export { default as MicrosoftPowerpointLogo } from "./MicrosoftPowerpoint";