@dust-tt/sparkle 0.2.274 → 0.2.276
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 +8245 -8259
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/components/AssistantPreview.d.ts.map +1 -1
- package/dist/esm/components/AssistantPreview.js +1 -1
- package/dist/esm/components/AssistantPreview.js.map +1 -1
- package/dist/esm/components/Banner.js +1 -1
- package/dist/esm/components/Banner.js.map +1 -1
- package/dist/esm/components/BarHeader.js +5 -5
- package/dist/esm/components/BarHeader.js.map +1 -1
- package/dist/esm/components/Button.d.ts +20 -24
- package/dist/esm/components/Button.d.ts.map +1 -1
- package/dist/esm/components/Button.js +76 -117
- package/dist/esm/components/Button.js.map +1 -1
- package/dist/esm/components/Citation.js +1 -1
- package/dist/esm/components/Citation.js.map +1 -1
- package/dist/esm/components/ConversationMessageActions.d.ts.map +1 -1
- package/dist/esm/components/ConversationMessageActions.js +2 -2
- package/dist/esm/components/ConversationMessageActions.js.map +1 -1
- package/dist/esm/components/DataTable.js +2 -2
- package/dist/esm/components/DataTable.js.map +1 -1
- package/dist/esm/components/Dialog.d.ts +2 -2
- package/dist/esm/components/Dialog.d.ts.map +1 -1
- package/dist/esm/components/Dialog.js +2 -2
- package/dist/esm/components/Dialog.js.map +1 -1
- package/dist/esm/components/FilterChips.d.ts.map +1 -1
- package/dist/esm/components/FilterChips.js +1 -1
- package/dist/esm/components/FilterChips.js.map +1 -1
- package/dist/esm/components/IconButton.d.ts +4 -3
- package/dist/esm/components/IconButton.d.ts.map +1 -1
- package/dist/esm/components/IconButton.js +41 -65
- package/dist/esm/components/IconButton.js.map +1 -1
- package/dist/esm/components/Input.d.ts.map +1 -1
- package/dist/esm/components/Input.js +20 -7
- package/dist/esm/components/Input.js.map +1 -1
- package/dist/esm/components/Label.js +1 -1
- package/dist/esm/components/Label.js.map +1 -1
- package/dist/esm/components/Markdown.d.ts.map +1 -1
- package/dist/esm/components/Markdown.js +2 -2
- package/dist/esm/components/Markdown.js.map +1 -1
- package/dist/esm/components/NavigationList.d.ts +18 -0
- package/dist/esm/components/NavigationList.d.ts.map +1 -0
- package/dist/esm/components/NavigationList.js +70 -0
- package/dist/esm/components/NavigationList.js.map +1 -0
- package/dist/esm/components/NewDropdown.js +2 -2
- package/dist/esm/components/NewDropdown.js.map +1 -1
- package/dist/esm/components/Notification.js +1 -1
- package/dist/esm/components/Notification.js.map +1 -1
- package/dist/esm/components/Pagination.d.ts.map +1 -1
- package/dist/esm/components/Pagination.js +2 -2
- package/dist/esm/components/Pagination.js.map +1 -1
- package/dist/esm/components/Popover.js +1 -1
- package/dist/esm/components/Popup.js +1 -1
- package/dist/esm/components/Popup.js.map +1 -1
- package/dist/esm/components/RadioGroup.d.ts.map +1 -1
- package/dist/esm/components/RadioGroup.js +4 -4
- package/dist/esm/components/RadioGroup.js.map +1 -1
- package/dist/esm/components/Searchbar.js +1 -1
- package/dist/esm/components/Searchbar.js.map +1 -1
- package/dist/esm/components/Spinner.d.ts +6 -2
- package/dist/esm/components/Spinner.d.ts.map +1 -1
- package/dist/esm/components/Spinner.js +34 -47
- package/dist/esm/components/Spinner.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 +9 -9
- package/dist/esm/components/Tree.js.map +1 -1
- package/dist/esm/components/ZoomableImageCitationWrapper.js +1 -1
- package/dist/esm/components/index.d.ts +2 -1
- package/dist/esm/components/index.d.ts.map +1 -1
- package/dist/esm/components/index.js +2 -1
- package/dist/esm/components/index.js.map +1 -1
- package/dist/esm/stories/Banner.stories.js +1 -1
- package/dist/esm/stories/Banner.stories.js.map +1 -1
- package/dist/esm/stories/Button.stories.d.ts +3 -16
- package/dist/esm/stories/Button.stories.d.ts.map +1 -1
- package/dist/esm/stories/Button.stories.js +54 -166
- package/dist/esm/stories/Button.stories.js.map +1 -1
- package/dist/esm/stories/CardButton.stories.js +1 -1
- package/dist/esm/stories/CardButton.stories.js.map +1 -1
- package/dist/esm/stories/ContextItem.stories.d.ts.map +1 -1
- package/dist/esm/stories/ContextItem.stories.js +5 -5
- package/dist/esm/stories/ContextItem.stories.js.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 +7 -7
- package/dist/esm/stories/DropdownMenu.stories.js.map +1 -1
- package/dist/esm/stories/IconButton.stories.js +4 -4
- package/dist/esm/stories/IconButton.stories.js.map +1 -1
- package/dist/esm/stories/Input.stories.js +1 -1
- package/dist/esm/stories/Input.stories.js.map +1 -1
- package/dist/esm/stories/Markdown.stories.d.ts +1 -2
- package/dist/esm/stories/Markdown.stories.d.ts.map +1 -1
- package/dist/esm/stories/Modal.stories.d.ts.map +1 -1
- package/dist/esm/stories/Modal.stories.js +1 -2
- package/dist/esm/stories/Modal.stories.js.map +1 -1
- package/dist/esm/stories/NavigationList.stories.d.ts +7 -0
- package/dist/esm/stories/NavigationList.stories.d.ts.map +1 -0
- package/dist/esm/stories/NavigationList.stories.js +140 -0
- package/dist/esm/stories/NavigationList.stories.js.map +1 -0
- package/dist/esm/stories/NewDropdown.stories.js +2 -2
- package/dist/esm/stories/NewDropdown.stories.js.map +1 -1
- package/dist/esm/stories/Page.stories.d.ts.map +1 -1
- package/dist/esm/stories/Page.stories.js +6 -6
- package/dist/esm/stories/Page.stories.js.map +1 -1
- package/dist/esm/stories/Popover.stories.js +1 -1
- package/dist/esm/stories/Popover.stories.js.map +1 -1
- package/dist/esm/stories/Searchbar.stories.js +3 -3
- package/dist/esm/stories/Searchbar.stories.js.map +1 -1
- package/dist/esm/stories/SliderToggle.stories.js +2 -2
- package/dist/esm/stories/SliderToggle.stories.js.map +1 -1
- package/dist/esm/stories/Tree.stories.d.ts.map +1 -1
- package/dist/esm/stories/Tree.stories.js +6 -6
- package/dist/esm/stories/Tree.stories.js.map +1 -1
- package/dist/sparkle.css +186 -281
- package/package.json +1 -1
- package/src/components/AssistantPreview.tsx +1 -5
- package/src/components/Banner.tsx +1 -1
- package/src/components/BarHeader.tsx +8 -11
- package/src/components/Button.tsx +169 -237
- package/src/components/Citation.tsx +1 -1
- package/src/components/ConversationMessageActions.tsx +3 -7
- package/src/components/DataTable.tsx +2 -2
- package/src/components/Dialog.tsx +5 -5
- package/src/components/FilterChips.tsx +1 -2
- package/src/components/IconButton.tsx +56 -87
- package/src/components/Input.tsx +44 -31
- package/src/components/Label.tsx +1 -1
- package/src/components/Markdown.tsx +2 -3
- package/src/components/NavigationList.tsx +137 -0
- package/src/components/NewDropdown.tsx +2 -2
- package/src/components/Notification.tsx +1 -1
- package/src/components/Pagination.tsx +2 -8
- package/src/components/Popover.tsx +1 -1
- package/src/components/Popup.tsx +1 -1
- package/src/components/RadioGroup.tsx +20 -22
- package/src/components/Searchbar.tsx +1 -1
- package/src/components/Spinner.tsx +45 -68
- package/src/components/Tree.tsx +11 -9
- package/src/components/ZoomableImageCitationWrapper.tsx +1 -1
- package/src/components/index.ts +6 -1
- package/src/stories/Banner.stories.tsx +1 -1
- package/src/stories/Button.stories.tsx +62 -607
- package/src/stories/CardButton.stories.tsx +1 -1
- package/src/stories/ContextItem.stories.tsx +6 -11
- package/src/stories/Dialog.stories.tsx +1 -1
- package/src/stories/DropdownMenu.stories.tsx +8 -27
- package/src/stories/IconButton.stories.tsx +4 -4
- package/src/stories/Input.stories.tsx +14 -14
- package/src/stories/Modal.stories.tsx +1 -2
- package/src/stories/NavigationList.stories.tsx +173 -0
- package/src/stories/NewDropdown.stories.tsx +2 -16
- package/src/stories/Page.stories.tsx +6 -9
- package/src/stories/Popover.stories.tsx +1 -1
- package/src/stories/Searchbar.stories.tsx +3 -3
- package/src/stories/SliderToggle.stories.tsx +2 -2
- package/src/stories/Tree.stories.tsx +6 -10
|
@@ -1,17 +1,18 @@
|
|
|
1
|
+
import { cva } from "class-variance-authority";
|
|
1
2
|
import React, { ComponentType, MouseEventHandler } from "react";
|
|
2
3
|
|
|
3
|
-
import {
|
|
4
|
+
import { Button, ButtonVariantType } from "@sparkle/components/Button";
|
|
4
5
|
|
|
5
|
-
import { Icon
|
|
6
|
+
import { Icon } from "./Icon";
|
|
6
7
|
import { Tooltip } from "./Tooltip";
|
|
7
8
|
|
|
8
9
|
type IconButtonProps = {
|
|
9
|
-
variant?:
|
|
10
|
+
variant?: React.ComponentProps<typeof Button>["variant"];
|
|
10
11
|
onClick?: MouseEventHandler<HTMLButtonElement>;
|
|
11
|
-
size?:
|
|
12
|
+
size?: React.ComponentProps<typeof Button>["size"];
|
|
12
13
|
tooltip?: string;
|
|
13
14
|
tooltipPosition?: React.ComponentProps<typeof Tooltip>["side"];
|
|
14
|
-
icon
|
|
15
|
+
icon: ComponentType;
|
|
15
16
|
className?: string;
|
|
16
17
|
disabled?: boolean;
|
|
17
18
|
};
|
|
@@ -19,100 +20,68 @@ type IconButtonProps = {
|
|
|
19
20
|
const baseClasses =
|
|
20
21
|
"s-transition-all s-ease-out s-duration-300 s-cursor-pointer hover:s-scale-110";
|
|
21
22
|
|
|
22
|
-
const
|
|
23
|
-
primary:
|
|
24
|
-
|
|
25
|
-
hover:
|
|
26
|
-
active:
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
dark:
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
dark:
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
base: "s-text-element-700",
|
|
61
|
-
hover: "hover:s-text-action-400",
|
|
62
|
-
active: "active:s-text-action-600",
|
|
63
|
-
disabled: "s-text-element-500",
|
|
64
|
-
dark: {
|
|
65
|
-
base: "dark:s-text-element-700-dark",
|
|
66
|
-
hover: "dark:hover:s-text-action-500-dark",
|
|
67
|
-
active: "dark:active:s-text-action-600-dark",
|
|
68
|
-
disabled: "dark:s-text-element-500-dark",
|
|
23
|
+
const styleVariants: Record<ButtonVariantType, string> = {
|
|
24
|
+
primary:
|
|
25
|
+
"s-text-action-500 dark:s-text-action-500-dark" +
|
|
26
|
+
"hover:s-text-action-400 dark:hover:s-text-action-500-dark" +
|
|
27
|
+
"active:s-text-action-600 dark:active:s-text-action-600-dark" +
|
|
28
|
+
"s-text-element-500 dark:s-text-element-500-dark",
|
|
29
|
+
warning:
|
|
30
|
+
"s-text-warning-500 dark:s-text-warning-500-dark" +
|
|
31
|
+
"hover:s-text-warning-400 dark:hover:s-text-warning-500-dark" +
|
|
32
|
+
"active:s-text-warning-600 dark:active:s-text-warning-600-dark" +
|
|
33
|
+
"s-text-element-500 dark:s-text-element-500-dark",
|
|
34
|
+
highlight:
|
|
35
|
+
"s-text-element-900 dark:s-text-element-900-dark" +
|
|
36
|
+
"hover:s-text-action-400 dark:hover:s-text-action-500-dark" +
|
|
37
|
+
"active:s-text-action-600 dark:active:s-text-action-600-dark" +
|
|
38
|
+
"s-text-element-500 dark:s-text-element-500-dark",
|
|
39
|
+
outline:
|
|
40
|
+
"s-text-element-700 dark:s-text-element-700-dark" +
|
|
41
|
+
"hover:s-text-action-400 dark:hover:s-text-action-500-dark" +
|
|
42
|
+
"active:s-text-action-600 dark:active:s-text-action-600-dark" +
|
|
43
|
+
"s-text-element-500 dark:s-text-element-500-dark",
|
|
44
|
+
ghost:
|
|
45
|
+
"s-text-white s-text-white" +
|
|
46
|
+
"hover:s-text-slate-100 hover:s-text-slate-100" +
|
|
47
|
+
"active:s-text-slate-200 active:s-text-slate-200" +
|
|
48
|
+
"s-text-white/50 s-text-white/50",
|
|
49
|
+
white:
|
|
50
|
+
"s-text-element-700 dark:s-text-element-700-dark" +
|
|
51
|
+
"hover:s-text-action-400 dark:hover:s-text-action-500-dark" +
|
|
52
|
+
"active:s-text-action-600 dark:active:s-text-action-600-dark" +
|
|
53
|
+
"s-text-element-500 dark:s-text-element-500-dark",
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const iconButtonVariants = cva(baseClasses, {
|
|
57
|
+
variants: {
|
|
58
|
+
variant: styleVariants,
|
|
59
|
+
disabled: {
|
|
60
|
+
true: "s-text-element-500 s-cursor-default hover:s-scale-100",
|
|
69
61
|
},
|
|
70
62
|
},
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
active: "active:s-text-slate-200",
|
|
75
|
-
disabled: "s-text-white/50",
|
|
76
|
-
dark: {
|
|
77
|
-
base: "s-text-white",
|
|
78
|
-
hover: "hover:s-text-slate-100",
|
|
79
|
-
active: "active:s-text-slate-200",
|
|
80
|
-
disabled: "s-text-white/50",
|
|
81
|
-
},
|
|
63
|
+
defaultVariants: {
|
|
64
|
+
variant: "outline",
|
|
65
|
+
disabled: false,
|
|
82
66
|
},
|
|
83
|
-
};
|
|
67
|
+
});
|
|
84
68
|
|
|
85
69
|
export function IconButton({
|
|
86
|
-
variant
|
|
70
|
+
variant,
|
|
87
71
|
onClick,
|
|
88
72
|
disabled = false,
|
|
89
73
|
tooltip,
|
|
90
|
-
tooltipPosition
|
|
74
|
+
tooltipPosition,
|
|
91
75
|
icon,
|
|
92
|
-
className
|
|
93
|
-
size
|
|
76
|
+
className,
|
|
77
|
+
size,
|
|
94
78
|
}: IconButtonProps) {
|
|
95
|
-
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
const finalIconClasses = classNames(
|
|
99
|
-
className,
|
|
100
|
-
baseClasses,
|
|
101
|
-
iconGroup.base,
|
|
102
|
-
disabled ? iconGroup.disabled : iconGroup.hover,
|
|
103
|
-
disabled ? "" : iconGroup.active,
|
|
104
|
-
iconGroup.dark.base,
|
|
105
|
-
disabled ? iconGroup.dark.disabled : iconGroup.dark.hover,
|
|
106
|
-
disabled ? "" : iconGroup.dark.active
|
|
107
|
-
);
|
|
79
|
+
const iconSize = size || "sm";
|
|
80
|
+
const buttonClasses = iconButtonVariants({ variant, disabled, className });
|
|
108
81
|
|
|
109
82
|
const IconButtonContent = (
|
|
110
|
-
<button
|
|
111
|
-
|
|
112
|
-
onClick={disabled ? undefined : onClick}
|
|
113
|
-
disabled={disabled}
|
|
114
|
-
>
|
|
115
|
-
{icon && <Icon visual={icon} size={size as IconProps["size"]} />}
|
|
83
|
+
<button className={buttonClasses} onClick={onClick} disabled={disabled}>
|
|
84
|
+
<Icon visual={icon} size={iconSize} />
|
|
116
85
|
</button>
|
|
117
86
|
);
|
|
118
87
|
|
package/src/components/Input.tsx
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { cva } from "class-variance-authority";
|
|
1
2
|
import React, { forwardRef } from "react";
|
|
2
3
|
|
|
3
4
|
import { cn } from "@sparkle/lib/utils";
|
|
@@ -13,51 +14,63 @@ export interface InputProps
|
|
|
13
14
|
label?: string;
|
|
14
15
|
}
|
|
15
16
|
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
const INPUT_STATES = ["error", "disabled", "default"];
|
|
18
|
+
|
|
19
|
+
type InputStateType = (typeof INPUT_STATES)[number];
|
|
20
|
+
|
|
21
|
+
const stateVariantStyles: Record<InputStateType, string> = {
|
|
22
|
+
default: "focus-visible:s-ring-ring",
|
|
23
|
+
disabled:
|
|
24
|
+
"disabled:s-cursor-not-allowed disabled:s-opacity-50 disabled:s-text-muted-foreground",
|
|
25
|
+
error: "s-border-border-warning focus:s-ring-ring-warning",
|
|
26
|
+
};
|
|
27
|
+
const inputStyleClasses = cva(
|
|
28
|
+
cn(
|
|
29
|
+
"s-text-sm s-bg-background s-rounded-xl s-border s-border-border-dark s-flex s-h-9 s-w-full s-px-3 s-py-1.5 ",
|
|
30
|
+
"file:s-border-0 file:s-bg-transparent file:s-text-sm file:s-font-medium file:s-text-foreground",
|
|
31
|
+
"placeholder:s-text-muted-foreground",
|
|
32
|
+
"focus-visible:s-outline-none focus-visible:s-ring-2 focus-visible:s-ring-offset-2 focus-visible:s-border-border-dark"
|
|
33
|
+
),
|
|
34
|
+
{
|
|
35
|
+
variants: {
|
|
36
|
+
state: stateVariantStyles,
|
|
37
|
+
},
|
|
38
|
+
defaultVariants: {
|
|
39
|
+
state: "default",
|
|
40
|
+
},
|
|
41
|
+
}
|
|
22
42
|
);
|
|
23
43
|
|
|
24
44
|
export const Input = forwardRef<HTMLInputElement, InputProps>(
|
|
25
45
|
(
|
|
26
|
-
{
|
|
46
|
+
{
|
|
47
|
+
className,
|
|
48
|
+
error,
|
|
49
|
+
value,
|
|
50
|
+
label,
|
|
51
|
+
disabled,
|
|
52
|
+
showErrorLabel = false,
|
|
53
|
+
...props
|
|
54
|
+
},
|
|
27
55
|
ref
|
|
28
56
|
) => {
|
|
57
|
+
const state = error ? "error" : disabled ? "disabled" : "default";
|
|
29
58
|
return (
|
|
30
59
|
<div className="s-flex s-flex-col s-gap-1 s-px-1">
|
|
31
|
-
{label &&
|
|
32
|
-
<Label
|
|
33
|
-
htmlFor={props.name}
|
|
34
|
-
className="s-pb-1 s-text-element-700 dark:s-text-element-700-dark"
|
|
35
|
-
>
|
|
36
|
-
{label}
|
|
37
|
-
</Label>
|
|
38
|
-
)}
|
|
60
|
+
{label && <Label htmlFor={props.name}>{label}</Label>}
|
|
39
61
|
<input
|
|
40
62
|
ref={ref}
|
|
41
|
-
className={cn(
|
|
42
|
-
inputStyleClasses,
|
|
43
|
-
className,
|
|
44
|
-
!error
|
|
45
|
-
? cn(
|
|
46
|
-
"s-ring-structure-200 focus:s-ring-action-300",
|
|
47
|
-
"dark:s-ring-structure-300-dark dark:focus:s-ring-action-300-dark"
|
|
48
|
-
)
|
|
49
|
-
: cn(
|
|
50
|
-
"s-ring-warning-200 focus:s-ring-warning-300",
|
|
51
|
-
"dark:s-ring-warning-200-dark dark:focus:s-ring-warning-300-dark"
|
|
52
|
-
)
|
|
53
|
-
)}
|
|
63
|
+
className={cn(inputStyleClasses({ state }), className)}
|
|
54
64
|
data-1p-ignore={props.type !== "password"}
|
|
55
65
|
value={value ?? undefined}
|
|
66
|
+
disabled={disabled}
|
|
56
67
|
{...props}
|
|
57
68
|
/>
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
69
|
+
{showErrorLabel && error && (
|
|
70
|
+
<div className="s-ml-3.5 s-text-xs s-text-foreground-warning">
|
|
71
|
+
{error}
|
|
72
|
+
</div>
|
|
73
|
+
)}
|
|
61
74
|
</div>
|
|
62
75
|
);
|
|
63
76
|
}
|
package/src/components/Label.tsx
CHANGED
|
@@ -4,7 +4,7 @@ import * as React from "react";
|
|
|
4
4
|
import { cn } from "@sparkle/lib/utils";
|
|
5
5
|
|
|
6
6
|
const labelVariants = cn(
|
|
7
|
-
"s-text-sm s-text-foreground s-leading-none",
|
|
7
|
+
"s-text-sm s-font-medium s-text-foreground s-leading-none",
|
|
8
8
|
"peer-disabled:s-cursor-not-allowed peer-disabled:s-opacity-70"
|
|
9
9
|
);
|
|
10
10
|
|
|
@@ -146,13 +146,12 @@ export function Markdown({
|
|
|
146
146
|
{childrenContent && (
|
|
147
147
|
<Button
|
|
148
148
|
size="xs"
|
|
149
|
-
variant="
|
|
149
|
+
variant="ghost"
|
|
150
150
|
onClick={async (e) => {
|
|
151
151
|
e.preventDefault();
|
|
152
152
|
await handleCopy();
|
|
153
153
|
}}
|
|
154
|
-
|
|
155
|
-
labelVisible={false}
|
|
154
|
+
tooltip="Copy"
|
|
156
155
|
icon={isCopied ? ClipboardCheckIcon : ClipboardIcon}
|
|
157
156
|
/>
|
|
158
157
|
)}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
|
|
4
|
+
import { Button, Icon } from "@sparkle/components/";
|
|
5
|
+
import { MoreIcon } from "@sparkle/icons";
|
|
6
|
+
import { cn } from "@sparkle/lib/utils";
|
|
7
|
+
|
|
8
|
+
const listStyles = cva("s-flex", {
|
|
9
|
+
variants: {
|
|
10
|
+
layout: {
|
|
11
|
+
container: "s-gap-1 s-flex-col s-overflow-hidden",
|
|
12
|
+
item: cn(
|
|
13
|
+
"s-box-border s-items-center s-w-full s-flex s-gap-1.5 s-cursor-pointer s-select-none s-items-center s-outline-none s-rounded-xl s-text-sm s-px-3 s-py-2 s-transition-colors s-duration-300",
|
|
14
|
+
"data-[disabled]:s-pointer-events-none data-[disabled]:s-text-muted-foreground",
|
|
15
|
+
"hover:s-text-foreground hover:s-bg-structure-150"
|
|
16
|
+
),
|
|
17
|
+
},
|
|
18
|
+
state: {
|
|
19
|
+
active: "active:s-bg-structure-200",
|
|
20
|
+
selected: "s-text-foreground s-font-medium s-bg-structure-150",
|
|
21
|
+
unselected: "s-text-muted-foreground",
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
defaultVariants: {
|
|
25
|
+
layout: "container",
|
|
26
|
+
state: "unselected",
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const labelStyles = cva(
|
|
31
|
+
"s-font-semibold s-pt-6 s-pb-2 s-text-xs s-whitespace-nowrap s-overflow-hidden s-text-ellipsis"
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
const NavigationList = React.forwardRef<
|
|
35
|
+
HTMLDivElement,
|
|
36
|
+
React.HTMLAttributes<HTMLDivElement>
|
|
37
|
+
>(({ className, ...props }, ref) => (
|
|
38
|
+
<div
|
|
39
|
+
ref={ref}
|
|
40
|
+
className={cn(listStyles({ layout: "container" }), className)}
|
|
41
|
+
{...props}
|
|
42
|
+
/>
|
|
43
|
+
));
|
|
44
|
+
NavigationList.displayName = "NavigationList";
|
|
45
|
+
|
|
46
|
+
interface NavigationListItemProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
47
|
+
selected?: boolean;
|
|
48
|
+
label?: string;
|
|
49
|
+
icon?: React.ComponentType;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const NavigationListItem = React.forwardRef<
|
|
53
|
+
HTMLDivElement,
|
|
54
|
+
NavigationListItemProps
|
|
55
|
+
>(({ className, selected, label, icon, ...props }, ref) => {
|
|
56
|
+
const [isHovered, setIsHovered] = React.useState(false);
|
|
57
|
+
const [isPressed, setIsPressed] = React.useState(false);
|
|
58
|
+
|
|
59
|
+
const handleMouseDown = (event: React.MouseEvent) => {
|
|
60
|
+
if (!(event.target as HTMLElement).closest(".new-button-class")) {
|
|
61
|
+
setIsPressed(true);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<div className={className} ref={ref} {...props}>
|
|
67
|
+
<div
|
|
68
|
+
className={listStyles({
|
|
69
|
+
layout: "item",
|
|
70
|
+
state: selected ? "selected" : isPressed ? "active" : "unselected",
|
|
71
|
+
})}
|
|
72
|
+
onMouseEnter={() => setIsHovered(true)}
|
|
73
|
+
onMouseLeave={() => {
|
|
74
|
+
setIsHovered(false);
|
|
75
|
+
setIsPressed(false);
|
|
76
|
+
}}
|
|
77
|
+
onMouseDown={handleMouseDown}
|
|
78
|
+
onMouseUp={() => setIsPressed(false)}
|
|
79
|
+
>
|
|
80
|
+
{icon && <Icon visual={icon} size="sm" />}
|
|
81
|
+
{label && (
|
|
82
|
+
<span className="s-grow s-overflow-hidden s-text-ellipsis s-whitespace-nowrap">
|
|
83
|
+
{label}
|
|
84
|
+
</span>
|
|
85
|
+
)}
|
|
86
|
+
{isHovered && (
|
|
87
|
+
<div className="-s-mr-2 s-flex s-h-4 s-items-center">
|
|
88
|
+
<Button
|
|
89
|
+
variant="ghost"
|
|
90
|
+
icon={MoreIcon}
|
|
91
|
+
size="xs"
|
|
92
|
+
onClick={(e) => e.stopPropagation()}
|
|
93
|
+
onMouseDown={(e) => e.stopPropagation()}
|
|
94
|
+
onMouseUp={(e) => e.stopPropagation()}
|
|
95
|
+
/>
|
|
96
|
+
</div>
|
|
97
|
+
)}
|
|
98
|
+
</div>
|
|
99
|
+
</div>
|
|
100
|
+
);
|
|
101
|
+
});
|
|
102
|
+
NavigationListItem.displayName = "NavigationListItem";
|
|
103
|
+
|
|
104
|
+
const variantStyles = cva("", {
|
|
105
|
+
variants: {
|
|
106
|
+
variant: {
|
|
107
|
+
primary: "s-text-foreground",
|
|
108
|
+
secondary: "s-text-muted-foreground",
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
defaultVariants: {
|
|
112
|
+
variant: "primary",
|
|
113
|
+
},
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
interface NavigationListLabelProps
|
|
117
|
+
extends React.HTMLAttributes<HTMLDivElement>,
|
|
118
|
+
VariantProps<typeof variantStyles> {
|
|
119
|
+
label: string;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const NavigationListLabel = React.forwardRef<
|
|
123
|
+
HTMLDivElement,
|
|
124
|
+
NavigationListLabelProps
|
|
125
|
+
>(({ className, variant, label, ...props }, ref) => (
|
|
126
|
+
<div
|
|
127
|
+
ref={ref}
|
|
128
|
+
className={cn(labelStyles(), variantStyles({ variant }), className)}
|
|
129
|
+
{...props}
|
|
130
|
+
>
|
|
131
|
+
{label}
|
|
132
|
+
</div>
|
|
133
|
+
));
|
|
134
|
+
|
|
135
|
+
NavigationListLabel.displayName = "NavigationListLabel";
|
|
136
|
+
|
|
137
|
+
export { NavigationList, NavigationListItem, NavigationListLabel };
|
|
@@ -13,7 +13,7 @@ type ItemVariantType = (typeof ITEM_VARIANTS)[number];
|
|
|
13
13
|
export const menuStyleClasses = {
|
|
14
14
|
inset: "s-pl-8",
|
|
15
15
|
container: cn(
|
|
16
|
-
"s-rounded-
|
|
16
|
+
"s-rounded-xl s-border s-border-hovering s-bg-white s-p-1 s-text-primary-950",
|
|
17
17
|
"s-z-50 s-min-w-[8rem] s-overflow-hidden",
|
|
18
18
|
"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"
|
|
19
19
|
),
|
|
@@ -83,7 +83,7 @@ const ItemWithLabelIconAndDescription = <
|
|
|
83
83
|
return (
|
|
84
84
|
<>
|
|
85
85
|
{label && (
|
|
86
|
-
<div className="s-grid s-grid-cols-[auto,1fr] s-gap-x-1">
|
|
86
|
+
<div className="s-grid s-grid-cols-[auto,1fr] s-gap-x-1.5">
|
|
87
87
|
{icon && (
|
|
88
88
|
<div
|
|
89
89
|
className={cn(
|
|
@@ -75,11 +75,8 @@ export function Pagination({
|
|
|
75
75
|
)}
|
|
76
76
|
>
|
|
77
77
|
<Button
|
|
78
|
-
variant="
|
|
78
|
+
variant="ghost"
|
|
79
79
|
size={size === "xs" ? "xs" : "sm"}
|
|
80
|
-
label="previous"
|
|
81
|
-
labelVisible={false}
|
|
82
|
-
disabledTooltip={true}
|
|
83
80
|
disabled={!canPreviousPage}
|
|
84
81
|
icon={ChevronLeftIcon}
|
|
85
82
|
onClick={previousPage}
|
|
@@ -96,11 +93,8 @@ export function Pagination({
|
|
|
96
93
|
</div>
|
|
97
94
|
|
|
98
95
|
<Button
|
|
99
|
-
variant="
|
|
96
|
+
variant="ghost"
|
|
100
97
|
size={size === "xs" ? "xs" : "sm"}
|
|
101
|
-
label="next"
|
|
102
|
-
labelVisible={false}
|
|
103
|
-
disabledTooltip={true}
|
|
104
98
|
disabled={!canNextPage}
|
|
105
99
|
icon={ChevronRightIcon}
|
|
106
100
|
onClick={nextPage}
|
|
@@ -38,7 +38,7 @@ const PopoverContent = React.forwardRef<
|
|
|
38
38
|
"data-[side=left]:s-slide-in-from-right-2",
|
|
39
39
|
"data-[side=right]:s-slide-in-from-left-2",
|
|
40
40
|
"data-[side=top]:s-slide-in-from-bottom-2",
|
|
41
|
-
"s-z-50 s-rounded-
|
|
41
|
+
"s-z-50 s-rounded-xl s-border s-bg-background s-text-primary-950 s-shadow-md s-outline-none",
|
|
42
42
|
fullWidth ? "s-grow" : "s-w-72 s-p-4",
|
|
43
43
|
className
|
|
44
44
|
)}
|
package/src/components/Popup.tsx
CHANGED
|
@@ -46,7 +46,7 @@ const RadioGroup = React.forwardRef<
|
|
|
46
46
|
>(({ className, ...props }, ref) => {
|
|
47
47
|
return (
|
|
48
48
|
<RadioGroupPrimitive.Root
|
|
49
|
-
className={cn("s-grid", className)}
|
|
49
|
+
className={cn("s-grid s-gap-2", className)}
|
|
50
50
|
{...props}
|
|
51
51
|
ref={ref}
|
|
52
52
|
/>
|
|
@@ -69,34 +69,32 @@ const RadioGroupItem = React.forwardRef<
|
|
|
69
69
|
{ tooltipMessage, className, size, tooltipAsChild = false, ...props },
|
|
70
70
|
ref
|
|
71
71
|
) => {
|
|
72
|
+
const item = (
|
|
73
|
+
<RadioGroupPrimitive.Item
|
|
74
|
+
ref={ref}
|
|
75
|
+
className={cn(radioStyles({ size }), className)}
|
|
76
|
+
{...props}
|
|
77
|
+
>
|
|
78
|
+
<RadioGroupPrimitive.Indicator
|
|
79
|
+
className={radioIndicatorStyles({ size })}
|
|
80
|
+
/>
|
|
81
|
+
</RadioGroupPrimitive.Item>
|
|
82
|
+
);
|
|
72
83
|
return (
|
|
73
|
-
<div
|
|
84
|
+
<div
|
|
85
|
+
className={cn(
|
|
86
|
+
"s-group",
|
|
87
|
+
size === "sm" ? "s-h-5 s-w-5" : "-s-mt-1.5 s-h-4 s-w-4"
|
|
88
|
+
)}
|
|
89
|
+
>
|
|
74
90
|
{tooltipMessage ? (
|
|
75
91
|
<Tooltip
|
|
76
92
|
triggerAsChild={tooltipAsChild}
|
|
77
|
-
trigger={
|
|
78
|
-
<RadioGroupPrimitive.Item
|
|
79
|
-
ref={ref}
|
|
80
|
-
className={cn(radioStyles({ size }), className)}
|
|
81
|
-
{...props}
|
|
82
|
-
>
|
|
83
|
-
<RadioGroupPrimitive.Indicator
|
|
84
|
-
className={radioIndicatorStyles({ size })}
|
|
85
|
-
/>
|
|
86
|
-
</RadioGroupPrimitive.Item>
|
|
87
|
-
}
|
|
93
|
+
trigger={item}
|
|
88
94
|
label={<span>{tooltipMessage}</span>}
|
|
89
95
|
/>
|
|
90
96
|
) : (
|
|
91
|
-
|
|
92
|
-
ref={ref}
|
|
93
|
-
className={cn(radioStyles({ size }), className)}
|
|
94
|
-
{...props}
|
|
95
|
-
>
|
|
96
|
-
<RadioGroupPrimitive.Indicator
|
|
97
|
-
className={radioIndicatorStyles({ size })}
|
|
98
|
-
/>
|
|
99
|
-
</RadioGroupPrimitive.Item>
|
|
97
|
+
item
|
|
100
98
|
)}
|
|
101
99
|
</div>
|
|
102
100
|
);
|