@dust-tt/sparkle 0.2.205 → 0.2.207
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 +6 -4
- package/dist/cjs/components/DropdownMenu.d.ts +3 -3
- package/dist/cjs/index.js +11 -9
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/components/DataTable.d.ts +6 -4
- package/dist/esm/components/DropdownMenu.d.ts +3 -3
- package/dist/esm/index.js +11 -9
- package/dist/esm/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/components/DataTable.tsx +30 -15
- package/src/components/DropdownMenu.tsx +3 -2
- package/src/stories/DataTable.stories.tsx +12 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dust-tt/sparkle",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.207",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build": "rm -rf dist && rollup -c",
|
|
6
6
|
"build:with-tw-base": "rollup -c --environment INCLUDE_TW_BASE:true",
|
|
@@ -92,4 +92,4 @@
|
|
|
92
92
|
"tailwind-scrollbar-hide": "^1.1.7"
|
|
93
93
|
},
|
|
94
94
|
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
|
|
95
|
-
}
|
|
95
|
+
}
|
|
@@ -10,7 +10,8 @@ import {
|
|
|
10
10
|
} from "@tanstack/react-table";
|
|
11
11
|
import React, { ReactNode, useEffect, useState } from "react";
|
|
12
12
|
|
|
13
|
-
import {
|
|
13
|
+
import { DropdownItemProps } from "@sparkle/components/DropdownMenu";
|
|
14
|
+
import { Avatar, DropdownMenu, MoreIcon } from "@sparkle/index";
|
|
14
15
|
import { ArrowDownIcon, ArrowUpIcon } from "@sparkle/index";
|
|
15
16
|
import { classNames } from "@sparkle/lib/utils";
|
|
16
17
|
|
|
@@ -18,7 +19,7 @@ import { Icon } from "./Icon";
|
|
|
18
19
|
|
|
19
20
|
interface TBaseData {
|
|
20
21
|
onClick?: () => void;
|
|
21
|
-
|
|
22
|
+
moreMenuItems?: DropdownItemProps[];
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
interface ColumnBreakpoint {
|
|
@@ -119,7 +120,7 @@ export function DataTable<TData extends TBaseData, TValue>({
|
|
|
119
120
|
<DataTable.Row
|
|
120
121
|
key={row.id}
|
|
121
122
|
onClick={row.original.onClick}
|
|
122
|
-
|
|
123
|
+
moreMenuItems={row.original.moreMenuItems}
|
|
123
124
|
>
|
|
124
125
|
{row.getVisibleCells().map((cell) => (
|
|
125
126
|
<DataTable.Cell
|
|
@@ -211,14 +212,14 @@ DataTable.Body = function Body({
|
|
|
211
212
|
interface RowProps extends React.HTMLAttributes<HTMLTableRowElement> {
|
|
212
213
|
children: ReactNode;
|
|
213
214
|
onClick?: () => void;
|
|
214
|
-
|
|
215
|
+
moreMenuItems?: DropdownItemProps[];
|
|
215
216
|
}
|
|
216
217
|
|
|
217
218
|
DataTable.Row = function Row({
|
|
218
219
|
children,
|
|
219
220
|
className,
|
|
220
221
|
onClick,
|
|
221
|
-
|
|
222
|
+
moreMenuItems,
|
|
222
223
|
...props
|
|
223
224
|
}: RowProps) {
|
|
224
225
|
return (
|
|
@@ -232,15 +233,22 @@ DataTable.Row = function Row({
|
|
|
232
233
|
{...props}
|
|
233
234
|
>
|
|
234
235
|
{children}
|
|
235
|
-
{
|
|
236
|
-
<td
|
|
237
|
-
className="s-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
236
|
+
{moreMenuItems && (
|
|
237
|
+
<td className="s-w-1 s-cursor-pointer s-pl-1 s-text-element-600">
|
|
238
|
+
<DropdownMenu className="s-flex">
|
|
239
|
+
<DropdownMenu.Button
|
|
240
|
+
onClick={(e) => {
|
|
241
|
+
e.stopPropagation();
|
|
242
|
+
}}
|
|
243
|
+
>
|
|
244
|
+
<Icon visual={MoreIcon} size="sm" />
|
|
245
|
+
</DropdownMenu.Button>
|
|
246
|
+
<DropdownMenu.Items origin="topRight" width={220}>
|
|
247
|
+
{moreMenuItems?.map((item, index) => (
|
|
248
|
+
<DropdownMenu.Item key={index} {...item} />
|
|
249
|
+
))}
|
|
250
|
+
</DropdownMenu.Items>
|
|
251
|
+
</DropdownMenu>
|
|
244
252
|
</td>
|
|
245
253
|
)}
|
|
246
254
|
</tr>
|
|
@@ -250,6 +258,7 @@ interface CellProps extends React.TdHTMLAttributes<HTMLTableCellElement> {
|
|
|
250
258
|
avatarUrl?: string;
|
|
251
259
|
icon?: React.ComponentType<{ className?: string }>;
|
|
252
260
|
iconClassName?: string;
|
|
261
|
+
roundedAvatar?: boolean;
|
|
253
262
|
children?: ReactNode;
|
|
254
263
|
description?: string;
|
|
255
264
|
}
|
|
@@ -258,6 +267,7 @@ DataTable.Cell = function Cell({
|
|
|
258
267
|
children,
|
|
259
268
|
className,
|
|
260
269
|
avatarUrl,
|
|
270
|
+
roundedAvatar,
|
|
261
271
|
icon,
|
|
262
272
|
iconClassName,
|
|
263
273
|
description,
|
|
@@ -273,7 +283,12 @@ DataTable.Cell = function Cell({
|
|
|
273
283
|
>
|
|
274
284
|
<div className="s-flex">
|
|
275
285
|
{avatarUrl && (
|
|
276
|
-
<Avatar
|
|
286
|
+
<Avatar
|
|
287
|
+
visual={avatarUrl}
|
|
288
|
+
size="xs"
|
|
289
|
+
className="s-mr-2"
|
|
290
|
+
isRounded={roundedAvatar ?? false}
|
|
291
|
+
/>
|
|
277
292
|
)}
|
|
278
293
|
{icon && (
|
|
279
294
|
<Icon
|
|
@@ -3,6 +3,7 @@ import React, {
|
|
|
3
3
|
ComponentType,
|
|
4
4
|
Fragment,
|
|
5
5
|
JSXElementConstructor,
|
|
6
|
+
MouseEventHandler,
|
|
6
7
|
MutableRefObject,
|
|
7
8
|
ReactElement,
|
|
8
9
|
useContext,
|
|
@@ -97,7 +98,7 @@ export interface DropdownButtonProps {
|
|
|
97
98
|
className?: string;
|
|
98
99
|
disabled?: boolean;
|
|
99
100
|
children?: React.ReactNode;
|
|
100
|
-
onClick?:
|
|
101
|
+
onClick?: MouseEventHandler;
|
|
101
102
|
}
|
|
102
103
|
|
|
103
104
|
DropdownMenu.Button = function ({
|
|
@@ -227,7 +228,7 @@ DropdownMenu.Button = function ({
|
|
|
227
228
|
);
|
|
228
229
|
};
|
|
229
230
|
|
|
230
|
-
interface DropdownItemProps {
|
|
231
|
+
export interface DropdownItemProps {
|
|
231
232
|
variant?: "default" | "warning";
|
|
232
233
|
label: string;
|
|
233
234
|
description?: string;
|
|
@@ -2,6 +2,8 @@ import type { Meta } from "@storybook/react";
|
|
|
2
2
|
import { ColumnDef } from "@tanstack/react-table";
|
|
3
3
|
import React from "react";
|
|
4
4
|
|
|
5
|
+
import { DropdownItemProps } from "@sparkle/components/DropdownMenu";
|
|
6
|
+
|
|
5
7
|
import { DataTable, FolderIcon } from "../index_with_tw_base";
|
|
6
8
|
|
|
7
9
|
const meta = {
|
|
@@ -21,7 +23,8 @@ type Data = {
|
|
|
21
23
|
avatarUrl?: string;
|
|
22
24
|
icon?: React.ComponentType<{ className?: string }>;
|
|
23
25
|
onClick?: () => void;
|
|
24
|
-
|
|
26
|
+
moreMenuItems?: DropdownItemProps[];
|
|
27
|
+
roundedAvatar?: boolean;
|
|
25
28
|
};
|
|
26
29
|
|
|
27
30
|
export const DataTableExample = () => {
|
|
@@ -34,8 +37,8 @@ export const DataTableExample = () => {
|
|
|
34
37
|
lastUpdated: "July 8, 2023",
|
|
35
38
|
size: "32kb",
|
|
36
39
|
avatarUrl: "https://dust.tt/static/droidavatar/Droid_Lime_3.jpg",
|
|
40
|
+
roundedAvatar: true,
|
|
37
41
|
onClick: () => console.log("hehe"),
|
|
38
|
-
onMoreClick: () => console.log("show more"),
|
|
39
42
|
},
|
|
40
43
|
{
|
|
41
44
|
name: "Design",
|
|
@@ -44,6 +47,12 @@ export const DataTableExample = () => {
|
|
|
44
47
|
lastUpdated: "2023-07-09",
|
|
45
48
|
size: "64kb",
|
|
46
49
|
icon: FolderIcon,
|
|
50
|
+
moreMenuItems: [
|
|
51
|
+
{
|
|
52
|
+
label: "Edit",
|
|
53
|
+
onClick: () => console.log("Edit"),
|
|
54
|
+
},
|
|
55
|
+
],
|
|
47
56
|
},
|
|
48
57
|
{
|
|
49
58
|
name: "Development",
|
|
@@ -77,6 +86,7 @@ export const DataTableExample = () => {
|
|
|
77
86
|
avatarUrl={info.row.original.avatarUrl}
|
|
78
87
|
icon={info.row.original.icon}
|
|
79
88
|
description={info.row.original.description}
|
|
89
|
+
roundedAvatar={info.row.original.roundedAvatar}
|
|
80
90
|
>
|
|
81
91
|
{info.row.original.name}
|
|
82
92
|
</DataTable.Cell>
|