@dust-tt/sparkle 0.2.201 → 0.2.203
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/components/DataTable.d.ts +10 -2
- package/dist/cjs/index.js +26 -15
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/components/DataTable.d.ts +10 -2
- package/dist/esm/index.js +26 -15
- package/dist/esm/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/components/CardButton.tsx +11 -4
- package/src/components/Citation.tsx +31 -21
- package/src/components/DataTable.tsx +27 -4
- package/src/stories/DataTable.stories.tsx +1 -2
package/package.json
CHANGED
|
@@ -24,12 +24,18 @@ interface CardButtonProps {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
const variantClasses = {
|
|
27
|
+
primary: "s-bg-structure-50 s-border s-border-structure-200",
|
|
28
|
+
secondary: "s-bg-structure-0 s-border s-border-structure-100",
|
|
29
|
+
tertiary: "s-border-structure-100/0 s-border s-border-structure-0",
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const hoverVariantClasses = {
|
|
27
33
|
primary:
|
|
28
|
-
"
|
|
34
|
+
"hover:s-bg-white hover:s-border-structure-100 active:s-bg-structure-100 active:s-border-structure-200 s-cursor-pointer",
|
|
29
35
|
secondary:
|
|
30
|
-
"
|
|
36
|
+
"hover:s-bg-structure-50 hover:s-border-structure-200 active:s-bg-structure-100 active:s-border-structure-300 s-cursor-pointer",
|
|
31
37
|
tertiary:
|
|
32
|
-
"
|
|
38
|
+
"hover:s-bg-structure-50 hover:s-border-structure-100 active:s-bg-structure-100 active:s-border-structure-200 s-cursor-pointer",
|
|
33
39
|
};
|
|
34
40
|
|
|
35
41
|
const sizeClasses = {
|
|
@@ -57,7 +63,8 @@ export function CardButton({
|
|
|
57
63
|
const Link: SparkleContextLinkType = href ? components.link : noHrefLink;
|
|
58
64
|
|
|
59
65
|
const commonClasses = classNames(
|
|
60
|
-
"s-flex s-group s-
|
|
66
|
+
"s-flex s-group s-transition s-duration-200 s-overflow-hidden",
|
|
67
|
+
onClick ? hoverVariantClasses[variant] : "",
|
|
61
68
|
variantClasses[variant],
|
|
62
69
|
sizeClasses[size],
|
|
63
70
|
className
|
|
@@ -86,7 +86,12 @@ export function Citation({
|
|
|
86
86
|
<>
|
|
87
87
|
{type === "image" && imgSrc && (
|
|
88
88
|
<div
|
|
89
|
-
className=
|
|
89
|
+
className={classNames(
|
|
90
|
+
"s-absolute s-left-0 s-top-0 s-brightness-90 s-filter s-transition s-duration-200 s-ease-out active:s-brightness-100 group-active:s-brightness-100",
|
|
91
|
+
href
|
|
92
|
+
? "hover:s-brightness-110 group-hover:s-brightness-110 group-hover:s-filter"
|
|
93
|
+
: ""
|
|
94
|
+
)}
|
|
90
95
|
style={{
|
|
91
96
|
backgroundImage: `url(${imgSrc})`,
|
|
92
97
|
backgroundSize: "cover",
|
|
@@ -146,27 +151,32 @@ export function Citation({
|
|
|
146
151
|
</>
|
|
147
152
|
);
|
|
148
153
|
|
|
149
|
-
|
|
154
|
+
const cardButton = (
|
|
155
|
+
<CardButton
|
|
156
|
+
variant="secondary"
|
|
157
|
+
size="sm"
|
|
158
|
+
className={classNames(
|
|
159
|
+
"s-relative s-flex s-w-48 s-flex-none s-flex-col s-gap-1",
|
|
160
|
+
sizing === "fluid" ? typeSizing[sizing] : typeSizing[sizing][size],
|
|
161
|
+
size === "sm" ? "sm:s-w-64" : "",
|
|
162
|
+
isBlinking ? "s-animate-[bgblink_500ms_3]" : "",
|
|
163
|
+
type === "image" ? "s-min-h-20" : ""
|
|
164
|
+
)}
|
|
165
|
+
{...(href && { href, target: "_blank", rel: "noopener noreferrer" })}
|
|
166
|
+
>
|
|
167
|
+
{isLoading && (
|
|
168
|
+
<div className="s-absolute s-inset-0 s-flex s-items-center s-justify-center">
|
|
169
|
+
<Spinner size="xs" variant="color" />
|
|
170
|
+
</div>
|
|
171
|
+
)}
|
|
172
|
+
<div className={isLoading ? "s-opacity-50" : ""}>{cardContent}</div>
|
|
173
|
+
</CardButton>
|
|
174
|
+
);
|
|
175
|
+
return href ? (
|
|
150
176
|
<Tooltip label={title} position="above">
|
|
151
|
-
|
|
152
|
-
variant="secondary"
|
|
153
|
-
size="sm"
|
|
154
|
-
className={classNames(
|
|
155
|
-
"s-relative s-flex s-w-48 s-flex-none s-flex-col s-gap-1",
|
|
156
|
-
sizing === "fluid" ? typeSizing[sizing] : typeSizing[sizing][size],
|
|
157
|
-
size === "sm" ? "sm:s-w-64" : "",
|
|
158
|
-
isBlinking ? "s-animate-[bgblink_500ms_3]" : "",
|
|
159
|
-
type === "image" ? "s-min-h-20" : ""
|
|
160
|
-
)}
|
|
161
|
-
{...(href && { href, target: "_blank", rel: "noopener noreferrer" })}
|
|
162
|
-
>
|
|
163
|
-
{isLoading && (
|
|
164
|
-
<div className="s-absolute s-inset-0 s-flex s-items-center s-justify-center">
|
|
165
|
-
<Spinner size="xs" variant="color" />
|
|
166
|
-
</div>
|
|
167
|
-
)}
|
|
168
|
-
<div className={isLoading ? "s-opacity-50" : ""}>{cardContent}</div>
|
|
169
|
-
</CardButton>
|
|
177
|
+
{cardButton}
|
|
170
178
|
</Tooltip>
|
|
179
|
+
) : (
|
|
180
|
+
cardButton
|
|
171
181
|
);
|
|
172
182
|
}
|
|
@@ -16,22 +16,33 @@ import { classNames } from "@sparkle/lib/utils";
|
|
|
16
16
|
|
|
17
17
|
import { Icon } from "./Icon";
|
|
18
18
|
|
|
19
|
-
interface
|
|
19
|
+
interface TBaseData {
|
|
20
|
+
onClick?: () => void;
|
|
21
|
+
onMoreClick?: () => void;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface ColumnBreakpoint {
|
|
25
|
+
[columnId: string]: "xs" | "sm" | "md" | "lg" | "xl";
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
interface DataTableProps<TData extends TBaseData, TValue> {
|
|
20
29
|
data: TData[];
|
|
21
30
|
columns: ColumnDef<TData, TValue>[];
|
|
22
31
|
className?: string;
|
|
23
32
|
filter?: string;
|
|
24
33
|
filterColumn?: string;
|
|
25
34
|
initialColumnOrder?: SortingState;
|
|
35
|
+
columnsBreakpoints?: ColumnBreakpoint;
|
|
26
36
|
}
|
|
27
37
|
|
|
28
|
-
export function DataTable<TData, TValue>({
|
|
38
|
+
export function DataTable<TData extends TBaseData, TValue>({
|
|
29
39
|
data,
|
|
30
40
|
columns,
|
|
31
41
|
className,
|
|
32
42
|
filter,
|
|
33
43
|
filterColumn,
|
|
34
44
|
initialColumnOrder,
|
|
45
|
+
columnsBreakpoints = {},
|
|
35
46
|
}: DataTableProps<TData, TValue>) {
|
|
36
47
|
const [sorting, setSorting] = useState<SortingState>(
|
|
37
48
|
initialColumnOrder ?? []
|
|
@@ -67,7 +78,12 @@ export function DataTable<TData, TValue>({
|
|
|
67
78
|
<DataTable.Head
|
|
68
79
|
key={header.id}
|
|
69
80
|
onClick={header.column.getToggleSortingHandler()}
|
|
70
|
-
className={
|
|
81
|
+
className={classNames(
|
|
82
|
+
header.column.getCanSort() ? "s-cursor-pointer" : "",
|
|
83
|
+
columnsBreakpoints[header.id]
|
|
84
|
+
? `s-hidden ${columnsBreakpoints[header.id]}:s-block`
|
|
85
|
+
: ""
|
|
86
|
+
)}
|
|
71
87
|
>
|
|
72
88
|
<div className="s-flex s-items-center s-space-x-1 s-whitespace-nowrap">
|
|
73
89
|
{flexRender(
|
|
@@ -106,7 +122,14 @@ export function DataTable<TData, TValue>({
|
|
|
106
122
|
onMoreClick={row.original.onMoreClick}
|
|
107
123
|
>
|
|
108
124
|
{row.getVisibleCells().map((cell) => (
|
|
109
|
-
<DataTable.Cell
|
|
125
|
+
<DataTable.Cell
|
|
126
|
+
key={cell.id}
|
|
127
|
+
className={classNames(
|
|
128
|
+
columnsBreakpoints[cell.column.id]
|
|
129
|
+
? `s-hidden ${columnsBreakpoints[cell.column.id]}:s-block`
|
|
130
|
+
: ""
|
|
131
|
+
)}
|
|
132
|
+
>
|
|
110
133
|
{flexRender(cell.column.columnDef.cell, cell.getContext())}
|
|
111
134
|
</DataTable.Cell>
|
|
112
135
|
))}
|
|
@@ -20,9 +20,7 @@ type Data = {
|
|
|
20
20
|
size: string;
|
|
21
21
|
avatarUrl?: string;
|
|
22
22
|
icon?: React.ComponentType<{ className?: string }>;
|
|
23
|
-
clickable?: boolean;
|
|
24
23
|
onClick?: () => void;
|
|
25
|
-
showMore?: boolean;
|
|
26
24
|
onMoreClick?: () => void;
|
|
27
25
|
};
|
|
28
26
|
|
|
@@ -119,6 +117,7 @@ export const DataTableExample = () => {
|
|
|
119
117
|
data={data}
|
|
120
118
|
columns={columns}
|
|
121
119
|
initialColumnOrder={[{ id: "name", desc: false }]}
|
|
120
|
+
columnsBreakpoints={{ lastUpdated: "sm" }}
|
|
122
121
|
/>
|
|
123
122
|
</div>
|
|
124
123
|
);
|