@dust-tt/sparkle 0.2.253 → 0.2.254-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 +3876 -453
- 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.map +1 -1
- package/dist/esm/components/DataTable.js +1 -2
- 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/Modal.d.ts +5 -6
- package/dist/esm/components/Modal.d.ts.map +1 -1
- package/dist/esm/components/Modal.js +4 -4
- package/dist/esm/components/Modal.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/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.d.ts +2 -0
- package/dist/esm/stories/Button.stories.d.ts.map +1 -1
- package/dist/esm/stories/Button.stories.js +14 -3
- 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.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/Modal.stories.d.ts.map +1 -1
- package/dist/esm/stories/Modal.stories.js +1 -6
- package/dist/esm/stories/Modal.stories.js.map +1 -1
- package/dist/esm/stories/TextArea.stories.d.ts.map +1 -1
- package/dist/esm/stories/TextArea.stories.js +18 -3
- 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 +0 -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 +11 -8
- 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/Modal.tsx +11 -17
- package/src/components/Searchbar.tsx +2 -4
- package/src/components/Tab.tsx +1 -1
- package/src/components/Tooltip.tsx +48 -78
- package/src/components/index.ts +7 -1
- package/src/stories/Button.stories.tsx +46 -3
- 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/Modal.stories.tsx +0 -17
- package/src/stories/TextArea.stories.tsx +19 -4
- 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
|
}
|
|
@@ -441,14 +441,17 @@ DataTable.CellContent = function CellContent({
|
|
|
441
441
|
{...props}
|
|
442
442
|
>
|
|
443
443
|
{avatarUrl && avatarTooltipLabel && (
|
|
444
|
-
<Tooltip
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
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
|
+
/>
|
|
452
455
|
)}
|
|
453
456
|
{avatarUrl && !avatarTooltipLabel && (
|
|
454
457
|
<Avatar
|
|
@@ -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
package/src/components/Modal.tsx
CHANGED
|
@@ -61,37 +61,35 @@ const modalStyles = {
|
|
|
61
61
|
};
|
|
62
62
|
|
|
63
63
|
export type ModalProps = {
|
|
64
|
+
isOpen: boolean;
|
|
65
|
+
onClose: () => void;
|
|
64
66
|
action?: ButtonProps;
|
|
65
|
-
alertModal?: boolean;
|
|
66
67
|
children: React.ReactNode;
|
|
67
|
-
className?: string;
|
|
68
68
|
hasChanged: boolean;
|
|
69
|
-
isOpen: boolean;
|
|
70
|
-
isSaving?: boolean;
|
|
71
|
-
onClose: () => void;
|
|
72
69
|
onSave?: () => void;
|
|
73
70
|
saveLabel?: string;
|
|
71
|
+
isSaving?: boolean;
|
|
74
72
|
savingLabel?: string;
|
|
75
73
|
title?: string;
|
|
76
74
|
variant?: "full-screen" | "side-sm" | "side-md" | "dialogue";
|
|
75
|
+
className?: string;
|
|
77
76
|
};
|
|
78
77
|
|
|
79
78
|
const getModalClasses = (type: ModalType) => modalStyles[type] || {};
|
|
80
79
|
|
|
81
80
|
export function Modal({
|
|
81
|
+
isOpen,
|
|
82
|
+
onClose,
|
|
82
83
|
action,
|
|
83
|
-
alertModal,
|
|
84
84
|
children,
|
|
85
|
-
className,
|
|
86
85
|
hasChanged,
|
|
87
|
-
isOpen,
|
|
88
|
-
isSaving,
|
|
89
|
-
onClose,
|
|
90
86
|
onSave,
|
|
91
87
|
saveLabel = "Save",
|
|
88
|
+
isSaving,
|
|
92
89
|
savingLabel,
|
|
93
90
|
title,
|
|
94
91
|
variant = "side-sm",
|
|
92
|
+
className,
|
|
95
93
|
}: ModalProps) {
|
|
96
94
|
const type = variantToType[variant];
|
|
97
95
|
|
|
@@ -131,8 +129,8 @@ export function Modal({
|
|
|
131
129
|
as="div"
|
|
132
130
|
className="s-fixed s-absolute s-inset-0 s-z-50 s-overflow-hidden"
|
|
133
131
|
onClose={() => {
|
|
134
|
-
//
|
|
135
|
-
if (!hasChanged
|
|
132
|
+
// We allow closing the modal by clicking outside of it only if there are no changes
|
|
133
|
+
if (!hasChanged) {
|
|
136
134
|
onClose();
|
|
137
135
|
}
|
|
138
136
|
}}
|
|
@@ -171,11 +169,7 @@ export function Modal({
|
|
|
171
169
|
<BarHeader
|
|
172
170
|
title={title || ""}
|
|
173
171
|
leftActions={action ? <Button {...action} /> : undefined}
|
|
174
|
-
rightActions={
|
|
175
|
-
alertModal ? undefined : (
|
|
176
|
-
<BarHeader.ButtonBar {...buttonBarProps} />
|
|
177
|
-
)
|
|
178
|
-
}
|
|
172
|
+
rightActions={<BarHeader.ButtonBar {...buttonBarProps} />}
|
|
179
173
|
/>
|
|
180
174
|
<div
|
|
181
175
|
className={classNames(
|
|
@@ -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,86 +1,56 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
|
2
|
+
import * as React from "react";
|
|
2
3
|
|
|
3
4
|
import { classNames } from "@sparkle/lib/utils";
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
const TooltipProvider = TooltipPrimitive.Provider;
|
|
7
|
+
|
|
8
|
+
const TooltipRoot = TooltipPrimitive.Root;
|
|
9
|
+
|
|
10
|
+
const TooltipTrigger = TooltipPrimitive.Trigger;
|
|
11
|
+
|
|
12
|
+
interface TooltipContentProps
|
|
13
|
+
extends React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content> {}
|
|
14
|
+
|
|
15
|
+
const TooltipContent = React.forwardRef<
|
|
16
|
+
React.ElementRef<typeof TooltipPrimitive.Content>,
|
|
17
|
+
TooltipContentProps
|
|
18
|
+
>(({ className, sideOffset = 4, ...props }, ref) => (
|
|
19
|
+
<TooltipPrimitive.Content
|
|
20
|
+
ref={ref}
|
|
21
|
+
sideOffset={sideOffset}
|
|
22
|
+
className={classNames(
|
|
23
|
+
"s-bg-primary-50 s-text-primary-700 s-z-50 s-max-w-xs s-overflow-hidden s-rounded-md s-border s-bg-white s-px-3 s-py-1.5 s-text-sm s-shadow-md",
|
|
24
|
+
"s-animate-in s-fade-in-0 s-zoom-in-95",
|
|
25
|
+
"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",
|
|
26
|
+
className || ""
|
|
27
|
+
)}
|
|
28
|
+
{...props}
|
|
29
|
+
/>
|
|
30
|
+
));
|
|
31
|
+
|
|
32
|
+
interface TooltipProps extends TooltipContentProps {
|
|
33
|
+
trigger: React.ReactNode;
|
|
34
|
+
label: React.ReactNode;
|
|
10
35
|
}
|
|
11
36
|
|
|
12
|
-
|
|
13
|
-
children,
|
|
14
|
-
label,
|
|
15
|
-
position = "above",
|
|
16
|
-
contentChildren,
|
|
17
|
-
}: TooltipProps) {
|
|
18
|
-
const [isHovered, setIsHovered] = useState(false);
|
|
19
|
-
const [timerId, setTimerId] = useState<number | null>(null);
|
|
20
|
-
const [isTouchDevice, setIsTouchDevice] = useState(false);
|
|
21
|
-
|
|
22
|
-
const handleMouseOver = () => {
|
|
23
|
-
const id = window.setTimeout(() => {
|
|
24
|
-
setIsHovered(true);
|
|
25
|
-
}, 600);
|
|
26
|
-
setTimerId(id);
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const handleMouseLeave = () => {
|
|
30
|
-
if (timerId !== null) {
|
|
31
|
-
clearTimeout(timerId);
|
|
32
|
-
}
|
|
33
|
-
setIsHovered(false);
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
useEffect(() => {
|
|
37
|
-
setIsTouchDevice("ontouchstart" in window || navigator.maxTouchPoints > 0);
|
|
38
|
-
return () => {
|
|
39
|
-
if (timerId) {
|
|
40
|
-
window.clearTimeout(timerId);
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
}, [timerId]);
|
|
44
|
-
|
|
45
|
-
if (isTouchDevice) {
|
|
46
|
-
return <>{children}</>;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const baseClasses = classNames(
|
|
50
|
-
"s-absolute s-z-10 s-px-3 s-py-2 s-text-sm s-rounded-xl s-border s-shadow-md s-transition-all s-duration-500 s-ease-out s-transform",
|
|
51
|
-
"s-border-structure-100 dark:s-border-structure-50-dark s-bg-structure-0 dark:s-bg-structure-100-dark s-text-element-700 dark:s-text-element-600-dark"
|
|
52
|
-
);
|
|
53
|
-
const hiddenClasses = "s-translate-y-2 s-opacity-0 s-pointer-events-none"; // Added s-pointer-events-none
|
|
54
|
-
const visibleClasses = "-s-translate-y-0 s-opacity-100";
|
|
55
|
-
const hiddenOnMobileClasses = "s-hidden sm:s-block";
|
|
56
|
-
const tooltipCenterClasses = "s-left-1/2 -s-translate-x-1/2";
|
|
57
|
-
const tooltipPositionClasses =
|
|
58
|
-
position === "above" ? "s-bottom-full s-mb-2" : "s-top-full s-mt-2";
|
|
59
|
-
|
|
60
|
-
// if tooltip text is too long we need to wrap it
|
|
61
|
-
const labelLength = label?.length || 0;
|
|
62
|
-
const labelClasses = labelLength > 80 ? "s-w-[38em]" : "s-whitespace-nowrap";
|
|
63
|
-
|
|
37
|
+
function Tooltip({ trigger, label, ...props }: TooltipProps) {
|
|
64
38
|
return (
|
|
65
|
-
<
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
<div
|
|
72
|
-
className={classNames(
|
|
73
|
-
`${isHovered ? visibleClasses : hiddenClasses}`,
|
|
74
|
-
baseClasses,
|
|
75
|
-
hiddenOnMobileClasses,
|
|
76
|
-
tooltipPositionClasses,
|
|
77
|
-
tooltipCenterClasses,
|
|
78
|
-
contentChildren ? "" : labelClasses
|
|
79
|
-
)}
|
|
80
|
-
onAnimationEnd={() => setIsHovered(false)}
|
|
81
|
-
>
|
|
82
|
-
{contentChildren || label}
|
|
83
|
-
</div>
|
|
84
|
-
</div>
|
|
39
|
+
<TooltipProvider>
|
|
40
|
+
<TooltipRoot>
|
|
41
|
+
<TooltipTrigger>{trigger}</TooltipTrigger>
|
|
42
|
+
<TooltipContent {...props}>{label}</TooltipContent>
|
|
43
|
+
</TooltipRoot>
|
|
44
|
+
</TooltipProvider>
|
|
85
45
|
);
|
|
86
46
|
}
|
|
47
|
+
|
|
48
|
+
TooltipContent.displayName = TooltipPrimitive.Content.displayName;
|
|
49
|
+
|
|
50
|
+
export {
|
|
51
|
+
Tooltip,
|
|
52
|
+
TooltipContent,
|
|
53
|
+
TooltipProvider,
|
|
54
|
+
TooltipRoot,
|
|
55
|
+
TooltipTrigger,
|
|
56
|
+
};
|
package/src/components/index.ts
CHANGED
|
@@ -43,6 +43,12 @@ export { SliderToggle } from "./SliderToggle";
|
|
|
43
43
|
export { default as Spinner } from "./Spinner";
|
|
44
44
|
export { Tab } from "./Tab";
|
|
45
45
|
export { TextArea } from "./TextArea";
|
|
46
|
-
export {
|
|
46
|
+
export {
|
|
47
|
+
Tooltip,
|
|
48
|
+
TooltipContent,
|
|
49
|
+
TooltipProvider,
|
|
50
|
+
TooltipRoot,
|
|
51
|
+
TooltipTrigger,
|
|
52
|
+
} from "./Tooltip";
|
|
47
53
|
export { Tree } from "./Tree";
|
|
48
54
|
export { ZoomableImageCitationWrapper } from "./ZoomableImageCitationWrapper";
|