@dust-tt/sparkle 0.2.253 → 0.2.254-rc-2
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 +3872 -449
- 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/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/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/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/TextArea.stories.tsx +19 -4
- package/src/stories/Tooltip.stories.tsx +31 -50
- package/src/stories/Tree.stories.tsx +1 -1
|
@@ -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,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";
|
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
2
|
import React from "react";
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
Button,
|
|
6
|
+
Cog6ToothIcon,
|
|
7
|
+
Tooltip,
|
|
8
|
+
TooltipContent,
|
|
9
|
+
TooltipProvider,
|
|
10
|
+
TooltipRoot,
|
|
11
|
+
TooltipTrigger,
|
|
12
|
+
} from "../index_with_tw_base";
|
|
5
13
|
|
|
6
14
|
const meta = {
|
|
7
15
|
title: "Primitives/Button",
|
|
@@ -564,6 +572,41 @@ export const ButtonSelectExamples = () => (
|
|
|
564
572
|
</div>
|
|
565
573
|
);
|
|
566
574
|
|
|
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
|
+
|
|
567
610
|
export const Primary: Story = {
|
|
568
611
|
args: {
|
|
569
612
|
variant: "primary",
|
|
@@ -622,7 +665,7 @@ export const IconOnlyPlusTooltip: Story = {
|
|
|
622
665
|
labelVisible: false,
|
|
623
666
|
icon: Cog6ToothIcon,
|
|
624
667
|
disabled: false,
|
|
625
|
-
tooltipPosition: "
|
|
668
|
+
tooltipPosition: "bottom",
|
|
626
669
|
},
|
|
627
670
|
};
|
|
628
671
|
|
|
@@ -634,7 +677,7 @@ export const IconOnlyNoTooltip: Story = {
|
|
|
634
677
|
labelVisible: false,
|
|
635
678
|
icon: Cog6ToothIcon,
|
|
636
679
|
disabled: false,
|
|
637
|
-
tooltipPosition: "
|
|
680
|
+
tooltipPosition: "bottom",
|
|
638
681
|
disabledTooltip: true,
|
|
639
682
|
},
|
|
640
683
|
};
|
|
@@ -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. Write a 120 character description of the citation here to be displayed in the citation list. 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,7 +161,9 @@ const columns: ColumnDef<Data>[] = [
|
|
|
161
161
|
width: "100px",
|
|
162
162
|
},
|
|
163
163
|
cell: (info) => (
|
|
164
|
-
<DataTable.CellContentWithCopy>
|
|
164
|
+
<DataTable.CellContentWithCopy>
|
|
165
|
+
{info.row.original.addedBy}
|
|
166
|
+
</DataTable.CellContentWithCopy>
|
|
165
167
|
),
|
|
166
168
|
},
|
|
167
169
|
{
|
|
@@ -48,7 +48,10 @@ 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
|
|
51
|
+
<DropdownMenu.Button
|
|
52
|
+
label="Action"
|
|
53
|
+
onClick={() => console.log("CLICK")}
|
|
54
|
+
/>
|
|
52
55
|
<DropdownMenu.Items width={220}>
|
|
53
56
|
<DropdownMenu.SectionHeader label="Edition" />
|
|
54
57
|
<DropdownMenu.Item
|
|
@@ -311,7 +314,7 @@ export const DropdownExample = () => {
|
|
|
311
314
|
<DropdownMenu.Button
|
|
312
315
|
icon={ChatBubbleBottomCenterTextIcon}
|
|
313
316
|
tooltip="Moonlab"
|
|
314
|
-
tooltipPosition="
|
|
317
|
+
tooltipPosition="bottom"
|
|
315
318
|
/>
|
|
316
319
|
<DropdownMenu.Items origin="topLeft" width={120}>
|
|
317
320
|
<DropdownMenu.Item label="item 1 is longish" link={{ href: "#" }} />
|
|
@@ -355,7 +358,7 @@ export const DropdownExample = () => {
|
|
|
355
358
|
<DropdownMenu.Button
|
|
356
359
|
icon={ChatBubbleBottomCenterTextIcon}
|
|
357
360
|
tooltip="Moonlab"
|
|
358
|
-
tooltipPosition="
|
|
361
|
+
tooltipPosition="bottom"
|
|
359
362
|
/>
|
|
360
363
|
<DropdownMenu.Items origin="topLeft">
|
|
361
364
|
<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: "bottom",
|
|
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: "bottom",
|
|
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: "bottom",
|
|
44
44
|
icon: Cog6ToothIcon,
|
|
45
45
|
},
|
|
46
46
|
};
|
|
@@ -23,8 +23,13 @@ export const TextAreaExample = () => {
|
|
|
23
23
|
<TextArea
|
|
24
24
|
placeholder="placeholder"
|
|
25
25
|
onChange={(e) => {
|
|
26
|
-
console.log(e.target.value)
|
|
27
|
-
setTextValues([
|
|
26
|
+
console.log(e.target.value);
|
|
27
|
+
setTextValues([
|
|
28
|
+
e.target.value,
|
|
29
|
+
textValues[1],
|
|
30
|
+
textValues[2],
|
|
31
|
+
textValues[3],
|
|
32
|
+
]);
|
|
28
33
|
}}
|
|
29
34
|
minRows={2}
|
|
30
35
|
defaultValue={textValues[0]}
|
|
@@ -34,7 +39,12 @@ export const TextAreaExample = () => {
|
|
|
34
39
|
defaultValue={textValues[1]}
|
|
35
40
|
error={"errored because blah"}
|
|
36
41
|
onChange={(e) =>
|
|
37
|
-
setTextValues([
|
|
42
|
+
setTextValues([
|
|
43
|
+
textValues[0],
|
|
44
|
+
e.target.value,
|
|
45
|
+
textValues[2],
|
|
46
|
+
textValues[3],
|
|
47
|
+
])
|
|
38
48
|
}
|
|
39
49
|
showErrorLabel
|
|
40
50
|
/>
|
|
@@ -42,7 +52,12 @@ export const TextAreaExample = () => {
|
|
|
42
52
|
placeholder="placeholder"
|
|
43
53
|
defaultValue={textValues[2]}
|
|
44
54
|
onChange={(e) =>
|
|
45
|
-
setTextValues([
|
|
55
|
+
setTextValues([
|
|
56
|
+
textValues[0],
|
|
57
|
+
textValues[1],
|
|
58
|
+
e.target.value,
|
|
59
|
+
textValues[3],
|
|
60
|
+
])
|
|
46
61
|
}
|
|
47
62
|
error={"errored because blah"}
|
|
48
63
|
/>
|