@dust-tt/sparkle 0.2.254-rc-2 → 0.2.254
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 +452 -3875
- 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 +3 -5
- package/dist/esm/components/Button.d.ts.map +1 -1
- package/dist/esm/components/Button.js +3 -11
- 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 +2 -1
- package/dist/esm/components/DataTable.js.map +1 -1
- package/dist/esm/components/Dialog.d.ts +1 -2
- 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 +5 -8
- 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/Tooltip.d.ts +7 -13
- package/dist/esm/components/Tooltip.d.ts.map +1 -1
- package/dist/esm/components/Tooltip.js +42 -18
- package/dist/esm/components/Tooltip.js.map +1 -1
- package/dist/esm/components/Tree.d.ts +2 -1
- package/dist/esm/components/Tree.d.ts.map +1 -1
- package/dist/esm/components/Tree.js +3 -3
- package/dist/esm/components/Tree.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 +0 -2
- package/dist/esm/stories/Button.stories.d.ts.map +1 -1
- package/dist/esm/stories/Button.stories.js +3 -14
- 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/TextArea.stories.d.ts.map +1 -1
- package/dist/esm/stories/TextArea.stories.js +3 -18
- package/dist/esm/stories/TextArea.stories.js.map +1 -1
- package/dist/esm/stories/Tooltip.stories.d.ts +8 -3
- package/dist/esm/stories/Tooltip.stories.d.ts.map +1 -1
- package/dist/esm/stories/Tooltip.stories.js +23 -10
- package/dist/esm/stories/Tooltip.stories.js.map +1 -1
- package/dist/esm/stories/Tree.stories.js.map +1 -1
- package/dist/sparkle.css +68 -0
- package/package.json +1 -3
- package/src/components/BarHeader.tsx +3 -0
- package/src/components/Breadcrumbs.tsx +4 -1
- package/src/components/Button.tsx +14 -17
- package/src/components/Citation.tsx +7 -1
- package/src/components/DataTable.tsx +8 -11
- package/src/components/Dialog.tsx +4 -4
- package/src/components/DropdownMenu.tsx +31 -42
- package/src/components/ElementDialog.tsx +1 -4
- package/src/components/IconButton.tsx +6 -9
- package/src/components/IconToggleButton.tsx +6 -9
- package/src/components/Input.tsx +1 -1
- package/src/components/Searchbar.tsx +4 -2
- package/src/components/Tab.tsx +1 -1
- package/src/components/Tooltip.tsx +78 -48
- package/src/components/Tree.tsx +3 -1
- package/src/components/index.ts +1 -7
- package/src/stories/Button.stories.tsx +3 -46
- package/src/stories/Citation.stories.tsx +1 -1
- package/src/stories/DataTable.stories.tsx +1 -3
- package/src/stories/Dialog.stories.tsx +0 -1
- package/src/stories/DropdownMenu.stories.tsx +3 -6
- package/src/stories/IconButton.stories.tsx +3 -3
- package/src/stories/TextArea.stories.tsx +4 -19
- package/src/stories/Tooltip.stories.tsx +50 -31
- package/src/stories/Tree.stories.tsx +1 -1
|
@@ -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
|
|
8
|
+
import { Button } 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?: "primary" | "primaryWarning";
|
|
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,5 +1,4 @@
|
|
|
1
1
|
import { Menu, Transition } from "@headlessui/react";
|
|
2
|
-
import { SIDE_OPTIONS } from "@radix-ui/react-popper";
|
|
3
2
|
import React, {
|
|
4
3
|
ComponentType,
|
|
5
4
|
forwardRef,
|
|
@@ -23,7 +22,7 @@ import { classNames } from "@sparkle/lib/utils";
|
|
|
23
22
|
|
|
24
23
|
import { Icon } from "./Icon";
|
|
25
24
|
import { Item as StandardItem, LinkProps } from "./Item";
|
|
26
|
-
import { Tooltip } from "./Tooltip";
|
|
25
|
+
import { Tooltip, TooltipProps } from "./Tooltip";
|
|
27
26
|
|
|
28
27
|
const ButtonRefContext =
|
|
29
28
|
React.createContext<MutableRefObject<HTMLButtonElement | null> | null>(null);
|
|
@@ -99,7 +98,7 @@ export interface DropdownButtonProps {
|
|
|
99
98
|
type?: "menu" | "submenu" | "select";
|
|
100
99
|
size?: "sm" | "md";
|
|
101
100
|
tooltip?: string;
|
|
102
|
-
tooltipPosition?:
|
|
101
|
+
tooltipPosition?: TooltipProps["position"];
|
|
103
102
|
icon?: ComponentType;
|
|
104
103
|
className?: string;
|
|
105
104
|
disabled?: boolean;
|
|
@@ -117,7 +116,7 @@ DropdownMenu.Button = forwardRef<HTMLButtonElement, DropdownButtonProps>(
|
|
|
117
116
|
tooltip,
|
|
118
117
|
icon,
|
|
119
118
|
children,
|
|
120
|
-
tooltipPosition = "
|
|
119
|
+
tooltipPosition = "above",
|
|
121
120
|
className = "",
|
|
122
121
|
disabled = false,
|
|
123
122
|
onClick,
|
|
@@ -179,11 +178,9 @@ DropdownMenu.Button = forwardRef<HTMLButtonElement, DropdownButtonProps>(
|
|
|
179
178
|
onClick={(e) => e.stopPropagation()}
|
|
180
179
|
>
|
|
181
180
|
{tooltip ? (
|
|
182
|
-
<Tooltip
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
side={tooltipPosition}
|
|
186
|
-
/>
|
|
181
|
+
<Tooltip position={tooltipPosition} label={tooltip}>
|
|
182
|
+
{children}
|
|
183
|
+
</Tooltip>
|
|
187
184
|
) : (
|
|
188
185
|
children
|
|
189
186
|
)}
|
|
@@ -201,39 +198,31 @@ DropdownMenu.Button = forwardRef<HTMLButtonElement, DropdownButtonProps>(
|
|
|
201
198
|
return (
|
|
202
199
|
<>
|
|
203
200
|
{tooltip ? (
|
|
204
|
-
<Tooltip
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
size={size === "sm" ? "xs" : "sm"}
|
|
230
|
-
className={finalChevronClasses}
|
|
231
|
-
/>
|
|
232
|
-
</Menu.Button>
|
|
233
|
-
}
|
|
234
|
-
label={tooltip}
|
|
235
|
-
side={tooltipPosition}
|
|
236
|
-
/>
|
|
201
|
+
<Tooltip label={tooltip} position={tooltipPosition}>
|
|
202
|
+
<Menu.Button
|
|
203
|
+
disabled={disabled}
|
|
204
|
+
ref={aggregatedRef}
|
|
205
|
+
className={classNames(
|
|
206
|
+
disabled ? "s-cursor-default" : "s-cursor-pointer",
|
|
207
|
+
className,
|
|
208
|
+
"s-group/dm s-flex s-justify-items-center s-text-sm s-font-medium focus:s-outline-none focus:s-ring-0",
|
|
209
|
+
label ? (size === "md" ? "s-gap-2" : "s-gap-1.5") : "s-gap-0.5"
|
|
210
|
+
)}
|
|
211
|
+
onClick={(e) => {
|
|
212
|
+
e.stopPropagation();
|
|
213
|
+
if (onClick) {
|
|
214
|
+
onClick();
|
|
215
|
+
}
|
|
216
|
+
}}
|
|
217
|
+
>
|
|
218
|
+
<Icon visual={icon} size={size} className={finalIconClasses} />
|
|
219
|
+
<Icon
|
|
220
|
+
visual={chevronIcon}
|
|
221
|
+
size={size === "sm" ? "xs" : "sm"}
|
|
222
|
+
className={finalChevronClasses}
|
|
223
|
+
/>
|
|
224
|
+
</Menu.Button>
|
|
225
|
+
</Tooltip>
|
|
237
226
|
) : (
|
|
238
227
|
<Menu.Button
|
|
239
228
|
disabled={disabled}
|
|
@@ -17,7 +17,6 @@ export function ElementDialog<T>({
|
|
|
17
17
|
closeDialogFn,
|
|
18
18
|
onValidate,
|
|
19
19
|
onCancel,
|
|
20
|
-
children,
|
|
21
20
|
...props
|
|
22
21
|
}: ElementDialogProps<T>) {
|
|
23
22
|
const [isClosingTransition, setIsClosingTransition] = useState(false);
|
|
@@ -34,8 +33,6 @@ export function ElementDialog<T>({
|
|
|
34
33
|
onCancel={() => onCancel(transitionOnClose)}
|
|
35
34
|
onValidate={() => onValidate(transitionOnClose)}
|
|
36
35
|
{...props}
|
|
37
|
-
|
|
38
|
-
{children}
|
|
39
|
-
</Dialog>
|
|
36
|
+
/>
|
|
40
37
|
);
|
|
41
38
|
}
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import { SIDE_OPTIONS } from "@radix-ui/react-popper";
|
|
2
1
|
import React, { ComponentType, MouseEventHandler } from "react";
|
|
3
2
|
|
|
4
3
|
import { classNames } from "@sparkle/lib/utils";
|
|
5
4
|
|
|
6
5
|
import { Icon, IconProps } from "./Icon";
|
|
7
|
-
import { Tooltip } from "./Tooltip";
|
|
6
|
+
import { Tooltip, TooltipProps } from "./Tooltip";
|
|
8
7
|
|
|
9
8
|
type IconButtonProps = {
|
|
10
9
|
variant?: "primary" | "warning" | "secondary" | "tertiary" | "white";
|
|
11
10
|
onClick?: MouseEventHandler<HTMLButtonElement>;
|
|
12
11
|
size?: "xs" | "sm" | "md";
|
|
13
12
|
tooltip?: string;
|
|
14
|
-
tooltipPosition?:
|
|
13
|
+
tooltipPosition?: TooltipProps["position"];
|
|
15
14
|
icon?: ComponentType;
|
|
16
15
|
className?: string;
|
|
17
16
|
disabled?: boolean;
|
|
@@ -88,7 +87,7 @@ export function IconButton({
|
|
|
88
87
|
onClick,
|
|
89
88
|
disabled = false,
|
|
90
89
|
tooltip,
|
|
91
|
-
tooltipPosition = "
|
|
90
|
+
tooltipPosition = "above",
|
|
92
91
|
icon,
|
|
93
92
|
className = "",
|
|
94
93
|
size = "sm",
|
|
@@ -118,11 +117,9 @@ export function IconButton({
|
|
|
118
117
|
);
|
|
119
118
|
|
|
120
119
|
return tooltip ? (
|
|
121
|
-
<Tooltip
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
side={tooltipPosition}
|
|
125
|
-
/>
|
|
120
|
+
<Tooltip label={tooltip} position={tooltipPosition}>
|
|
121
|
+
{IconButtonContent}
|
|
122
|
+
</Tooltip>
|
|
126
123
|
) : (
|
|
127
124
|
IconButtonContent
|
|
128
125
|
);
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import { SIDE_OPTIONS } from "@radix-ui/react-popper";
|
|
2
1
|
import React, { ComponentType, MouseEventHandler } from "react";
|
|
3
2
|
|
|
4
3
|
import { classNames } from "@sparkle/lib/utils";
|
|
5
4
|
|
|
6
5
|
import { Icon, IconProps } from "./Icon";
|
|
7
|
-
import { Tooltip } from "./Tooltip";
|
|
6
|
+
import { Tooltip, TooltipProps } from "./Tooltip";
|
|
8
7
|
|
|
9
8
|
type IconToggleButtonProps = {
|
|
10
9
|
variant?: "secondary" | "tertiary";
|
|
11
10
|
onClick?: MouseEventHandler<HTMLButtonElement>;
|
|
12
11
|
size?: "xs" | "sm" | "md";
|
|
13
12
|
tooltip?: string;
|
|
14
|
-
tooltipPosition?:
|
|
13
|
+
tooltipPosition?: TooltipProps["position"];
|
|
15
14
|
icon: ComponentType;
|
|
16
15
|
iconSelected?: ComponentType;
|
|
17
16
|
className?: string;
|
|
@@ -58,7 +57,7 @@ export function IconToggleButton({
|
|
|
58
57
|
onClick,
|
|
59
58
|
disabled = false,
|
|
60
59
|
tooltip,
|
|
61
|
-
tooltipPosition = "
|
|
60
|
+
tooltipPosition = "above",
|
|
62
61
|
icon,
|
|
63
62
|
iconSelected,
|
|
64
63
|
className = "",
|
|
@@ -106,11 +105,9 @@ export function IconToggleButton({
|
|
|
106
105
|
);
|
|
107
106
|
|
|
108
107
|
return tooltip ? (
|
|
109
|
-
<Tooltip
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
side={tooltipPosition}
|
|
113
|
-
/>
|
|
108
|
+
<Tooltip label={tooltip} position={tooltipPosition}>
|
|
109
|
+
{IconButtonToggleContent}
|
|
110
|
+
</Tooltip>
|
|
114
111
|
) : (
|
|
115
112
|
IconButtonToggleContent
|
|
116
113
|
);
|
package/src/components/Input.tsx
CHANGED
|
@@ -26,9 +26,11 @@ 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<
|
|
31
|
+
export const Searchbar = forwardRef<
|
|
32
|
+
HTMLInputElement, SearchbarProps
|
|
33
|
+
>(
|
|
32
34
|
(
|
|
33
35
|
{
|
|
34
36
|
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
|
|
202
|
+
<Tooltip label={tab.label}>{content}</Tooltip>
|
|
203
203
|
</div>
|
|
204
204
|
{tab.hasSeparator && (
|
|
205
205
|
<div className="s-flex s-h-full s-grow" key={`sep-${i}`} />
|
|
@@ -1,56 +1,86 @@
|
|
|
1
|
-
import
|
|
2
|
-
import * as React from "react";
|
|
1
|
+
import React, { useEffect, useState } from "react";
|
|
3
2
|
|
|
4
3
|
import { classNames } from "@sparkle/lib/utils";
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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;
|
|
5
|
+
export interface TooltipProps {
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
label?: string;
|
|
8
|
+
position?: "above" | "below";
|
|
9
|
+
contentChildren?: React.ReactNode;
|
|
35
10
|
}
|
|
36
11
|
|
|
37
|
-
function Tooltip({
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
12
|
+
export function Tooltip({
|
|
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"
|
|
45
52
|
);
|
|
46
|
-
|
|
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";
|
|
47
59
|
|
|
48
|
-
|
|
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";
|
|
49
63
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
64
|
+
return (
|
|
65
|
+
<div
|
|
66
|
+
onMouseEnter={handleMouseOver}
|
|
67
|
+
onMouseLeave={handleMouseLeave}
|
|
68
|
+
className="s-relative s-inline-block"
|
|
69
|
+
>
|
|
70
|
+
{children}
|
|
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>
|
|
85
|
+
);
|
|
86
|
+
}
|
package/src/components/Tree.tsx
CHANGED
|
@@ -81,6 +81,7 @@ interface TreeItemProps {
|
|
|
81
81
|
collapsed?: boolean;
|
|
82
82
|
defaultCollapsed?: boolean;
|
|
83
83
|
className?: string;
|
|
84
|
+
labelClassName?: string;
|
|
84
85
|
actions?: React.ReactNode;
|
|
85
86
|
areActionsFading?: boolean;
|
|
86
87
|
isNavigatable?: boolean;
|
|
@@ -102,6 +103,7 @@ Tree.Item = function ({
|
|
|
102
103
|
label,
|
|
103
104
|
type = "node",
|
|
104
105
|
className = "",
|
|
106
|
+
labelClassName = "",
|
|
105
107
|
size = "sm",
|
|
106
108
|
tailwindIconTextColor = "s-text-element-800",
|
|
107
109
|
visual,
|
|
@@ -188,7 +190,7 @@ Tree.Item = function ({
|
|
|
188
190
|
|
|
189
191
|
<div
|
|
190
192
|
className={classNames(
|
|
191
|
-
|
|
193
|
+
`s-truncate s-font-medium s-text-element-900 ${labelClassName}`,
|
|
192
194
|
size === "sm" ? "s-ml-1 s-text-sm" : "s-ml-1 s-text-base"
|
|
193
195
|
)}
|
|
194
196
|
>
|
package/src/components/index.ts
CHANGED
|
@@ -43,12 +43,6 @@ 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 {
|
|
47
|
-
Tooltip,
|
|
48
|
-
TooltipContent,
|
|
49
|
-
TooltipProvider,
|
|
50
|
-
TooltipRoot,
|
|
51
|
-
TooltipTrigger,
|
|
52
|
-
} from "./Tooltip";
|
|
46
|
+
export { Tooltip } from "./Tooltip";
|
|
53
47
|
export { Tree } from "./Tree";
|
|
54
48
|
export { ZoomableImageCitationWrapper } from "./ZoomableImageCitationWrapper";
|
|
@@ -1,15 +1,7 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
2
|
import React from "react";
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
Button,
|
|
6
|
-
Cog6ToothIcon,
|
|
7
|
-
Tooltip,
|
|
8
|
-
TooltipContent,
|
|
9
|
-
TooltipProvider,
|
|
10
|
-
TooltipRoot,
|
|
11
|
-
TooltipTrigger,
|
|
12
|
-
} from "../index_with_tw_base";
|
|
4
|
+
import { Button, Cog6ToothIcon } from "../index_with_tw_base";
|
|
13
5
|
|
|
14
6
|
const meta = {
|
|
15
7
|
title: "Primitives/Button",
|
|
@@ -572,41 +564,6 @@ export const ButtonSelectExamples = () => (
|
|
|
572
564
|
</div>
|
|
573
565
|
);
|
|
574
566
|
|
|
575
|
-
export const ButtonWithTooltipManualInstantiation = () => {
|
|
576
|
-
return (
|
|
577
|
-
<TooltipProvider>
|
|
578
|
-
<TooltipRoot>
|
|
579
|
-
<TooltipTrigger>
|
|
580
|
-
<Button
|
|
581
|
-
labelVisible={true}
|
|
582
|
-
label="New conversation"
|
|
583
|
-
icon={Cog6ToothIcon}
|
|
584
|
-
hasMagnifying={false}
|
|
585
|
-
/>
|
|
586
|
-
</TooltipTrigger>
|
|
587
|
-
<TooltipContent>
|
|
588
|
-
<p>Hello</p>
|
|
589
|
-
</TooltipContent>
|
|
590
|
-
</TooltipRoot>
|
|
591
|
-
</TooltipProvider>
|
|
592
|
-
)}
|
|
593
|
-
|
|
594
|
-
export const ButtonWithTooltip = () => {
|
|
595
|
-
return (
|
|
596
|
-
<Tooltip
|
|
597
|
-
trigger={
|
|
598
|
-
<Button
|
|
599
|
-
labelVisible={true}
|
|
600
|
-
label="New conversation"
|
|
601
|
-
icon={Cog6ToothIcon}
|
|
602
|
-
hasMagnifying={false}
|
|
603
|
-
/>
|
|
604
|
-
}
|
|
605
|
-
label={"Hello"}
|
|
606
|
-
/>
|
|
607
|
-
)
|
|
608
|
-
}
|
|
609
|
-
|
|
610
567
|
export const Primary: Story = {
|
|
611
568
|
args: {
|
|
612
569
|
variant: "primary",
|
|
@@ -665,7 +622,7 @@ export const IconOnlyPlusTooltip: Story = {
|
|
|
665
622
|
labelVisible: false,
|
|
666
623
|
icon: Cog6ToothIcon,
|
|
667
624
|
disabled: false,
|
|
668
|
-
tooltipPosition: "
|
|
625
|
+
tooltipPosition: "below",
|
|
669
626
|
},
|
|
670
627
|
};
|
|
671
628
|
|
|
@@ -677,7 +634,7 @@ export const IconOnlyNoTooltip: Story = {
|
|
|
677
634
|
labelVisible: false,
|
|
678
635
|
icon: Cog6ToothIcon,
|
|
679
636
|
disabled: false,
|
|
680
|
-
tooltipPosition: "
|
|
637
|
+
tooltipPosition: "below",
|
|
681
638
|
disabledTooltip: true,
|
|
682
639
|
},
|
|
683
640
|
};
|
|
@@ -133,7 +133,7 @@ export const CitationsExample = () => (
|
|
|
133
133
|
type="google_drive"
|
|
134
134
|
index="3"
|
|
135
135
|
href="https://www.google.com"
|
|
136
|
-
description="Write a 120 character description of the citation here to be displayed in the citation list.
|
|
136
|
+
description="Write a 120 character description of the citation here to be displayed in the citation list."
|
|
137
137
|
isBlinking={true}
|
|
138
138
|
/>
|
|
139
139
|
<Citation
|
|
@@ -161,9 +161,7 @@ const columns: ColumnDef<Data>[] = [
|
|
|
161
161
|
width: "100px",
|
|
162
162
|
},
|
|
163
163
|
cell: (info) => (
|
|
164
|
-
<DataTable.CellContentWithCopy>
|
|
165
|
-
{info.row.original.addedBy}
|
|
166
|
-
</DataTable.CellContentWithCopy>
|
|
164
|
+
<DataTable.CellContentWithCopy>{info.row.original.addedBy}</DataTable.CellContentWithCopy>
|
|
167
165
|
),
|
|
168
166
|
},
|
|
169
167
|
{
|
|
@@ -48,10 +48,7 @@ export const DropdownExample = () => {
|
|
|
48
48
|
<div className="s-flex s-gap-6">
|
|
49
49
|
<div className="s-text-sm">Action</div>
|
|
50
50
|
<DropdownMenu>
|
|
51
|
-
<DropdownMenu.Button
|
|
52
|
-
label="Action"
|
|
53
|
-
onClick={() => console.log("CLICK")}
|
|
54
|
-
/>
|
|
51
|
+
<DropdownMenu.Button label="Action" onClick={() => console.log("CLICK")}/>
|
|
55
52
|
<DropdownMenu.Items width={220}>
|
|
56
53
|
<DropdownMenu.SectionHeader label="Edition" />
|
|
57
54
|
<DropdownMenu.Item
|
|
@@ -314,7 +311,7 @@ export const DropdownExample = () => {
|
|
|
314
311
|
<DropdownMenu.Button
|
|
315
312
|
icon={ChatBubbleBottomCenterTextIcon}
|
|
316
313
|
tooltip="Moonlab"
|
|
317
|
-
tooltipPosition="
|
|
314
|
+
tooltipPosition="below"
|
|
318
315
|
/>
|
|
319
316
|
<DropdownMenu.Items origin="topLeft" width={120}>
|
|
320
317
|
<DropdownMenu.Item label="item 1 is longish" link={{ href: "#" }} />
|
|
@@ -358,7 +355,7 @@ export const DropdownExample = () => {
|
|
|
358
355
|
<DropdownMenu.Button
|
|
359
356
|
icon={ChatBubbleBottomCenterTextIcon}
|
|
360
357
|
tooltip="Moonlab"
|
|
361
|
-
tooltipPosition="
|
|
358
|
+
tooltipPosition="below"
|
|
362
359
|
/>
|
|
363
360
|
<DropdownMenu.Items origin="topLeft">
|
|
364
361
|
<DropdownMenu.Item label="item 1" link={{ href: "#" }} />
|
|
@@ -22,7 +22,7 @@ export const IconButtonWithTooltip: Story = {
|
|
|
22
22
|
args: {
|
|
23
23
|
variant: "primary",
|
|
24
24
|
tooltip: "Your settings",
|
|
25
|
-
tooltipPosition: "
|
|
25
|
+
tooltipPosition: "below",
|
|
26
26
|
icon: Cog6ToothIcon,
|
|
27
27
|
},
|
|
28
28
|
};
|
|
@@ -31,7 +31,7 @@ export const IconButtonSecondary: Story = {
|
|
|
31
31
|
args: {
|
|
32
32
|
variant: "secondary",
|
|
33
33
|
tooltip: "This a secondary IconButton",
|
|
34
|
-
tooltipPosition: "
|
|
34
|
+
tooltipPosition: "below",
|
|
35
35
|
icon: Cog6ToothIcon,
|
|
36
36
|
},
|
|
37
37
|
};
|
|
@@ -40,7 +40,7 @@ export const IconButtonTertiary: Story = {
|
|
|
40
40
|
args: {
|
|
41
41
|
variant: "tertiary",
|
|
42
42
|
tooltip: "This a tertiary IconButton",
|
|
43
|
-
tooltipPosition: "
|
|
43
|
+
tooltipPosition: "below",
|
|
44
44
|
icon: Cog6ToothIcon,
|
|
45
45
|
},
|
|
46
46
|
};
|
|
@@ -23,13 +23,8 @@ export const TextAreaExample = () => {
|
|
|
23
23
|
<TextArea
|
|
24
24
|
placeholder="placeholder"
|
|
25
25
|
onChange={(e) => {
|
|
26
|
-
console.log(e.target.value)
|
|
27
|
-
setTextValues([
|
|
28
|
-
e.target.value,
|
|
29
|
-
textValues[1],
|
|
30
|
-
textValues[2],
|
|
31
|
-
textValues[3],
|
|
32
|
-
]);
|
|
26
|
+
console.log(e.target.value)
|
|
27
|
+
setTextValues([e.target.value, textValues[1], textValues[2], textValues[3]])
|
|
33
28
|
}}
|
|
34
29
|
minRows={2}
|
|
35
30
|
defaultValue={textValues[0]}
|
|
@@ -39,12 +34,7 @@ export const TextAreaExample = () => {
|
|
|
39
34
|
defaultValue={textValues[1]}
|
|
40
35
|
error={"errored because blah"}
|
|
41
36
|
onChange={(e) =>
|
|
42
|
-
setTextValues([
|
|
43
|
-
textValues[0],
|
|
44
|
-
e.target.value,
|
|
45
|
-
textValues[2],
|
|
46
|
-
textValues[3],
|
|
47
|
-
])
|
|
37
|
+
setTextValues([textValues[0], e.target.value, textValues[2], textValues[3]])
|
|
48
38
|
}
|
|
49
39
|
showErrorLabel
|
|
50
40
|
/>
|
|
@@ -52,12 +42,7 @@ export const TextAreaExample = () => {
|
|
|
52
42
|
placeholder="placeholder"
|
|
53
43
|
defaultValue={textValues[2]}
|
|
54
44
|
onChange={(e) =>
|
|
55
|
-
setTextValues([
|
|
56
|
-
textValues[0],
|
|
57
|
-
textValues[1],
|
|
58
|
-
e.target.value,
|
|
59
|
-
textValues[3],
|
|
60
|
-
])
|
|
45
|
+
setTextValues([textValues[0], textValues[1], e.target.value, textValues[3]])
|
|
61
46
|
}
|
|
62
47
|
error={"errored because blah"}
|
|
63
48
|
/>
|