@dust-tt/sparkle 0.2.472 → 0.2.474-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 +1 -1
- package/dist/esm/components/Button.d.ts +2 -2
- package/dist/esm/components/Button.d.ts.map +1 -1
- package/dist/esm/components/Button.js +29 -13
- package/dist/esm/components/Button.js.map +1 -1
- package/dist/esm/components/Counter.js +9 -9
- package/dist/esm/components/Counter.js.map +1 -1
- package/dist/esm/components/Dropdown.d.ts.map +1 -1
- package/dist/esm/components/Dropdown.js +5 -3
- package/dist/esm/components/Dropdown.js.map +1 -1
- package/dist/esm/components/SplitButton.d.ts.map +1 -1
- package/dist/esm/components/SplitButton.js +2 -13
- package/dist/esm/components/SplitButton.js.map +1 -1
- package/dist/esm/components/Tree.js +3 -3
- package/dist/esm/components/Tree.js.map +1 -1
- package/dist/esm/stories/Button.stories.d.ts +1 -1
- package/dist/esm/stories/IconButton.stories.d.ts +1 -1
- package/dist/sparkle.css +23 -10
- package/package.json +1 -1
- package/src/components/Button.tsx +43 -14
- package/src/components/Counter.tsx +9 -9
- package/src/components/Dropdown.tsx +18 -3
- package/src/components/SplitButton.tsx +2 -19
- package/src/components/Tree.tsx +3 -3
|
@@ -29,7 +29,7 @@ export const BUTTON_VARIANTS = [
|
|
|
29
29
|
|
|
30
30
|
export type ButtonVariantType = (typeof BUTTON_VARIANTS)[number];
|
|
31
31
|
|
|
32
|
-
export const BUTTON_SIZES = ["mini", "xs", "sm", "md"] as const;
|
|
32
|
+
export const BUTTON_SIZES = ["xmini", "mini", "xs", "sm", "md"] as const;
|
|
33
33
|
export type ButtonSizeType = (typeof BUTTON_SIZES)[number];
|
|
34
34
|
|
|
35
35
|
// Define button styling with cva
|
|
@@ -97,10 +97,11 @@ const buttonVariants = cva(
|
|
|
97
97
|
),
|
|
98
98
|
},
|
|
99
99
|
size: {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
100
|
+
xmini: "s-h-6 s-w-6 s-rounded-lg s-label-xs s-gap-1 s-shrink-0",
|
|
101
|
+
mini: "s-h-7 s-w-7 s-rounded-lg s-label-xs s-gap-1.5 s-shrink-0",
|
|
102
|
+
xs: "s-h-7 s-px-2.5 s-rounded-lg s-label-xs s-gap-1.5 s-shrink-0",
|
|
103
|
+
sm: "s-h-9 s-px-3 s-rounded-xl s-label-sm s-gap-2 s-shrink-0",
|
|
104
|
+
md: "s-h-12 s-px-4 s-py-2 s-rounded-2xl s-label-base s-gap-2.5 s-shrink-0",
|
|
104
105
|
},
|
|
105
106
|
},
|
|
106
107
|
defaultVariants: {
|
|
@@ -113,7 +114,8 @@ const buttonVariants = cva(
|
|
|
113
114
|
const labelVariants = cva("", {
|
|
114
115
|
variants: {
|
|
115
116
|
size: {
|
|
116
|
-
|
|
117
|
+
xmini: "s-label-xs s-hidden",
|
|
118
|
+
mini: "s-label-xs s-hidden",
|
|
117
119
|
xs: "s-label-xs",
|
|
118
120
|
sm: "s-label-sm",
|
|
119
121
|
md: "s-label-base",
|
|
@@ -166,6 +168,25 @@ const MetaButton = React.forwardRef<HTMLButtonElement, MetaButtonProps>(
|
|
|
166
168
|
);
|
|
167
169
|
MetaButton.displayName = "MetaButton";
|
|
168
170
|
|
|
171
|
+
type IconSizeType = "xs" | "sm" | "md";
|
|
172
|
+
type CounterSizeType = "xs" | "sm" | "md";
|
|
173
|
+
|
|
174
|
+
const ICON_SIZE_MAP: Record<ButtonSizeType, IconSizeType> = {
|
|
175
|
+
xmini: "xs",
|
|
176
|
+
mini: "sm",
|
|
177
|
+
xs: "xs",
|
|
178
|
+
sm: "sm",
|
|
179
|
+
md: "md",
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
const COUNTER_SIZE_MAP: Record<ButtonSizeType, CounterSizeType> = {
|
|
183
|
+
xmini: "xs",
|
|
184
|
+
mini: "xs",
|
|
185
|
+
xs: "xs",
|
|
186
|
+
sm: "sm",
|
|
187
|
+
md: "md",
|
|
188
|
+
};
|
|
189
|
+
|
|
169
190
|
type CommonButtonProps = Omit<MetaButtonProps, "children"> &
|
|
170
191
|
Omit<LinkWrapperProps, "children"> & {
|
|
171
192
|
isSelect?: boolean;
|
|
@@ -214,17 +235,16 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
|
214
235
|
},
|
|
215
236
|
ref
|
|
216
237
|
) => {
|
|
217
|
-
const
|
|
218
|
-
const
|
|
219
|
-
(variant && spinnerVariantsMap[variant]) || "gray400";
|
|
238
|
+
const iconSize = ICON_SIZE_MAP[size];
|
|
239
|
+
const counterSize = COUNTER_SIZE_MAP[size];
|
|
220
240
|
|
|
221
241
|
const renderIcon = (visual: React.ComponentType, extraClass = "") => (
|
|
222
|
-
<Icon visual={visual} size={
|
|
242
|
+
<Icon visual={visual} size={iconSize} className={cn(extraClass)} />
|
|
223
243
|
);
|
|
224
244
|
const renderChevron = (visual: React.ComponentType, extraClass = "") => (
|
|
225
245
|
<Icon
|
|
226
246
|
visual={visual}
|
|
227
|
-
size={
|
|
247
|
+
size={iconSize}
|
|
228
248
|
className={cn(variant ? chevronVariantMap[variant] : "", extraClass)}
|
|
229
249
|
/>
|
|
230
250
|
);
|
|
@@ -235,8 +255,17 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
|
235
255
|
const content = (
|
|
236
256
|
<>
|
|
237
257
|
{isLoading ? (
|
|
238
|
-
<div
|
|
239
|
-
|
|
258
|
+
<div
|
|
259
|
+
className={cn(
|
|
260
|
+
"-s-mx-0.5",
|
|
261
|
+
size === "mini" && "s-w-5 s-px-0.5",
|
|
262
|
+
size === "xmini" && "s-w-5 s-px-0.5"
|
|
263
|
+
)}
|
|
264
|
+
>
|
|
265
|
+
<Spinner
|
|
266
|
+
size={size === "mini" || size === "xmini" ? "xs" : iconSize}
|
|
267
|
+
variant={(variant && spinnerVariantsMap[variant]) || "gray400"}
|
|
268
|
+
/>
|
|
240
269
|
</div>
|
|
241
270
|
) : (
|
|
242
271
|
icon && renderIcon(icon, "-s-mx-0.5")
|
|
@@ -254,7 +283,7 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
|
254
283
|
<Counter
|
|
255
284
|
value={Number(counterValue)}
|
|
256
285
|
variant={variant || "primary"}
|
|
257
|
-
size={
|
|
286
|
+
size={counterSize}
|
|
258
287
|
isInButton={true}
|
|
259
288
|
/>
|
|
260
289
|
)}
|
|
@@ -6,13 +6,13 @@ import { cn } from "@sparkle/lib/utils";
|
|
|
6
6
|
export const COUNTER_SIZES = ["xs", "sm", "md"] as const;
|
|
7
7
|
|
|
8
8
|
const counterVariants = cva(
|
|
9
|
-
"s-inline-flex s-items-center s-justify-center s-rounded-full
|
|
9
|
+
"s-inline-flex s-items-center s-justify-center s-rounded-full",
|
|
10
10
|
{
|
|
11
11
|
variants: {
|
|
12
12
|
size: {
|
|
13
|
-
xs: "s-h-5 s-min-w-[
|
|
14
|
-
sm: "s-h-6 s-min-w-[
|
|
15
|
-
md: "s-h-7 s-min-w-[
|
|
13
|
+
xs: "s-h-5 s-min-w-[20px] s-px-1 s-text-xs",
|
|
14
|
+
sm: "s-h-6 s-min-w-[24px] s-px-1.5 s-text-sm",
|
|
15
|
+
md: "s-h-7 s-min-w-[28px] s-px-2 s-text-base",
|
|
16
16
|
},
|
|
17
17
|
variant: {
|
|
18
18
|
primary: "",
|
|
@@ -32,27 +32,27 @@ const counterVariants = cva(
|
|
|
32
32
|
isInButton: false,
|
|
33
33
|
variant: "primary",
|
|
34
34
|
className:
|
|
35
|
-
"s-bg-primary dark:s-bg-primary-night s-text-primary-50 dark:s-text-primary-800",
|
|
35
|
+
"s-bg-primary dark:s-bg-primary-night s-text-primary-50 dark:s-text-primary-800 s-font-medium",
|
|
36
36
|
},
|
|
37
37
|
{
|
|
38
38
|
isInButton: false,
|
|
39
39
|
variant: "highlight",
|
|
40
|
-
className: "s-bg-highlight s-text-white",
|
|
40
|
+
className: "s-bg-highlight s-text-white s-font-medium",
|
|
41
41
|
},
|
|
42
42
|
{
|
|
43
43
|
isInButton: false,
|
|
44
44
|
variant: "warning",
|
|
45
|
-
className: "s-bg-warning s-text-white",
|
|
45
|
+
className: "s-bg-warning s-text-white s-font-medium",
|
|
46
46
|
},
|
|
47
47
|
{
|
|
48
48
|
isInButton: false,
|
|
49
49
|
variant: "outline",
|
|
50
|
-
className: "s-bg-primary-200 s-text-primary-900",
|
|
50
|
+
className: "s-bg-primary-200 s-text-primary-900 s-font-medium",
|
|
51
51
|
},
|
|
52
52
|
{
|
|
53
53
|
isInButton: false,
|
|
54
54
|
variant: ["ghost", "ghost-secondary"],
|
|
55
|
-
className: "s-text-primary dark:s-text-primary-night",
|
|
55
|
+
className: "s-text-primary dark:s-text-primary-night s-font-medium",
|
|
56
56
|
},
|
|
57
57
|
{
|
|
58
58
|
isInButton: true,
|
|
@@ -6,6 +6,7 @@ import { useRef } from "react";
|
|
|
6
6
|
import { DoubleIcon } from "@sparkle/components/DoubleIcon";
|
|
7
7
|
import { Icon } from "@sparkle/components/Icon";
|
|
8
8
|
import { LinkWrapper, LinkWrapperProps } from "@sparkle/components/LinkWrapper";
|
|
9
|
+
import { ScrollArea } from "@sparkle/components/ScrollArea";
|
|
9
10
|
import { SearchInput, SearchInputProps } from "@sparkle/components/SearchInput";
|
|
10
11
|
import { CheckIcon, ChevronRightIcon, CircleIcon } from "@sparkle/icons/app";
|
|
11
12
|
import { cn } from "@sparkle/lib/utils";
|
|
@@ -21,7 +22,7 @@ export const menuStyleClasses = {
|
|
|
21
22
|
"s-border s-border-border dark:s-border-border-night",
|
|
22
23
|
"s-bg-background dark:s-bg-muted-background-night",
|
|
23
24
|
"s-text-foreground dark:s-text-foreground-night",
|
|
24
|
-
"s-z-50 s-min-w-[8rem]
|
|
25
|
+
"s-z-50 s-min-w-[8rem]",
|
|
25
26
|
"data-[state=open]:s-animate-in data-[state=closed]:s-animate-out data-[state=closed]:s-fade-out-0 data-[state=open]:s-fade-in-0 data-[state=closed]:s-zoom-out-95 data-[state=open]:s-zoom-in-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
27
|
),
|
|
27
28
|
item: cva(
|
|
@@ -228,6 +229,7 @@ const DropdownMenuContent = React.forwardRef<
|
|
|
228
229
|
sideOffset = 4,
|
|
229
230
|
mountPortal = true,
|
|
230
231
|
mountPortalContainer,
|
|
232
|
+
children,
|
|
231
233
|
...props
|
|
232
234
|
},
|
|
233
235
|
ref
|
|
@@ -236,9 +238,22 @@ const DropdownMenuContent = React.forwardRef<
|
|
|
236
238
|
<DropdownMenuPrimitive.Content
|
|
237
239
|
ref={ref}
|
|
238
240
|
sideOffset={sideOffset}
|
|
239
|
-
className={cn(
|
|
241
|
+
className={cn(
|
|
242
|
+
menuStyleClasses.container,
|
|
243
|
+
"s-h-fit s-p-0 s-shadow-md",
|
|
244
|
+
className
|
|
245
|
+
)}
|
|
240
246
|
{...props}
|
|
241
|
-
|
|
247
|
+
>
|
|
248
|
+
<ScrollArea
|
|
249
|
+
className="s-w-full"
|
|
250
|
+
viewportClassName={cn(
|
|
251
|
+
"s-max-h-[var(--radix-dropdown-menu-content-available-height)]"
|
|
252
|
+
)}
|
|
253
|
+
>
|
|
254
|
+
{children}
|
|
255
|
+
</ScrollArea>
|
|
256
|
+
</DropdownMenuPrimitive.Content>
|
|
242
257
|
);
|
|
243
258
|
|
|
244
259
|
const [container, setContainer] = React.useState<Element | undefined>(
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { cva } from "class-variance-authority";
|
|
2
1
|
import React, { useState } from "react";
|
|
3
2
|
|
|
4
3
|
import {
|
|
@@ -9,27 +8,11 @@ import {
|
|
|
9
8
|
DropdownMenuTrigger,
|
|
10
9
|
RegularButtonProps,
|
|
11
10
|
} from "@sparkle/components/";
|
|
12
|
-
import {
|
|
13
|
-
Button,
|
|
14
|
-
ButtonSizeType,
|
|
15
|
-
ButtonVariantType,
|
|
16
|
-
} from "@sparkle/components/Button";
|
|
11
|
+
import { Button, ButtonVariantType } from "@sparkle/components/Button";
|
|
17
12
|
import { Separator } from "@sparkle/components/Separator";
|
|
18
13
|
import { ChevronDownIcon } from "@sparkle/icons/app";
|
|
19
14
|
import { cn } from "@sparkle/lib";
|
|
20
15
|
|
|
21
|
-
const separatorSizeVariants: Record<Exclude<ButtonSizeType, "mini">, string> = {
|
|
22
|
-
xs: "s-h-3",
|
|
23
|
-
sm: "s-h-5",
|
|
24
|
-
md: "s-h-7",
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
const separatorVariants = cva("s--ml-[1px]", {
|
|
28
|
-
variants: {
|
|
29
|
-
size: separatorSizeVariants,
|
|
30
|
-
},
|
|
31
|
-
});
|
|
32
|
-
|
|
33
16
|
interface SplitButtonActionProps {
|
|
34
17
|
label: string;
|
|
35
18
|
icon?: React.ComponentType;
|
|
@@ -101,7 +84,7 @@ const SplitButton = React.forwardRef<HTMLButtonElement, SplitButtonProps>(
|
|
|
101
84
|
ref={ref}
|
|
102
85
|
className={cn("s-rounded-r-none s-border-r-0", className)}
|
|
103
86
|
/>
|
|
104
|
-
<div className=
|
|
87
|
+
<div className="sm">
|
|
105
88
|
<Separator orientation="vertical" />
|
|
106
89
|
</div>
|
|
107
90
|
<DropdownMenu>
|
package/src/components/Tree.tsx
CHANGED
|
@@ -67,7 +67,7 @@ export function Tree({
|
|
|
67
67
|
className={cn(
|
|
68
68
|
"s-flex s-flex-col s-gap-0.5 s-overflow-hidden",
|
|
69
69
|
isBoxed &&
|
|
70
|
-
"s-rounded-xl s-border s-border-border s-bg-muted-background s-
|
|
70
|
+
"s-rounded-xl s-border s-border-border s-bg-muted-background s-px-3 s-py-2 dark:s-border-border-night dark:s-bg-muted-background-night",
|
|
71
71
|
className
|
|
72
72
|
)}
|
|
73
73
|
>
|
|
@@ -235,7 +235,7 @@ Tree.Item = React.forwardRef<
|
|
|
235
235
|
{type === "node" && (
|
|
236
236
|
<Button
|
|
237
237
|
icon={isExpanded ? ArrowDownSIcon : ArrowRightSIcon}
|
|
238
|
-
size="
|
|
238
|
+
size="xmini"
|
|
239
239
|
variant="ghost-secondary"
|
|
240
240
|
disabled={!effectiveOnChevronClick}
|
|
241
241
|
onClick={(e) => {
|
|
@@ -313,7 +313,7 @@ Tree.Empty = function ({ label, onItemClick }: TreeEmptyProps) {
|
|
|
313
313
|
return (
|
|
314
314
|
<div
|
|
315
315
|
className={cn(
|
|
316
|
-
"s-
|
|
316
|
+
"s-copy-sm s-py-1.5 s-pl-6 s-italic",
|
|
317
317
|
"s-text-muted-foreground dark:s-text-muted-foreground-night",
|
|
318
318
|
onItemClick ? "s-cursor-pointer" : ""
|
|
319
319
|
)}
|