@dust-tt/sparkle 0.2.251 → 0.2.253-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 +3906 -457
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/components/BarHeader.js +3 -3
- package/dist/esm/components/BarHeader.js.map +1 -1
- package/dist/esm/components/Breadcrumbs.js +1 -1
- package/dist/esm/components/Breadcrumbs.js.map +1 -1
- package/dist/esm/components/Button.d.ts +5 -3
- package/dist/esm/components/Button.d.ts.map +1 -1
- package/dist/esm/components/Button.js +11 -3
- package/dist/esm/components/Button.js.map +1 -1
- package/dist/esm/components/Citation.d.ts.map +1 -1
- package/dist/esm/components/Citation.js +1 -1
- package/dist/esm/components/Citation.js.map +1 -1
- package/dist/esm/components/DataTable.d.ts +6 -0
- package/dist/esm/components/DataTable.d.ts.map +1 -1
- package/dist/esm/components/DataTable.js +33 -5
- package/dist/esm/components/DataTable.js.map +1 -1
- package/dist/esm/components/Dialog.d.ts +2 -1
- package/dist/esm/components/Dialog.d.ts.map +1 -1
- package/dist/esm/components/Dialog.js.map +1 -1
- package/dist/esm/components/DropdownMenu.d.ts +2 -2
- package/dist/esm/components/DropdownMenu.d.ts.map +1 -1
- package/dist/esm/components/DropdownMenu.js +8 -5
- package/dist/esm/components/DropdownMenu.js.map +1 -1
- package/dist/esm/components/ElementDialog.d.ts +1 -1
- package/dist/esm/components/ElementDialog.d.ts.map +1 -1
- package/dist/esm/components/ElementDialog.js +2 -2
- package/dist/esm/components/ElementDialog.js.map +1 -1
- package/dist/esm/components/IconButton.d.ts +2 -2
- package/dist/esm/components/IconButton.d.ts.map +1 -1
- package/dist/esm/components/IconButton.js +2 -2
- package/dist/esm/components/IconButton.js.map +1 -1
- package/dist/esm/components/IconToggleButton.d.ts +2 -2
- package/dist/esm/components/IconToggleButton.d.ts.map +1 -1
- package/dist/esm/components/IconToggleButton.js +2 -2
- package/dist/esm/components/IconToggleButton.js.map +1 -1
- package/dist/esm/components/Input.js.map +1 -1
- package/dist/esm/components/Searchbar.d.ts.map +1 -1
- package/dist/esm/components/Searchbar.js.map +1 -1
- package/dist/esm/components/Tab.js +1 -1
- package/dist/esm/components/Tab.js.map +1 -1
- package/dist/esm/components/TextArea.d.ts +4 -8
- package/dist/esm/components/TextArea.d.ts.map +1 -1
- package/dist/esm/components/TextArea.js +7 -9
- package/dist/esm/components/TextArea.js.map +1 -1
- package/dist/esm/components/Tooltip.d.ts +13 -7
- package/dist/esm/components/Tooltip.d.ts.map +1 -1
- package/dist/esm/components/Tooltip.js +18 -42
- package/dist/esm/components/Tooltip.js.map +1 -1
- package/dist/esm/components/index.d.ts +1 -1
- package/dist/esm/components/index.d.ts.map +1 -1
- package/dist/esm/components/index.js +1 -1
- package/dist/esm/components/index.js.map +1 -1
- package/dist/esm/stories/Button.stories.js +2 -2
- package/dist/esm/stories/Button.stories.js.map +1 -1
- package/dist/esm/stories/Citation.stories.js +1 -1
- package/dist/esm/stories/Citation.stories.js.map +1 -1
- package/dist/esm/stories/DataTable.stories.d.ts.map +1 -1
- package/dist/esm/stories/DataTable.stories.js +1 -1
- package/dist/esm/stories/DataTable.stories.js.map +1 -1
- package/dist/esm/stories/Dialog.stories.d.ts.map +1 -1
- package/dist/esm/stories/Dialog.stories.js +1 -1
- package/dist/esm/stories/Dialog.stories.js.map +1 -1
- package/dist/esm/stories/DropdownMenu.stories.d.ts.map +1 -1
- package/dist/esm/stories/DropdownMenu.stories.js +2 -2
- package/dist/esm/stories/DropdownMenu.stories.js.map +1 -1
- package/dist/esm/stories/IconButton.stories.js +3 -3
- package/dist/esm/stories/IconButton.stories.js.map +1 -1
- package/dist/esm/stories/TextArea.stories.d.ts +1 -2
- package/dist/esm/stories/TextArea.stories.d.ts.map +1 -1
- package/dist/esm/stories/TextArea.stories.js +23 -7
- package/dist/esm/stories/TextArea.stories.js.map +1 -1
- package/dist/esm/stories/Tooltip.stories.d.ts +3 -8
- package/dist/esm/stories/Tooltip.stories.d.ts.map +1 -1
- package/dist/esm/stories/Tooltip.stories.js +10 -23
- package/dist/esm/stories/Tooltip.stories.js.map +1 -1
- package/dist/esm/stories/Tree.stories.js.map +1 -1
- package/dist/sparkle.css +6 -68
- package/package.json +3 -1
- package/src/components/BarHeader.tsx +0 -3
- package/src/components/Breadcrumbs.tsx +1 -4
- package/src/components/Button.tsx +17 -14
- package/src/components/Citation.tsx +1 -7
- package/src/components/DataTable.tsx +63 -10
- package/src/components/Dialog.tsx +4 -4
- package/src/components/DropdownMenu.tsx +42 -31
- package/src/components/ElementDialog.tsx +4 -1
- package/src/components/IconButton.tsx +9 -6
- package/src/components/IconToggleButton.tsx +9 -6
- package/src/components/Input.tsx +1 -1
- package/src/components/Searchbar.tsx +2 -4
- package/src/components/Tab.tsx +1 -1
- package/src/components/TextArea.tsx +38 -43
- package/src/components/Tooltip.tsx +48 -78
- package/src/components/index.ts +7 -1
- package/src/stories/Button.stories.tsx +2 -2
- package/src/stories/Citation.stories.tsx +1 -1
- package/src/stories/DataTable.stories.tsx +3 -1
- package/src/stories/Dialog.stories.tsx +1 -0
- package/src/stories/DropdownMenu.stories.tsx +6 -3
- package/src/stories/IconButton.stories.tsx +3 -3
- package/src/stories/TextArea.stories.tsx +26 -10
- package/src/stories/Tooltip.stories.tsx +31 -50
- package/src/stories/Tree.stories.tsx +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SIDE_OPTIONS } from "@radix-ui/react-popper";
|
|
1
2
|
import React, {
|
|
2
3
|
Children,
|
|
3
4
|
cloneElement,
|
|
@@ -6,22 +7,26 @@ import React, {
|
|
|
6
7
|
ReactNode,
|
|
7
8
|
} from "react";
|
|
8
9
|
|
|
10
|
+
import { Tooltip } from "@sparkle/components/Tooltip";
|
|
9
11
|
import { ChevronDownIcon, ChevronUpDownIcon } from "@sparkle/icons/solid";
|
|
10
12
|
import { classNames } from "@sparkle/lib/utils";
|
|
11
13
|
|
|
12
14
|
import { Avatar } from "./Avatar";
|
|
13
15
|
import { Icon, IconProps } from "./Icon";
|
|
14
|
-
import { Tooltip, TooltipProps } from "./Tooltip";
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
const BUTTON_VARIANTS = [
|
|
18
|
+
"primary",
|
|
19
|
+
"primaryWarning",
|
|
20
|
+
"secondary",
|
|
21
|
+
"secondaryWarning",
|
|
22
|
+
"tertiary",
|
|
23
|
+
"avatar",
|
|
24
|
+
] as const;
|
|
25
|
+
|
|
26
|
+
export type ButtonVariantType = (typeof BUTTON_VARIANTS)[number];
|
|
24
27
|
|
|
28
|
+
export type ButtonProps = {
|
|
29
|
+
variant?: ButtonVariantType;
|
|
25
30
|
type?: "button" | "menu" | "select";
|
|
26
31
|
size?: "xs" | "sm" | "md" | "lg";
|
|
27
32
|
onClick?: (event: MouseEvent<HTMLButtonElement>) => void;
|
|
@@ -32,7 +37,7 @@ export type ButtonProps = {
|
|
|
32
37
|
icon?: ComponentType;
|
|
33
38
|
avatar?: string;
|
|
34
39
|
className?: string;
|
|
35
|
-
tooltipPosition?:
|
|
40
|
+
tooltipPosition?: (typeof SIDE_OPTIONS)[number];
|
|
36
41
|
disabledTooltip?: boolean;
|
|
37
42
|
};
|
|
38
43
|
|
|
@@ -173,7 +178,7 @@ export function Button({
|
|
|
173
178
|
label,
|
|
174
179
|
icon,
|
|
175
180
|
className = "",
|
|
176
|
-
tooltipPosition
|
|
181
|
+
tooltipPosition,
|
|
177
182
|
hasMagnifying = true,
|
|
178
183
|
disabledTooltip = false,
|
|
179
184
|
avatar,
|
|
@@ -242,9 +247,7 @@ export function Button({
|
|
|
242
247
|
return labelVisible || disabledTooltip ? (
|
|
243
248
|
buttonBase
|
|
244
249
|
) : (
|
|
245
|
-
<Tooltip label={label}
|
|
246
|
-
{buttonBase}
|
|
247
|
-
</Tooltip>
|
|
250
|
+
<Tooltip trigger={buttonBase} label={label} side={tooltipPosition} />
|
|
248
251
|
);
|
|
249
252
|
}
|
|
250
253
|
|
|
@@ -172,11 +172,5 @@ export function Citation({
|
|
|
172
172
|
<div className={isLoading ? "s-opacity-50" : ""}>{cardContent}</div>
|
|
173
173
|
</CardButton>
|
|
174
174
|
);
|
|
175
|
-
return href ?
|
|
176
|
-
<Tooltip label={title} position="above">
|
|
177
|
-
{cardButton}
|
|
178
|
-
</Tooltip>
|
|
179
|
-
) : (
|
|
180
|
-
cardButton
|
|
181
|
-
);
|
|
175
|
+
return href ? <Tooltip trigger={cardButton} label={title} /> : cardButton;
|
|
182
176
|
}
|
|
@@ -22,8 +22,14 @@ import {
|
|
|
22
22
|
import { IconButton } from "@sparkle/components/IconButton";
|
|
23
23
|
import { Pagination } from "@sparkle/components/Pagination";
|
|
24
24
|
import { Tooltip } from "@sparkle/components/Tooltip";
|
|
25
|
-
import {
|
|
26
|
-
|
|
25
|
+
import {
|
|
26
|
+
ArrowDownIcon,
|
|
27
|
+
ArrowUpIcon,
|
|
28
|
+
ClipboardCheckIcon,
|
|
29
|
+
ClipboardIcon,
|
|
30
|
+
MoreIcon,
|
|
31
|
+
} from "@sparkle/icons";
|
|
32
|
+
import { classNames, useCopyToClipboard } from "@sparkle/lib/utils";
|
|
27
33
|
|
|
28
34
|
import { Icon } from "./Icon";
|
|
29
35
|
import { breakpoints, useWindowSize } from "./WindowUtility";
|
|
@@ -435,14 +441,17 @@ DataTable.CellContent = function CellContent({
|
|
|
435
441
|
{...props}
|
|
436
442
|
>
|
|
437
443
|
{avatarUrl && avatarTooltipLabel && (
|
|
438
|
-
<Tooltip
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
444
|
+
<Tooltip
|
|
445
|
+
trigger={
|
|
446
|
+
<Avatar
|
|
447
|
+
visual={avatarUrl}
|
|
448
|
+
size="xs"
|
|
449
|
+
className="s-mr-2"
|
|
450
|
+
isRounded={roundedAvatar ?? false}
|
|
451
|
+
/>
|
|
452
|
+
}
|
|
453
|
+
label={avatarTooltipLabel}
|
|
454
|
+
/>
|
|
446
455
|
)}
|
|
447
456
|
{avatarUrl && !avatarTooltipLabel && (
|
|
448
457
|
<Avatar
|
|
@@ -476,6 +485,50 @@ DataTable.CellContent = function CellContent({
|
|
|
476
485
|
);
|
|
477
486
|
};
|
|
478
487
|
|
|
488
|
+
interface CellContentWithCopyProps {
|
|
489
|
+
children: React.ReactNode;
|
|
490
|
+
textToCopy?: string;
|
|
491
|
+
className?: string;
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
DataTable.CellContentWithCopy = function CellContentWithCopy({
|
|
495
|
+
children,
|
|
496
|
+
textToCopy,
|
|
497
|
+
className,
|
|
498
|
+
}: CellContentWithCopyProps) {
|
|
499
|
+
const [isCopied, copyToClipboard] = useCopyToClipboard();
|
|
500
|
+
|
|
501
|
+
const handleCopy = async () => {
|
|
502
|
+
void copyToClipboard(
|
|
503
|
+
new ClipboardItem({
|
|
504
|
+
"text/plain": new Blob([textToCopy ?? String(children)], {
|
|
505
|
+
type: "text/plain",
|
|
506
|
+
}),
|
|
507
|
+
})
|
|
508
|
+
);
|
|
509
|
+
};
|
|
510
|
+
|
|
511
|
+
return (
|
|
512
|
+
<div
|
|
513
|
+
className={classNames(
|
|
514
|
+
"s-flex s-items-center s-space-x-2",
|
|
515
|
+
className || ""
|
|
516
|
+
)}
|
|
517
|
+
>
|
|
518
|
+
<span className="s-truncate">{children}</span>
|
|
519
|
+
<IconButton
|
|
520
|
+
icon={isCopied ? ClipboardCheckIcon : ClipboardIcon}
|
|
521
|
+
variant="tertiary"
|
|
522
|
+
onClick={async (e) => {
|
|
523
|
+
e.stopPropagation();
|
|
524
|
+
await handleCopy();
|
|
525
|
+
}}
|
|
526
|
+
size="xs"
|
|
527
|
+
/>
|
|
528
|
+
</div>
|
|
529
|
+
);
|
|
530
|
+
};
|
|
531
|
+
|
|
479
532
|
DataTable.Caption = function Caption({
|
|
480
533
|
children,
|
|
481
534
|
className,
|
|
@@ -5,7 +5,7 @@ import ConfettiBackground from "@sparkle/components/ConfettiBackground";
|
|
|
5
5
|
import Spinner from "@sparkle/components/Spinner";
|
|
6
6
|
import { classNames } from "@sparkle/lib/utils";
|
|
7
7
|
|
|
8
|
-
import { Button } from "./Button";
|
|
8
|
+
import { Button, ButtonVariantType } from "./Button";
|
|
9
9
|
|
|
10
10
|
export type BaseDialogProps = {
|
|
11
11
|
backgroundType?: "confetti" | "snow" | "none";
|
|
@@ -16,19 +16,19 @@ export type BaseDialogProps = {
|
|
|
16
16
|
onValidate: () => void;
|
|
17
17
|
title: string;
|
|
18
18
|
validateLabel?: string;
|
|
19
|
-
validateVariant?:
|
|
19
|
+
validateVariant?: ButtonVariantType;
|
|
20
20
|
cancelLabel?: string;
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
export type DialogProps = BaseDialogProps & {
|
|
24
24
|
alertDialog?: false;
|
|
25
25
|
onCancel: () => void;
|
|
26
|
-
}
|
|
26
|
+
};
|
|
27
27
|
|
|
28
28
|
export type AlertDialogProps = BaseDialogProps & {
|
|
29
29
|
alertDialog: true;
|
|
30
30
|
onCancel?: () => void;
|
|
31
|
-
}
|
|
31
|
+
};
|
|
32
32
|
|
|
33
33
|
export function Dialog({
|
|
34
34
|
backgroundType = "none",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Menu, Transition } from "@headlessui/react";
|
|
2
|
+
import { SIDE_OPTIONS } from "@radix-ui/react-popper";
|
|
2
3
|
import React, {
|
|
3
4
|
ComponentType,
|
|
4
5
|
forwardRef,
|
|
@@ -22,7 +23,7 @@ import { classNames } from "@sparkle/lib/utils";
|
|
|
22
23
|
|
|
23
24
|
import { Icon } from "./Icon";
|
|
24
25
|
import { Item as StandardItem, LinkProps } from "./Item";
|
|
25
|
-
import { Tooltip
|
|
26
|
+
import { Tooltip } from "./Tooltip";
|
|
26
27
|
|
|
27
28
|
const ButtonRefContext =
|
|
28
29
|
React.createContext<MutableRefObject<HTMLButtonElement | null> | null>(null);
|
|
@@ -98,7 +99,7 @@ export interface DropdownButtonProps {
|
|
|
98
99
|
type?: "menu" | "submenu" | "select";
|
|
99
100
|
size?: "sm" | "md";
|
|
100
101
|
tooltip?: string;
|
|
101
|
-
tooltipPosition?:
|
|
102
|
+
tooltipPosition?: (typeof SIDE_OPTIONS)[number];
|
|
102
103
|
icon?: ComponentType;
|
|
103
104
|
className?: string;
|
|
104
105
|
disabled?: boolean;
|
|
@@ -116,7 +117,7 @@ DropdownMenu.Button = forwardRef<HTMLButtonElement, DropdownButtonProps>(
|
|
|
116
117
|
tooltip,
|
|
117
118
|
icon,
|
|
118
119
|
children,
|
|
119
|
-
tooltipPosition = "
|
|
120
|
+
tooltipPosition = "top",
|
|
120
121
|
className = "",
|
|
121
122
|
disabled = false,
|
|
122
123
|
onClick,
|
|
@@ -178,9 +179,11 @@ DropdownMenu.Button = forwardRef<HTMLButtonElement, DropdownButtonProps>(
|
|
|
178
179
|
onClick={(e) => e.stopPropagation()}
|
|
179
180
|
>
|
|
180
181
|
{tooltip ? (
|
|
181
|
-
<Tooltip
|
|
182
|
-
{children}
|
|
183
|
-
|
|
182
|
+
<Tooltip
|
|
183
|
+
trigger={children}
|
|
184
|
+
label={tooltip}
|
|
185
|
+
side={tooltipPosition}
|
|
186
|
+
/>
|
|
184
187
|
) : (
|
|
185
188
|
children
|
|
186
189
|
)}
|
|
@@ -198,31 +201,39 @@ DropdownMenu.Button = forwardRef<HTMLButtonElement, DropdownButtonProps>(
|
|
|
198
201
|
return (
|
|
199
202
|
<>
|
|
200
203
|
{tooltip ? (
|
|
201
|
-
<Tooltip
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
204
|
+
<Tooltip
|
|
205
|
+
trigger={
|
|
206
|
+
<Menu.Button
|
|
207
|
+
disabled={disabled}
|
|
208
|
+
ref={aggregatedRef}
|
|
209
|
+
className={classNames(
|
|
210
|
+
disabled ? "s-cursor-default" : "s-cursor-pointer",
|
|
211
|
+
className,
|
|
212
|
+
"s-group/dm s-flex s-justify-items-center s-text-sm s-font-medium focus:s-outline-none focus:s-ring-0",
|
|
213
|
+
label
|
|
214
|
+
? size === "md"
|
|
215
|
+
? "s-gap-2"
|
|
216
|
+
: "s-gap-1.5"
|
|
217
|
+
: "s-gap-0.5"
|
|
218
|
+
)}
|
|
219
|
+
onClick={(e) => {
|
|
220
|
+
e.stopPropagation();
|
|
221
|
+
if (onClick) {
|
|
222
|
+
onClick();
|
|
223
|
+
}
|
|
224
|
+
}}
|
|
225
|
+
>
|
|
226
|
+
<Icon visual={icon} size={size} className={finalIconClasses} />
|
|
227
|
+
<Icon
|
|
228
|
+
visual={chevronIcon}
|
|
229
|
+
size={size === "sm" ? "xs" : "sm"}
|
|
230
|
+
className={finalChevronClasses}
|
|
231
|
+
/>
|
|
232
|
+
</Menu.Button>
|
|
233
|
+
}
|
|
234
|
+
label={tooltip}
|
|
235
|
+
side={tooltipPosition}
|
|
236
|
+
/>
|
|
226
237
|
) : (
|
|
227
238
|
<Menu.Button
|
|
228
239
|
disabled={disabled}
|
|
@@ -17,6 +17,7 @@ export function ElementDialog<T>({
|
|
|
17
17
|
closeDialogFn,
|
|
18
18
|
onValidate,
|
|
19
19
|
onCancel,
|
|
20
|
+
children,
|
|
20
21
|
...props
|
|
21
22
|
}: ElementDialogProps<T>) {
|
|
22
23
|
const [isClosingTransition, setIsClosingTransition] = useState(false);
|
|
@@ -33,6 +34,8 @@ export function ElementDialog<T>({
|
|
|
33
34
|
onCancel={() => onCancel(transitionOnClose)}
|
|
34
35
|
onValidate={() => onValidate(transitionOnClose)}
|
|
35
36
|
{...props}
|
|
36
|
-
|
|
37
|
+
>
|
|
38
|
+
{children}
|
|
39
|
+
</Dialog>
|
|
37
40
|
);
|
|
38
41
|
}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
+
import { SIDE_OPTIONS } from "@radix-ui/react-popper";
|
|
1
2
|
import React, { ComponentType, MouseEventHandler } from "react";
|
|
2
3
|
|
|
3
4
|
import { classNames } from "@sparkle/lib/utils";
|
|
4
5
|
|
|
5
6
|
import { Icon, IconProps } from "./Icon";
|
|
6
|
-
import { Tooltip
|
|
7
|
+
import { Tooltip } from "./Tooltip";
|
|
7
8
|
|
|
8
9
|
type IconButtonProps = {
|
|
9
10
|
variant?: "primary" | "warning" | "secondary" | "tertiary" | "white";
|
|
10
11
|
onClick?: MouseEventHandler<HTMLButtonElement>;
|
|
11
12
|
size?: "xs" | "sm" | "md";
|
|
12
13
|
tooltip?: string;
|
|
13
|
-
tooltipPosition?:
|
|
14
|
+
tooltipPosition?: (typeof SIDE_OPTIONS)[number];
|
|
14
15
|
icon?: ComponentType;
|
|
15
16
|
className?: string;
|
|
16
17
|
disabled?: boolean;
|
|
@@ -87,7 +88,7 @@ export function IconButton({
|
|
|
87
88
|
onClick,
|
|
88
89
|
disabled = false,
|
|
89
90
|
tooltip,
|
|
90
|
-
tooltipPosition = "
|
|
91
|
+
tooltipPosition = "top",
|
|
91
92
|
icon,
|
|
92
93
|
className = "",
|
|
93
94
|
size = "sm",
|
|
@@ -117,9 +118,11 @@ export function IconButton({
|
|
|
117
118
|
);
|
|
118
119
|
|
|
119
120
|
return tooltip ? (
|
|
120
|
-
<Tooltip
|
|
121
|
-
{IconButtonContent}
|
|
122
|
-
|
|
121
|
+
<Tooltip
|
|
122
|
+
trigger={IconButtonContent}
|
|
123
|
+
label={tooltip}
|
|
124
|
+
side={tooltipPosition}
|
|
125
|
+
/>
|
|
123
126
|
) : (
|
|
124
127
|
IconButtonContent
|
|
125
128
|
);
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
+
import { SIDE_OPTIONS } from "@radix-ui/react-popper";
|
|
1
2
|
import React, { ComponentType, MouseEventHandler } from "react";
|
|
2
3
|
|
|
3
4
|
import { classNames } from "@sparkle/lib/utils";
|
|
4
5
|
|
|
5
6
|
import { Icon, IconProps } from "./Icon";
|
|
6
|
-
import { Tooltip
|
|
7
|
+
import { Tooltip } from "./Tooltip";
|
|
7
8
|
|
|
8
9
|
type IconToggleButtonProps = {
|
|
9
10
|
variant?: "secondary" | "tertiary";
|
|
10
11
|
onClick?: MouseEventHandler<HTMLButtonElement>;
|
|
11
12
|
size?: "xs" | "sm" | "md";
|
|
12
13
|
tooltip?: string;
|
|
13
|
-
tooltipPosition?:
|
|
14
|
+
tooltipPosition?: (typeof SIDE_OPTIONS)[number];
|
|
14
15
|
icon: ComponentType;
|
|
15
16
|
iconSelected?: ComponentType;
|
|
16
17
|
className?: string;
|
|
@@ -57,7 +58,7 @@ export function IconToggleButton({
|
|
|
57
58
|
onClick,
|
|
58
59
|
disabled = false,
|
|
59
60
|
tooltip,
|
|
60
|
-
tooltipPosition = "
|
|
61
|
+
tooltipPosition = "top",
|
|
61
62
|
icon,
|
|
62
63
|
iconSelected,
|
|
63
64
|
className = "",
|
|
@@ -105,9 +106,11 @@ export function IconToggleButton({
|
|
|
105
106
|
);
|
|
106
107
|
|
|
107
108
|
return tooltip ? (
|
|
108
|
-
<Tooltip
|
|
109
|
-
{IconButtonToggleContent}
|
|
110
|
-
|
|
109
|
+
<Tooltip
|
|
110
|
+
trigger={IconButtonToggleContent}
|
|
111
|
+
label={tooltip}
|
|
112
|
+
side={tooltipPosition}
|
|
113
|
+
/>
|
|
111
114
|
) : (
|
|
112
115
|
IconButtonToggleContent
|
|
113
116
|
);
|
package/src/components/Input.tsx
CHANGED
|
@@ -26,11 +26,9 @@ type SearchbarProps = {
|
|
|
26
26
|
size?: "xs" | "sm" | "md";
|
|
27
27
|
disabled?: boolean;
|
|
28
28
|
className?: string;
|
|
29
|
-
}
|
|
29
|
+
};
|
|
30
30
|
|
|
31
|
-
export const Searchbar = forwardRef<
|
|
32
|
-
HTMLInputElement, SearchbarProps
|
|
33
|
-
>(
|
|
31
|
+
export const Searchbar = forwardRef<HTMLInputElement, SearchbarProps>(
|
|
34
32
|
(
|
|
35
33
|
{
|
|
36
34
|
placeholder,
|
package/src/components/Tab.tsx
CHANGED
|
@@ -199,7 +199,7 @@ export function Tab<E>({
|
|
|
199
199
|
tab.label ? (
|
|
200
200
|
<React.Fragment key={`tab-${i}`}>
|
|
201
201
|
<div className={tabSizingClasses[tab.sizing ?? "hug"]}>
|
|
202
|
-
<Tooltip label={tab.label}
|
|
202
|
+
<Tooltip trigger={content} label={tab.label} />
|
|
203
203
|
</div>
|
|
204
204
|
{tab.hasSeparator && (
|
|
205
205
|
<div className="s-flex s-h-full s-grow" key={`sep-${i}`} />
|
|
@@ -1,51 +1,46 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from "react";
|
|
2
2
|
|
|
3
3
|
import { classNames } from "@sparkle/lib/utils";
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
value: string | null;
|
|
8
|
-
onChange: (value: string) => void;
|
|
5
|
+
export interface TextAreaProps
|
|
6
|
+
extends React.TextareaHTMLAttributes<HTMLTextAreaElement> {
|
|
9
7
|
error?: string | null;
|
|
10
8
|
showErrorLabel?: boolean;
|
|
11
|
-
className?: string;
|
|
12
9
|
minRows?: number;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export function TextArea({
|
|
16
|
-
placeholder,
|
|
17
|
-
value,
|
|
18
|
-
onChange,
|
|
19
|
-
error,
|
|
20
|
-
showErrorLabel = false,
|
|
21
|
-
className,
|
|
22
|
-
minRows = 10
|
|
23
|
-
}: TextAreaProps) {
|
|
24
|
-
const textareaRef = useRef<HTMLTextAreaElement>(null);
|
|
10
|
+
className?: string;
|
|
11
|
+
}
|
|
25
12
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
13
|
+
export const TextArea = React.forwardRef<HTMLTextAreaElement, TextAreaProps>(
|
|
14
|
+
(
|
|
15
|
+
{
|
|
16
|
+
error,
|
|
17
|
+
showErrorLabel = false,
|
|
18
|
+
className,
|
|
19
|
+
minRows = 10,
|
|
20
|
+
...props
|
|
21
|
+
}: TextAreaProps,
|
|
22
|
+
ref
|
|
23
|
+
) => {
|
|
24
|
+
return (
|
|
25
|
+
<div className="s-flex s-flex-col s-gap-1 s-p-px">
|
|
26
|
+
<textarea
|
|
27
|
+
rows={minRows}
|
|
28
|
+
ref={ref}
|
|
29
|
+
className={classNames(
|
|
30
|
+
"overflow-y-auto s-block s-w-full s-min-w-0 s-rounded-xl s-text-sm s-placeholder-element-700 s-transition-all s-duration-200 s-scrollbar-hide",
|
|
31
|
+
!error
|
|
32
|
+
? "s-border-structure-100 focus:s-border-action-300 focus:s-ring-action-300"
|
|
33
|
+
: "s-border-red-500 focus:s-border-red-500 focus:s-ring-red-500",
|
|
34
|
+
"s-border-structure-200 s-bg-structure-50",
|
|
35
|
+
"s-resize-y",
|
|
36
|
+
className ?? ""
|
|
37
|
+
)}
|
|
38
|
+
{...props}
|
|
39
|
+
/>
|
|
40
|
+
{error && showErrorLabel && (
|
|
41
|
+
<div className="s-ml-2 s-text-sm s-text-warning-500">{error}</div>
|
|
39
42
|
)}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}}
|
|
45
|
-
/>
|
|
46
|
-
{error && showErrorLabel && (
|
|
47
|
-
<div className="s-ml-2 s-text-sm s-text-warning-500">{error}</div>
|
|
48
|
-
)}
|
|
49
|
-
</div>
|
|
50
|
-
);
|
|
51
|
-
}
|
|
43
|
+
</div>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
);
|