@dust-tt/sparkle 0.2.615 → 0.2.617-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/Avatar.d.ts +1 -1
- package/dist/esm/components/Avatar.js +4 -4
- package/dist/esm/components/Avatar.js.map +1 -1
- package/dist/esm/components/DataTable.d.ts.map +1 -1
- package/dist/esm/components/DataTable.js +50 -12
- package/dist/esm/components/DataTable.js.map +1 -1
- package/dist/esm/components/NavigationList.d.ts +1 -4
- package/dist/esm/components/NavigationList.d.ts.map +1 -1
- package/dist/esm/components/NavigationList.js +2 -2
- package/dist/esm/components/NavigationList.js.map +1 -1
- package/dist/esm/components/ScrollArea.d.ts +0 -1
- package/dist/esm/components/ScrollArea.d.ts.map +1 -1
- package/dist/esm/components/ScrollArea.js +4 -7
- package/dist/esm/components/ScrollArea.js.map +1 -1
- package/dist/esm/components/Spinner.d.ts +1 -1
- package/dist/esm/components/Spinner.js +7 -7
- package/dist/esm/components/Spinner.js.map +1 -1
- package/dist/esm/components/ToolCard.d.ts +0 -6
- package/dist/esm/components/ToolCard.d.ts.map +1 -1
- package/dist/esm/components/ToolCard.js +11 -18
- package/dist/esm/components/ToolCard.js.map +1 -1
- package/dist/esm/components/Tooltip.d.ts.map +1 -1
- package/dist/esm/components/Tooltip.js.map +1 -1
- package/dist/esm/components/WindowUtility.d.ts +2 -3
- package/dist/esm/components/WindowUtility.d.ts.map +1 -1
- package/dist/esm/components/WindowUtility.js +17 -25
- package/dist/esm/components/WindowUtility.js.map +1 -1
- package/dist/esm/components/markdown/CodeBlock.d.ts +1 -2
- package/dist/esm/components/markdown/CodeBlock.d.ts.map +1 -1
- package/dist/esm/components/markdown/CodeBlock.js +2 -9
- package/dist/esm/components/markdown/CodeBlock.js.map +1 -1
- package/dist/esm/index.d.ts +0 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +0 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/stories/Avatar.stories.js +4 -4
- package/dist/esm/stories/MultiPageDialog.stories.js +1 -1
- package/dist/esm/stories/MultiPageDialog.stories.js.map +1 -1
- package/dist/esm/stories/Spinner.stories.js +3 -3
- package/dist/esm/stories/ToolCard.stories.d.ts.map +1 -1
- package/dist/esm/stories/ToolCard.stories.js +6 -14
- package/dist/esm/stories/ToolCard.stories.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Avatar.tsx +4 -4
- package/src/components/DataTable.tsx +46 -7
- package/src/components/NavigationList.tsx +2 -7
- package/src/components/ScrollArea.tsx +3 -9
- package/src/components/Spinner.tsx +7 -7
- package/src/components/ToolCard.tsx +35 -60
- package/src/components/Tooltip.tsx +38 -49
- package/src/components/WindowUtility.tsx +18 -11
- package/src/components/markdown/CodeBlock.tsx +0 -10
- package/src/index.ts +0 -1
- package/src/stories/Avatar.stories.tsx +4 -4
- package/src/stories/MultiPageDialog.stories.tsx +1 -1
- package/src/stories/Spinner.stories.tsx +3 -3
- package/src/stories/ToolCard.stories.tsx +35 -49
- package/dist/esm/stories/CodeBlock.stories.d.ts +0 -17
- package/dist/esm/stories/CodeBlock.stories.d.ts.map +0 -1
- package/dist/esm/stories/CodeBlock.stories.js +0 -125
- package/dist/esm/stories/CodeBlock.stories.js.map +0 -1
- package/src/stories/CodeBlock.stories.tsx +0 -361
|
@@ -15,7 +15,13 @@ import {
|
|
|
15
15
|
useReactTable,
|
|
16
16
|
} from "@tanstack/react-table";
|
|
17
17
|
import { useVirtualizer } from "@tanstack/react-virtual";
|
|
18
|
-
import React, {
|
|
18
|
+
import React, {
|
|
19
|
+
ReactNode,
|
|
20
|
+
useEffect,
|
|
21
|
+
useLayoutEffect,
|
|
22
|
+
useRef,
|
|
23
|
+
useState,
|
|
24
|
+
} from "react";
|
|
19
25
|
|
|
20
26
|
import {
|
|
21
27
|
Avatar,
|
|
@@ -339,6 +345,24 @@ export interface ScrollableDataTableProps<TData extends TBaseData>
|
|
|
339
345
|
const COLUMN_HEIGHT = 48;
|
|
340
346
|
const MIN_COLUMN_WIDTH = 40;
|
|
341
347
|
|
|
348
|
+
// Helper function to compare column sizing objects
|
|
349
|
+
function shallowEqualSizing(
|
|
350
|
+
a: Record<string, number>,
|
|
351
|
+
b: Record<string, number>
|
|
352
|
+
) {
|
|
353
|
+
const aKeys = Object.keys(a);
|
|
354
|
+
const bKeys = Object.keys(b);
|
|
355
|
+
if (aKeys.length !== bKeys.length) {
|
|
356
|
+
return false;
|
|
357
|
+
}
|
|
358
|
+
for (const k of aKeys) {
|
|
359
|
+
if (a[k] !== b[k]) {
|
|
360
|
+
return false;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
return true;
|
|
364
|
+
}
|
|
365
|
+
|
|
342
366
|
export function ScrollableDataTable<TData extends TBaseData>({
|
|
343
367
|
data,
|
|
344
368
|
totalRowCount,
|
|
@@ -360,7 +384,7 @@ export function ScrollableDataTable<TData extends TBaseData>({
|
|
|
360
384
|
const loadMoreRef = useRef<HTMLDivElement>(null);
|
|
361
385
|
const [tableWidth, setTableWidth] = useState(0);
|
|
362
386
|
|
|
363
|
-
// Monitor table width changes
|
|
387
|
+
// Monitor table width changes with guard against tiny changes
|
|
364
388
|
useEffect(() => {
|
|
365
389
|
if (!tableContainerRef.current) {
|
|
366
390
|
return;
|
|
@@ -368,7 +392,8 @@ export function ScrollableDataTable<TData extends TBaseData>({
|
|
|
368
392
|
|
|
369
393
|
const resizeObserver = new ResizeObserver((entries) => {
|
|
370
394
|
for (const entry of entries) {
|
|
371
|
-
|
|
395
|
+
const w = Math.round(entry.contentRect.width);
|
|
396
|
+
setTableWidth((prev) => (prev !== w ? w : prev)); // update only on real change
|
|
372
397
|
}
|
|
373
398
|
});
|
|
374
399
|
|
|
@@ -405,12 +430,20 @@ export function ScrollableDataTable<TData extends TBaseData>({
|
|
|
405
430
|
getRowId,
|
|
406
431
|
});
|
|
407
432
|
|
|
408
|
-
|
|
433
|
+
useLayoutEffect(() => {
|
|
409
434
|
if (!tableContainerRef.current || !table || !tableWidth) {
|
|
410
435
|
return;
|
|
411
436
|
}
|
|
412
437
|
const columns = table.getAllColumns();
|
|
413
438
|
|
|
439
|
+
// Skip sizing if no columns have ratios defined
|
|
440
|
+
const hasRatios = columns.some(
|
|
441
|
+
(c) => (c.columnDef.meta?.sizeRatio ?? 0) > 0
|
|
442
|
+
);
|
|
443
|
+
if (!hasRatios) {
|
|
444
|
+
return;
|
|
445
|
+
}
|
|
446
|
+
|
|
414
447
|
// Calculate ideal widths and handle minimums
|
|
415
448
|
const idealSizing = columns.reduce(
|
|
416
449
|
(acc, column) => {
|
|
@@ -419,7 +452,8 @@ export function ScrollableDataTable<TData extends TBaseData>({
|
|
|
419
452
|
Math.floor((ratio / 100) * tableWidth),
|
|
420
453
|
MIN_COLUMN_WIDTH
|
|
421
454
|
);
|
|
422
|
-
|
|
455
|
+
acc[column.id] = calculated;
|
|
456
|
+
return acc;
|
|
423
457
|
},
|
|
424
458
|
{} as Record<string, number>
|
|
425
459
|
);
|
|
@@ -439,8 +473,13 @@ export function ScrollableDataTable<TData extends TBaseData>({
|
|
|
439
473
|
|
|
440
474
|
idealSizing[adjustColumnId] += widthDifference;
|
|
441
475
|
}
|
|
442
|
-
|
|
443
|
-
|
|
476
|
+
|
|
477
|
+
// Only set when sizing actually changes
|
|
478
|
+
const currentSizing = table.getState().columnSizing;
|
|
479
|
+
if (!shallowEqualSizing(idealSizing, currentSizing)) {
|
|
480
|
+
table.setColumnSizing(idealSizing);
|
|
481
|
+
}
|
|
482
|
+
}, [tableWidth]); // intentionally remove `table` from deps
|
|
444
483
|
|
|
445
484
|
// Get the current column sizing from the table for rendering
|
|
446
485
|
const columnSizing = table.getState().columnSizing;
|
|
@@ -41,18 +41,13 @@ const NavigationListItemStyles = cva(
|
|
|
41
41
|
}
|
|
42
42
|
);
|
|
43
43
|
|
|
44
|
-
interface NavigationListProps {
|
|
45
|
-
viewportRef?: React.RefObject<HTMLDivElement>;
|
|
46
|
-
}
|
|
47
44
|
const NavigationList = React.forwardRef<
|
|
48
45
|
React.ElementRef<typeof ScrollAreaPrimitive.Root>,
|
|
49
|
-
React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.Root>
|
|
50
|
-
|
|
51
|
-
>(({ className, children, viewportRef, ...props }, ref) => {
|
|
46
|
+
React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.Root>
|
|
47
|
+
>(({ className, children, ...props }, ref) => {
|
|
52
48
|
return (
|
|
53
49
|
<ScrollArea
|
|
54
50
|
ref={ref}
|
|
55
|
-
viewportRef={viewportRef}
|
|
56
51
|
className={cn(className, "s-transition-all s-duration-300")}
|
|
57
52
|
{...props}
|
|
58
53
|
>
|
|
@@ -14,7 +14,6 @@ interface ScrollAreaProps
|
|
|
14
14
|
active?: string;
|
|
15
15
|
inactive?: string;
|
|
16
16
|
};
|
|
17
|
-
viewportRef?: React.RefObject<HTMLDivElement>;
|
|
18
17
|
}
|
|
19
18
|
|
|
20
19
|
const ScrollArea = React.forwardRef<
|
|
@@ -30,12 +29,11 @@ const ScrollArea = React.forwardRef<
|
|
|
30
29
|
scrollBarClassName,
|
|
31
30
|
viewportClassName,
|
|
32
31
|
scrollStyles,
|
|
33
|
-
viewportRef,
|
|
34
32
|
...props
|
|
35
33
|
},
|
|
36
34
|
ref
|
|
37
35
|
) => {
|
|
38
|
-
const
|
|
36
|
+
const viewportRef = React.useRef<HTMLDivElement>(null);
|
|
39
37
|
const [isScrolled, setIsScrolled] = React.useState(false);
|
|
40
38
|
|
|
41
39
|
const hasCustomScrollBar = useMemo(
|
|
@@ -52,13 +50,9 @@ const ScrollArea = React.forwardRef<
|
|
|
52
50
|
const shouldHideDefaultScrollBar = hideScrollBar || hasCustomScrollBar;
|
|
53
51
|
|
|
54
52
|
const handleScroll = React.useCallback(() => {
|
|
55
|
-
if (viewportRef
|
|
53
|
+
if (viewportRef.current) {
|
|
56
54
|
setIsScrolled(viewportRef.current.scrollTop > 0);
|
|
57
55
|
}
|
|
58
|
-
|
|
59
|
-
if (localViewportRef.current) {
|
|
60
|
-
setIsScrolled(localViewportRef.current.scrollTop > 0);
|
|
61
|
-
}
|
|
62
56
|
}, []);
|
|
63
57
|
|
|
64
58
|
return (
|
|
@@ -72,7 +66,7 @@ const ScrollArea = React.forwardRef<
|
|
|
72
66
|
{...props}
|
|
73
67
|
>
|
|
74
68
|
<ScrollAreaPrimitive.Viewport
|
|
75
|
-
ref={viewportRef
|
|
69
|
+
ref={viewportRef}
|
|
76
70
|
onScroll={handleScroll}
|
|
77
71
|
className={cn(
|
|
78
72
|
"s-h-full s-w-full s-rounded-[inherit]",
|
|
@@ -13,7 +13,7 @@ import animLightLG from "@sparkle/lottie/spinnerLightLG";
|
|
|
13
13
|
import animLightXS from "@sparkle/lottie/spinnerLightXS";
|
|
14
14
|
|
|
15
15
|
type SpinnerSizeType = (typeof SPINNER_SIZES)[number];
|
|
16
|
-
const SPINNER_SIZES = ["xs", "sm", "md", "lg", "xl", "
|
|
16
|
+
const SPINNER_SIZES = ["xs", "sm", "md", "lg", "xl", "xxl"] as const;
|
|
17
17
|
|
|
18
18
|
type SpinnerVariant =
|
|
19
19
|
| "mono"
|
|
@@ -43,7 +43,7 @@ const pxSizeClasses: Record<SpinnerSizeType, string> = {
|
|
|
43
43
|
md: "24",
|
|
44
44
|
lg: "32",
|
|
45
45
|
xl: "128",
|
|
46
|
-
|
|
46
|
+
xxl: "192",
|
|
47
47
|
};
|
|
48
48
|
|
|
49
49
|
type LottieColorType = [number, number, number, number];
|
|
@@ -111,7 +111,7 @@ const Spinner: React.FC<SpinnerProps> = ({ size = "md", variant = "mono" }) => {
|
|
|
111
111
|
anim = animLightXS;
|
|
112
112
|
break;
|
|
113
113
|
case "xl":
|
|
114
|
-
case "
|
|
114
|
+
case "xxl":
|
|
115
115
|
anim = animLightLG;
|
|
116
116
|
break;
|
|
117
117
|
default:
|
|
@@ -139,7 +139,7 @@ const Spinner: React.FC<SpinnerProps> = ({ size = "md", variant = "mono" }) => {
|
|
|
139
139
|
anim = animColorXS;
|
|
140
140
|
break;
|
|
141
141
|
case "xl":
|
|
142
|
-
case "
|
|
142
|
+
case "xxl":
|
|
143
143
|
anim = animColorLG;
|
|
144
144
|
break;
|
|
145
145
|
default:
|
|
@@ -162,7 +162,7 @@ const Spinner: React.FC<SpinnerProps> = ({ size = "md", variant = "mono" }) => {
|
|
|
162
162
|
anim = animLightXS;
|
|
163
163
|
break;
|
|
164
164
|
case "xl":
|
|
165
|
-
case "
|
|
165
|
+
case "xxl":
|
|
166
166
|
anim = animLightLG;
|
|
167
167
|
break;
|
|
168
168
|
default:
|
|
@@ -185,7 +185,7 @@ const Spinner: React.FC<SpinnerProps> = ({ size = "md", variant = "mono" }) => {
|
|
|
185
185
|
anim = animDarkXS;
|
|
186
186
|
break;
|
|
187
187
|
case "xl":
|
|
188
|
-
case "
|
|
188
|
+
case "xxl":
|
|
189
189
|
anim = animDarkLG;
|
|
190
190
|
break;
|
|
191
191
|
default:
|
|
@@ -210,7 +210,7 @@ const Spinner: React.FC<SpinnerProps> = ({ size = "md", variant = "mono" }) => {
|
|
|
210
210
|
darkAnim = animDarkXS;
|
|
211
211
|
break;
|
|
212
212
|
case "xl":
|
|
213
|
-
case "
|
|
213
|
+
case "xxl":
|
|
214
214
|
lightAnim = animLightLG;
|
|
215
215
|
darkAnim = animDarkLG;
|
|
216
216
|
break;
|
|
@@ -15,13 +15,10 @@ export interface ToolCardProps {
|
|
|
15
15
|
isSelected: boolean;
|
|
16
16
|
canAdd: boolean;
|
|
17
17
|
cantAddReason?: string;
|
|
18
|
-
toolInfo?: { label: string; onClick: () => void };
|
|
19
18
|
onClick?: () => void;
|
|
20
19
|
className?: string;
|
|
21
|
-
cardContainerClassName?: string;
|
|
22
20
|
mountPortal?: boolean;
|
|
23
21
|
mountPortalContainer?: HTMLElement;
|
|
24
|
-
descriptionLineClamp?: number;
|
|
25
22
|
}
|
|
26
23
|
|
|
27
24
|
export const ToolCard = React.forwardRef<HTMLDivElement, ToolCardProps>(
|
|
@@ -33,13 +30,10 @@ export const ToolCard = React.forwardRef<HTMLDivElement, ToolCardProps>(
|
|
|
33
30
|
isSelected,
|
|
34
31
|
canAdd,
|
|
35
32
|
cantAddReason,
|
|
36
|
-
toolInfo,
|
|
37
33
|
onClick,
|
|
38
34
|
className,
|
|
39
|
-
cardContainerClassName,
|
|
40
35
|
mountPortal,
|
|
41
36
|
mountPortalContainer,
|
|
42
|
-
descriptionLineClamp = 2,
|
|
43
37
|
},
|
|
44
38
|
ref
|
|
45
39
|
) => {
|
|
@@ -49,63 +43,44 @@ export const ToolCard = React.forwardRef<HTMLDivElement, ToolCardProps>(
|
|
|
49
43
|
variant={isSelected ? "secondary" : "primary"}
|
|
50
44
|
onClick={onClick}
|
|
51
45
|
disabled={!canAdd}
|
|
52
|
-
|
|
53
|
-
className={cn("s-p-3", className)}
|
|
46
|
+
className={cn("s-h-24 s-p-3", className)}
|
|
54
47
|
>
|
|
55
|
-
<div className="s-flex s-
|
|
56
|
-
<div className="s-
|
|
57
|
-
<div className="s-
|
|
58
|
-
<
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
)}
|
|
69
|
-
</div>
|
|
70
|
-
<div className="s-flex s-flex-shrink-0 s-items-center s-gap-2">
|
|
71
|
-
{canAdd && (
|
|
72
|
-
<Button
|
|
73
|
-
size="xs"
|
|
74
|
-
variant="outline"
|
|
75
|
-
icon={PlusIcon}
|
|
76
|
-
label="Add"
|
|
77
|
-
className={cn(FADE_TRANSITION_CLASSES, "s-flex-shrink-0")}
|
|
78
|
-
/>
|
|
79
|
-
)}
|
|
80
|
-
{cantAddReason && (
|
|
81
|
-
<div className="s-flex-shrink-0 s-text-xs s-italic s-text-muted-foreground dark:s-text-muted-foreground-night">
|
|
82
|
-
{cantAddReason}
|
|
83
|
-
</div>
|
|
84
|
-
)}
|
|
85
|
-
</div>
|
|
48
|
+
<div className="s-flex s-w-full s-flex-col">
|
|
49
|
+
<div className="s-mb-2 s-flex s-items-start s-justify-between s-gap-2">
|
|
50
|
+
<div className="s-flex s-items-center s-gap-2">
|
|
51
|
+
<Avatar icon={icon} size="sm" />
|
|
52
|
+
<span className="s-text-sm s-font-medium">{label}</span>
|
|
53
|
+
{isSelected && (
|
|
54
|
+
<Chip
|
|
55
|
+
size="xs"
|
|
56
|
+
color="green"
|
|
57
|
+
label="ADDED"
|
|
58
|
+
className={cn(FADE_TRANSITION_CLASSES, "s-opacity-100")}
|
|
59
|
+
/>
|
|
60
|
+
)}
|
|
86
61
|
</div>
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
62
|
+
{canAdd && (
|
|
63
|
+
<Button
|
|
64
|
+
size="xs"
|
|
65
|
+
variant="outline"
|
|
66
|
+
icon={PlusIcon}
|
|
67
|
+
label="Add"
|
|
68
|
+
className={cn(FADE_TRANSITION_CLASSES, "s-flex-shrink-0")}
|
|
69
|
+
/>
|
|
70
|
+
)}
|
|
71
|
+
{cantAddReason && (
|
|
72
|
+
<div className="s-flex-shrink-0 s-text-xs s-italic s-text-muted-foreground dark:s-text-muted-foreground-night">
|
|
73
|
+
{cantAddReason}
|
|
74
|
+
</div>
|
|
75
|
+
)}
|
|
95
76
|
</div>
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
className="hover:s-underline-offset-2 dark:s-text-muted-foreground-night s-cursor-pointer s-text-sm s-font-semibold s-text-muted-foreground hover:s-text-highlight-light hover:s-underline dark:hover:s-text-highlight-light-night"
|
|
104
|
-
>
|
|
105
|
-
{toolInfo.label}
|
|
106
|
-
</a>
|
|
107
|
-
</div>
|
|
108
|
-
)}
|
|
77
|
+
<TruncatedText
|
|
78
|
+
className="s-text-sm s-text-muted-foreground dark:s-text-muted-foreground-night"
|
|
79
|
+
mountPortal={mountPortal}
|
|
80
|
+
mountPortalContainer={mountPortalContainer}
|
|
81
|
+
>
|
|
82
|
+
{description}
|
|
83
|
+
</TruncatedText>
|
|
109
84
|
</div>
|
|
110
85
|
</Card>
|
|
111
86
|
);
|
|
@@ -20,58 +20,47 @@ interface TooltipContentProps
|
|
|
20
20
|
const TooltipContent = React.forwardRef<
|
|
21
21
|
React.ElementRef<typeof TooltipPrimitive.Content>,
|
|
22
22
|
TooltipContentProps
|
|
23
|
-
>(
|
|
24
|
-
(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
sideOffset
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
"s-text-foreground dark:s-text-foreground-night",
|
|
42
|
-
"s-border-border dark:s-border-border-night",
|
|
43
|
-
"s-px-3 s-py-1.5 s-text-sm s-shadow-md",
|
|
44
|
-
"s-animate-in s-fade-in-0 s-zoom-in-95",
|
|
45
|
-
"data-[state=closed]:s-animate-out data-[state=closed]:s-fade-out-0 data-[state=closed]:s-zoom-out-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",
|
|
46
|
-
className || ""
|
|
47
|
-
)}
|
|
48
|
-
{...props}
|
|
49
|
-
/>
|
|
50
|
-
);
|
|
23
|
+
>(({ className, sideOffset = 4, mountPortal = true, mountPortalContainer, ...props }, ref) => {
|
|
24
|
+
const content = (
|
|
25
|
+
<TooltipPrimitive.Content
|
|
26
|
+
ref={ref}
|
|
27
|
+
sideOffset={sideOffset}
|
|
28
|
+
className={classNames(
|
|
29
|
+
"s-z-50 s-max-w-sm s-overflow-hidden s-whitespace-pre-wrap s-break-words s-rounded-md s-border",
|
|
30
|
+
"s-bg-background dark:s-bg-background-night",
|
|
31
|
+
"s-text-foreground dark:s-text-foreground-night",
|
|
32
|
+
"s-border-border dark:s-border-border-night",
|
|
33
|
+
"s-px-3 s-py-1.5 s-text-sm s-shadow-md",
|
|
34
|
+
"s-animate-in s-fade-in-0 s-zoom-in-95",
|
|
35
|
+
"data-[state=closed]:s-animate-out data-[state=closed]:s-fade-out-0 data-[state=closed]:s-zoom-out-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",
|
|
36
|
+
className || ""
|
|
37
|
+
)}
|
|
38
|
+
{...props}
|
|
39
|
+
/>
|
|
40
|
+
);
|
|
51
41
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
42
|
+
const [container, setContainer] = useState<Element | undefined>(
|
|
43
|
+
mountPortalContainer
|
|
44
|
+
);
|
|
55
45
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
if (mountPortal && !container) {
|
|
48
|
+
const dialogElements = document.querySelectorAll(
|
|
49
|
+
".s-sheet[role=dialog][data-state=open]"
|
|
50
|
+
);
|
|
51
|
+
const defaultContainer = dialogElements[dialogElements.length - 1];
|
|
52
|
+
setContainer(defaultContainer);
|
|
53
|
+
}
|
|
54
|
+
}, [mountPortal, container]);
|
|
65
55
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
);
|
|
56
|
+
return mountPortal ? (
|
|
57
|
+
<TooltipPrimitive.Portal container={container}>
|
|
58
|
+
{content}
|
|
59
|
+
</TooltipPrimitive.Portal>
|
|
60
|
+
) : (
|
|
61
|
+
content
|
|
62
|
+
);
|
|
63
|
+
});
|
|
75
64
|
|
|
76
65
|
interface TooltipProps extends TooltipContentProps {
|
|
77
66
|
trigger: React.ReactNode;
|
|
@@ -2,25 +2,30 @@ import { useEffect, useState } from "react";
|
|
|
2
2
|
|
|
3
3
|
// Define breakpoints
|
|
4
4
|
export const breakpoints = {
|
|
5
|
-
|
|
6
|
-
xs: 512,
|
|
5
|
+
xs: 0,
|
|
7
6
|
sm: 640,
|
|
8
7
|
md: 768,
|
|
9
8
|
lg: 1024,
|
|
10
9
|
xl: 1280,
|
|
11
|
-
|
|
10
|
+
xxl: 1536,
|
|
12
11
|
};
|
|
13
12
|
|
|
14
13
|
// Helper function to determine active breakpoint
|
|
15
14
|
function getActiveBreakpoint(width: number): keyof typeof breakpoints {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
15
|
+
if (width >= breakpoints.xxl) {
|
|
16
|
+
return "xxl";
|
|
17
|
+
}
|
|
18
|
+
if (width >= breakpoints.xl) {
|
|
19
|
+
return "xl";
|
|
20
|
+
}
|
|
21
|
+
if (width >= breakpoints.lg) {
|
|
22
|
+
return "lg";
|
|
23
|
+
}
|
|
24
|
+
if (width >= breakpoints.md) {
|
|
25
|
+
return "md";
|
|
26
|
+
}
|
|
27
|
+
if (width >= breakpoints.sm) {
|
|
28
|
+
return "sm";
|
|
24
29
|
}
|
|
25
30
|
return "xs";
|
|
26
31
|
}
|
|
@@ -57,3 +62,5 @@ export function useWindowSize() {
|
|
|
57
62
|
|
|
58
63
|
return windowSize;
|
|
59
64
|
}
|
|
65
|
+
|
|
66
|
+
export default useWindowSize;
|
|
@@ -34,7 +34,6 @@ type CodeBlockProps = {
|
|
|
34
34
|
inline?: boolean;
|
|
35
35
|
variant?: "surface";
|
|
36
36
|
wrapLongLines?: boolean;
|
|
37
|
-
showLineNumber?: boolean;
|
|
38
37
|
};
|
|
39
38
|
|
|
40
39
|
export function CodeBlock({
|
|
@@ -43,7 +42,6 @@ export function CodeBlock({
|
|
|
43
42
|
inline,
|
|
44
43
|
variant = "surface",
|
|
45
44
|
wrapLongLines = false,
|
|
46
|
-
showLineNumber = false,
|
|
47
45
|
}: CodeBlockProps): JSX.Element {
|
|
48
46
|
const match = /language-(\w+)/.exec(className || "");
|
|
49
47
|
const language = match ? match[1] : "text";
|
|
@@ -65,13 +63,6 @@ export function CodeBlock({
|
|
|
65
63
|
backgroundColor: "transparent",
|
|
66
64
|
fontSize: "0.875rem",
|
|
67
65
|
},
|
|
68
|
-
"hljs-ln": {
|
|
69
|
-
color: "var(--s-muted-foreground)",
|
|
70
|
-
fontSize: "0.75rem",
|
|
71
|
-
paddingRight: "1em",
|
|
72
|
-
textAlign: "right",
|
|
73
|
-
userSelect: "none",
|
|
74
|
-
},
|
|
75
66
|
"hljs-keyword": {
|
|
76
67
|
// function, const, let, if, return
|
|
77
68
|
color: violet[500],
|
|
@@ -157,7 +148,6 @@ export function CodeBlock({
|
|
|
157
148
|
<div className="s-text-foreground dark:s-text-foreground-night">
|
|
158
149
|
<SyntaxHighlighter
|
|
159
150
|
wrapLongLines={wrapLongLines}
|
|
160
|
-
showLineNumbers={showLineNumber}
|
|
161
151
|
style={codeStyle}
|
|
162
152
|
language={languageToUse}
|
|
163
153
|
PreTag="div"
|
package/src/index.ts
CHANGED
|
@@ -44,7 +44,7 @@ export const AvatarExample = () => (
|
|
|
44
44
|
<Avatar size="md" />
|
|
45
45
|
<Avatar size="lg" />
|
|
46
46
|
<Avatar size="xl" />
|
|
47
|
-
<Avatar size="
|
|
47
|
+
<Avatar size="xxl" />
|
|
48
48
|
</div>
|
|
49
49
|
<div>With name</div>
|
|
50
50
|
<div className="s-flex s-gap-4">
|
|
@@ -53,7 +53,7 @@ export const AvatarExample = () => (
|
|
|
53
53
|
<Avatar size="md" name="Aria Doe" />
|
|
54
54
|
<Avatar size="lg" name="Omar Doe" />
|
|
55
55
|
<Avatar size="xl" name="Omar Doe" />
|
|
56
|
-
<Avatar size="
|
|
56
|
+
<Avatar size="xxl" name="Omar Doe" />
|
|
57
57
|
</div>
|
|
58
58
|
<div>With emoji url</div>
|
|
59
59
|
<div className="s-flex s-gap-4">
|
|
@@ -69,7 +69,7 @@ export const AvatarExample = () => (
|
|
|
69
69
|
<Avatar size="md" emoji="😂" backgroundColor="s-bg-info-200" />
|
|
70
70
|
<Avatar size="lg" emoji="🧑🚀" backgroundColor="s-bg-gray-200" />
|
|
71
71
|
<Avatar size="xl" emoji="👕" backgroundColor="s-bg-blue-200" />
|
|
72
|
-
<Avatar size="
|
|
72
|
+
<Avatar size="xxl" emoji="👕" backgroundColor="s-bg-blue-200" />
|
|
73
73
|
</div>
|
|
74
74
|
<div className="s-flex s-gap-4">
|
|
75
75
|
<Avatar size="sm" name="Eleanor Wright" />
|
|
@@ -126,7 +126,7 @@ export const AvatarExample = () => (
|
|
|
126
126
|
<Avatar size="lg" icon={ActionFlagIcon} />
|
|
127
127
|
<Avatar size="lg" icon={SlackLogo} hexBgColor="#421D51" />
|
|
128
128
|
<Avatar size="xl" icon={ActionShirtIcon} />
|
|
129
|
-
<Avatar size="
|
|
129
|
+
<Avatar size="xxl" icon={StarStrokeIcon} />
|
|
130
130
|
</div>
|
|
131
131
|
<div className="heading-2xl">Tools example</div>
|
|
132
132
|
<div>Remote MCP Servers</div>
|
|
@@ -912,7 +912,7 @@ export const ActionValidation: Story = {
|
|
|
912
912
|
content: (
|
|
913
913
|
<div className="s-space-y-6 s-pt-4">
|
|
914
914
|
<div>
|
|
915
|
-
<p className="s-mb-6 s-text-sm s-text-muted-foreground
|
|
915
|
+
<p className="s-mb-6 s-text-sm s-text-muted-foreground">
|
|
916
916
|
Allow{" "}
|
|
917
917
|
<span className="s-font-semibold">@Marketing Assistant</span> to
|
|
918
918
|
use the tool <span className="s-font-semibold">Send Email</span>{" "}
|
|
@@ -89,13 +89,13 @@ export const SpinnerExample = () => {
|
|
|
89
89
|
</div>
|
|
90
90
|
<div className="s-flex s-gap-4">
|
|
91
91
|
<div className="s-p-20">
|
|
92
|
-
<Spinner variant="color" size="
|
|
92
|
+
<Spinner variant="color" size="xxl" />
|
|
93
93
|
</div>
|
|
94
94
|
<div className="s-p-20">
|
|
95
|
-
<Spinner variant="mono" size="
|
|
95
|
+
<Spinner variant="mono" size="xxl" />
|
|
96
96
|
</div>
|
|
97
97
|
<div className="s-p-20">
|
|
98
|
-
<Spinner variant="rose300" size="
|
|
98
|
+
<Spinner variant="rose300" size="xxl" />
|
|
99
99
|
</div>
|
|
100
100
|
</div>
|
|
101
101
|
</div>
|