@dust-tt/sparkle 0.2.201 → 0.2.202

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dust-tt/sparkle",
3
- "version": "0.2.201",
3
+ "version": "0.2.202",
4
4
  "scripts": {
5
5
  "build": "rm -rf dist && rollup -c",
6
6
  "build:with-tw-base": "rollup -c --environment INCLUDE_TW_BASE:true",
@@ -16,22 +16,33 @@ import { classNames } from "@sparkle/lib/utils";
16
16
 
17
17
  import { Icon } from "./Icon";
18
18
 
19
- interface DataTableProps<TData, TValue> {
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={header.column.getCanSort() ? "s-cursor-pointer" : ""}
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 key={cell.id}>
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
  );