@dust-tt/sparkle 0.2.528 → 0.2.529-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 +1 -1
- package/dist/esm/components/AssistantCard.d.ts +2 -2
- package/dist/esm/components/AssistantCard.d.ts.map +1 -1
- package/dist/esm/components/Button.d.ts +24 -8
- package/dist/esm/components/Button.d.ts.map +1 -1
- package/dist/esm/components/Button.js +29 -33
- package/dist/esm/components/Button.js.map +1 -1
- package/dist/esm/components/Card.d.ts +12 -1
- package/dist/esm/components/Card.d.ts.map +1 -1
- package/dist/esm/components/Card.js.map +1 -1
- package/dist/esm/components/Dialog.d.ts +3 -3
- package/dist/esm/components/Dialog.d.ts.map +1 -1
- package/dist/esm/components/Dialog.js +1 -1
- package/dist/esm/components/Dialog.js.map +1 -1
- package/dist/esm/components/EmptyCTA.d.ts +3 -3
- package/dist/esm/components/EmptyCTA.d.ts.map +1 -1
- package/dist/esm/components/EmptyCTA.js +1 -1
- package/dist/esm/components/EmptyCTA.js.map +1 -1
- package/dist/esm/components/IconButton.d.ts.map +1 -1
- package/dist/esm/components/IconButton.js +1 -1
- package/dist/esm/components/IconButton.js.map +1 -1
- package/dist/esm/components/LinkWrapper.d.ts +1 -0
- package/dist/esm/components/LinkWrapper.d.ts.map +1 -1
- package/dist/esm/components/LinkWrapper.js +2 -2
- package/dist/esm/components/LinkWrapper.js.map +1 -1
- package/dist/esm/components/SplitButton.d.ts +5 -5
- package/dist/esm/components/SplitButton.d.ts.map +1 -1
- package/dist/esm/components/SplitButton.js +1 -1
- package/dist/esm/components/SplitButton.js.map +1 -1
- package/dist/esm/components/Tabs.d.ts +2 -1
- package/dist/esm/components/Tabs.d.ts.map +1 -1
- package/dist/esm/components/Tabs.js +1 -1
- package/dist/esm/components/Tabs.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/context.d.ts +1 -0
- package/dist/esm/context.d.ts.map +1 -1
- package/dist/esm/context.js +7 -4
- package/dist/esm/context.js.map +1 -1
- package/dist/esm/stories/Button.stories.d.ts +2 -2
- package/dist/esm/stories/Button.stories.d.ts.map +1 -1
- package/dist/esm/stories/Button.stories.js +12 -5
- package/dist/esm/stories/Button.stories.js.map +1 -1
- package/dist/esm/stories/Chip.stories.d.ts +1 -0
- package/dist/esm/stories/Chip.stories.d.ts.map +1 -1
- package/dist/esm/stories/EmptyCTA.stories.d.ts.map +1 -1
- package/dist/esm/stories/EmptyCTA.stories.js +4 -6
- package/dist/esm/stories/EmptyCTA.stories.js.map +1 -1
- package/dist/esm/stories/IconButton.stories.d.ts +1 -1
- package/package.json +1 -1
- package/src/components/AssistantCard.tsx +2 -2
- package/src/components/Button.tsx +148 -91
- package/src/components/Card.tsx +2 -2
- package/src/components/Dialog.tsx +8 -3
- package/src/components/EmptyCTA.tsx +11 -13
- package/src/components/IconButton.tsx +0 -1
- package/src/components/LinkWrapper.tsx +26 -19
- package/src/components/SplitButton.tsx +10 -6
- package/src/components/Tabs.tsx +3 -3
- package/src/components/index.ts +2 -2
- package/src/context.tsx +18 -4
- package/src/stories/Button.stories.tsx +24 -4
- package/src/stories/EmptyCTA.stories.tsx +3 -6
|
@@ -10,29 +10,36 @@ export interface LinkWrapperProps {
|
|
|
10
10
|
shallow?: boolean;
|
|
11
11
|
target?: string;
|
|
12
12
|
prefetch?: boolean;
|
|
13
|
+
disabled?: boolean;
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
export const LinkWrapper = React.forwardRef<
|
|
16
17
|
HTMLAnchorElement,
|
|
17
18
|
LinkWrapperProps
|
|
18
|
-
>(
|
|
19
|
-
|
|
19
|
+
>(
|
|
20
|
+
(
|
|
21
|
+
{ children, href, rel, replace, shallow, target, prefetch, disabled },
|
|
22
|
+
ref
|
|
23
|
+
) => {
|
|
24
|
+
const { components } = React.useContext(SparkleContext);
|
|
20
25
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
26
|
+
if (href) {
|
|
27
|
+
return (
|
|
28
|
+
<components.link
|
|
29
|
+
ref={ref}
|
|
30
|
+
href={href}
|
|
31
|
+
target={target}
|
|
32
|
+
rel={rel}
|
|
33
|
+
replace={replace}
|
|
34
|
+
shallow={shallow}
|
|
35
|
+
prefetch={prefetch}
|
|
36
|
+
disabled={disabled}
|
|
37
|
+
>
|
|
38
|
+
{children}
|
|
39
|
+
</components.link>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
36
42
|
|
|
37
|
-
|
|
38
|
-
}
|
|
43
|
+
return children;
|
|
44
|
+
}
|
|
45
|
+
);
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import React, { useState } from "react";
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
|
-
|
|
4
|
+
ButtonAsButtonProps,
|
|
5
5
|
DropdownMenu,
|
|
6
6
|
DropdownMenuContent,
|
|
7
7
|
DropdownMenuItem,
|
|
8
8
|
DropdownMenuTrigger,
|
|
9
|
-
RegularButtonProps,
|
|
10
9
|
} from "@sparkle/components/";
|
|
11
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
Button,
|
|
12
|
+
ButtonProps,
|
|
13
|
+
ButtonVariantType,
|
|
14
|
+
} from "@sparkle/components/Button";
|
|
12
15
|
import { Separator } from "@sparkle/components/Separator";
|
|
13
16
|
import { ChevronDownIcon } from "@sparkle/icons/app";
|
|
14
17
|
import { cn } from "@sparkle/lib";
|
|
@@ -23,7 +26,7 @@ interface SplitButtonActionProps {
|
|
|
23
26
|
}
|
|
24
27
|
|
|
25
28
|
export interface SplitButtonProps
|
|
26
|
-
extends Omit<
|
|
29
|
+
extends Omit<ButtonAsButtonProps, "children" | "onClick"> {
|
|
27
30
|
/**
|
|
28
31
|
* List of possible actions, will be displayed in dropdown
|
|
29
32
|
*/
|
|
@@ -130,9 +133,10 @@ const flexSeparatorVariants: Record<ButtonVariantType, string> = {
|
|
|
130
133
|
"ghost-secondary": "s-bg-separator dark:s-bg-separator-night",
|
|
131
134
|
};
|
|
132
135
|
|
|
133
|
-
export interface FlexSplitButtonProps
|
|
136
|
+
export interface FlexSplitButtonProps
|
|
137
|
+
extends Omit<ButtonAsButtonProps, "size"> {
|
|
134
138
|
containerClassName?: string;
|
|
135
|
-
splitAction: React.ReactElement<
|
|
139
|
+
splitAction: React.ReactElement<ButtonProps>;
|
|
136
140
|
}
|
|
137
141
|
|
|
138
142
|
const FlexSplitButton = React.forwardRef<
|
package/src/components/Tabs.tsx
CHANGED
|
@@ -3,7 +3,7 @@ import { cva, VariantProps } from "class-variance-authority";
|
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
|
|
5
5
|
import { ScrollArea, ScrollBar } from "@sparkle/components/";
|
|
6
|
-
import { Button } from "@sparkle/components/Button";
|
|
6
|
+
import { Button, ButtonProps } from "@sparkle/components/Button";
|
|
7
7
|
import { LinkWrapperProps } from "@sparkle/components/LinkWrapper";
|
|
8
8
|
import { cn } from "@sparkle/lib/utils";
|
|
9
9
|
|
|
@@ -47,7 +47,7 @@ const TabsTrigger = React.forwardRef<
|
|
|
47
47
|
React.ComponentPropsWithoutRef<typeof TabsPrimitive.Trigger> &
|
|
48
48
|
Partial<
|
|
49
49
|
Pick<
|
|
50
|
-
|
|
50
|
+
ButtonProps,
|
|
51
51
|
"label" | "tooltip" | "icon" | "isCounter" | "counterValue" | "variant"
|
|
52
52
|
>
|
|
53
53
|
> & {
|
|
@@ -88,7 +88,7 @@ const TabsTrigger = React.forwardRef<
|
|
|
88
88
|
tooltip={tooltip}
|
|
89
89
|
icon={icon}
|
|
90
90
|
disabled={disabled}
|
|
91
|
-
href={href}
|
|
91
|
+
href={href ?? ""}
|
|
92
92
|
target={target}
|
|
93
93
|
rel={rel}
|
|
94
94
|
replace={replace}
|
package/src/components/index.ts
CHANGED
|
@@ -11,9 +11,9 @@ export { BarHeader } from "./BarHeader";
|
|
|
11
11
|
export type { BreadcrumbItem } from "./Breadcrumbs";
|
|
12
12
|
export { Breadcrumbs } from "./Breadcrumbs";
|
|
13
13
|
export type {
|
|
14
|
+
ButtonAsButtonProps,
|
|
14
15
|
ButtonProps,
|
|
15
|
-
|
|
16
|
-
RegularButtonProps,
|
|
16
|
+
MiniButtonAsButtonProps,
|
|
17
17
|
} from "./Button";
|
|
18
18
|
export { Button } from "./Button";
|
|
19
19
|
export type { CardProps } from "./Card";
|
package/src/context.tsx
CHANGED
|
@@ -2,6 +2,8 @@ import React, { ComponentType, MouseEvent, ReactNode } from "react";
|
|
|
2
2
|
import type { UrlObject } from "url";
|
|
3
3
|
import url from "url";
|
|
4
4
|
|
|
5
|
+
import { cn } from "./lib/utils";
|
|
6
|
+
|
|
5
7
|
type SparkleLinkProps = {
|
|
6
8
|
href: string | UrlObject;
|
|
7
9
|
className?: string;
|
|
@@ -22,6 +24,7 @@ type SparkleLinkProps = {
|
|
|
22
24
|
target?: string;
|
|
23
25
|
rel?: string;
|
|
24
26
|
prefetch?: boolean;
|
|
27
|
+
disabled?: boolean;
|
|
25
28
|
};
|
|
26
29
|
|
|
27
30
|
export type SparkleContextLinkType = ComponentType<
|
|
@@ -34,12 +37,24 @@ export type SparkleContextType = {
|
|
|
34
37
|
};
|
|
35
38
|
};
|
|
36
39
|
|
|
40
|
+
// To mimic disabled button behavior, we disable pointer events
|
|
41
|
+
// if disabled is true.
|
|
37
42
|
export const aLink: SparkleContextLinkType = React.forwardRef<
|
|
38
43
|
HTMLAnchorElement,
|
|
39
44
|
SparkleLinkProps
|
|
40
45
|
>(
|
|
41
46
|
(
|
|
42
|
-
{
|
|
47
|
+
{
|
|
48
|
+
href,
|
|
49
|
+
className,
|
|
50
|
+
ariaCurrent,
|
|
51
|
+
ariaLabel,
|
|
52
|
+
onClick,
|
|
53
|
+
children,
|
|
54
|
+
target,
|
|
55
|
+
rel,
|
|
56
|
+
disabled,
|
|
57
|
+
},
|
|
43
58
|
ref
|
|
44
59
|
) => {
|
|
45
60
|
const hrefAsString = typeof href !== "string" ? url.format(href) : href;
|
|
@@ -48,7 +63,7 @@ export const aLink: SparkleContextLinkType = React.forwardRef<
|
|
|
48
63
|
<a
|
|
49
64
|
ref={ref}
|
|
50
65
|
href={hrefAsString}
|
|
51
|
-
className={className}
|
|
66
|
+
className={cn(className, disabled && "s-pointer-events-none")}
|
|
52
67
|
aria-current={ariaCurrent}
|
|
53
68
|
aria-label={ariaLabel}
|
|
54
69
|
onClick={onClick}
|
|
@@ -64,10 +79,9 @@ export const aLink: SparkleContextLinkType = React.forwardRef<
|
|
|
64
79
|
export const noHrefLink: SparkleContextLinkType = React.forwardRef<
|
|
65
80
|
HTMLAnchorElement,
|
|
66
81
|
SparkleLinkProps
|
|
67
|
-
>(({
|
|
82
|
+
>(({ ariaCurrent, ariaLabel, onClick, children }, ref) => (
|
|
68
83
|
<a
|
|
69
84
|
ref={ref}
|
|
70
|
-
className={className}
|
|
71
85
|
aria-current={ariaCurrent}
|
|
72
86
|
aria-label={ariaLabel}
|
|
73
87
|
onClick={onClick}
|
|
@@ -120,6 +120,13 @@ const ButtonBySize = ({
|
|
|
120
120
|
label="Button with href"
|
|
121
121
|
href="hello"
|
|
122
122
|
/>
|
|
123
|
+
<Button
|
|
124
|
+
size={size}
|
|
125
|
+
variant="primary"
|
|
126
|
+
label="Button with href and disabled"
|
|
127
|
+
href="hello"
|
|
128
|
+
disabled={true}
|
|
129
|
+
/>
|
|
123
130
|
</div>
|
|
124
131
|
<div className="s-flex s-items-center s-gap-4">
|
|
125
132
|
<Button size={size} label="Button" isLoading />
|
|
@@ -140,10 +147,23 @@ const ButtonBySize = ({
|
|
|
140
147
|
|
|
141
148
|
export const Gallery: Story = {
|
|
142
149
|
render: () => (
|
|
143
|
-
<div className="s-flex s-flex-col s-gap-
|
|
144
|
-
<
|
|
145
|
-
|
|
146
|
-
|
|
150
|
+
<div className="s-flex s-flex-col s-gap-6">
|
|
151
|
+
<div className="s-flex s-flex-col s-gap-4">
|
|
152
|
+
<ButtonBySize size="xs" />
|
|
153
|
+
<ButtonBySize size="sm" />
|
|
154
|
+
<ButtonBySize size="md" />
|
|
155
|
+
</div>
|
|
156
|
+
<Separator />
|
|
157
|
+
<h3 className="s-text-primary dark:s-text-primary-50">With tooltip</h3>
|
|
158
|
+
<div className="s-flex s-gap-4">
|
|
159
|
+
<Button label="Button with tooltip" tooltip="Hello" />
|
|
160
|
+
<Button
|
|
161
|
+
label="Button as link with tooltip"
|
|
162
|
+
href="https://dust.tt"
|
|
163
|
+
target="_blank"
|
|
164
|
+
tooltip="Hello"
|
|
165
|
+
/>
|
|
166
|
+
</div>
|
|
147
167
|
</div>
|
|
148
168
|
),
|
|
149
169
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Meta } from "@storybook/react";
|
|
2
2
|
import React from "react";
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
import { CloudArrowDownIcon
|
|
4
|
+
import { EmptyCTA, EmptyCTAButton } from "@sparkle/components";
|
|
5
|
+
import { CloudArrowDownIcon } from "@sparkle/icons/app";
|
|
6
6
|
|
|
7
7
|
const meta = {
|
|
8
8
|
title: "Components/EmptyCTA",
|
|
@@ -12,7 +12,7 @@ export default meta;
|
|
|
12
12
|
|
|
13
13
|
export const Demo = () => {
|
|
14
14
|
return (
|
|
15
|
-
<div
|
|
15
|
+
<div>
|
|
16
16
|
<div className="s-flex s-items-center s-space-x-2">
|
|
17
17
|
<EmptyCTA
|
|
18
18
|
action={
|
|
@@ -24,9 +24,6 @@ export const Demo = () => {
|
|
|
24
24
|
message="You don't have any spaces yet."
|
|
25
25
|
/>
|
|
26
26
|
</div>
|
|
27
|
-
<div className="s-flex s-items-center s-space-x-2">
|
|
28
|
-
<EmptyCTA action={<Button icon={PlusIcon} label="Add domain" />} />
|
|
29
|
-
</div>
|
|
30
27
|
</div>
|
|
31
28
|
);
|
|
32
29
|
};
|