@dust-tt/sparkle 0.2.643 → 0.2.645

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.
@@ -961,12 +961,14 @@ export interface DataTableMoreButtonProps {
961
961
  React.ComponentPropsWithoutRef<typeof DropdownMenu>,
962
962
  "modal"
963
963
  >;
964
+ disabled?: boolean;
964
965
  }
965
966
 
966
967
  DataTable.MoreButton = function MoreButton({
967
968
  className,
968
969
  menuItems,
969
970
  dropdownMenuProps,
971
+ disabled,
970
972
  }: DataTableMoreButtonProps) {
971
973
  if (!menuItems?.length) {
972
974
  return null;
@@ -984,11 +986,15 @@ DataTable.MoreButton = function MoreButton({
984
986
  icon={MoreIcon}
985
987
  size="mini"
986
988
  variant="ghost-secondary"
987
- className={cn(className)}
989
+ disabled={disabled}
990
+ className={cn(
991
+ disabled && "s-cursor-not-allowed s-opacity-50",
992
+ className
993
+ )}
988
994
  />
989
995
  </DropdownMenuTrigger>
990
996
 
991
- <DropdownMenuContent align="end">
997
+ <DropdownMenuContent align="end" hidden={disabled}>
992
998
  <DropdownMenuGroup>
993
999
  {menuItems.map((item, index) => renderMenuItem(item, index))}
994
1000
  </DropdownMenuGroup>
@@ -1032,6 +1038,11 @@ interface CellContentProps extends React.TdHTMLAttributes<HTMLDivElement> {
1032
1038
  children?: ReactNode;
1033
1039
  description?: string;
1034
1040
  grow?: boolean;
1041
+ disabled?: boolean;
1042
+ avatarStack?: {
1043
+ items: { name: string; visual: string }[];
1044
+ nbVisibleItems?: number;
1045
+ };
1035
1046
  }
1036
1047
 
1037
1048
  DataTable.CellContent = function CellContent({
@@ -1044,6 +1055,8 @@ DataTable.CellContent = function CellContent({
1044
1055
  iconClassName,
1045
1056
  description,
1046
1057
  grow = false,
1058
+ disabled,
1059
+ avatarStack,
1047
1060
  ...props
1048
1061
  }: CellContentProps) {
1049
1062
  return (
@@ -1051,8 +1064,10 @@ DataTable.CellContent = function CellContent({
1051
1064
  className={cn(
1052
1065
  "s-flex s-items-center",
1053
1066
  grow ? "s-flex-grow" : "",
1067
+ disabled && "s-cursor-not-allowed s-opacity-50",
1054
1068
  className
1055
1069
  )}
1070
+ aria-disabled={disabled || undefined}
1056
1071
  {...props}
1057
1072
  >
1058
1073
  {avatarUrl && avatarTooltipLabel && (
@@ -1076,6 +1091,14 @@ DataTable.CellContent = function CellContent({
1076
1091
  isRounded={roundedAvatar ?? false}
1077
1092
  />
1078
1093
  )}
1094
+ {avatarStack && (
1095
+ <Avatar.Stack
1096
+ avatars={avatarStack.items}
1097
+ nbVisibleItems={avatarStack.nbVisibleItems}
1098
+ size="xs"
1099
+ isRounded={roundedAvatar ?? false}
1100
+ />
1101
+ )}
1079
1102
  {icon && (
1080
1103
  <Icon
1081
1104
  visual={icon}
@@ -1117,6 +1140,7 @@ interface BasicCellContentProps extends React.TdHTMLAttributes<HTMLDivElement> {
1117
1140
  label: string | number;
1118
1141
  tooltip?: string | number;
1119
1142
  textToCopy?: string | number;
1143
+ disabled?: boolean;
1120
1144
  }
1121
1145
 
1122
1146
  DataTable.BasicCellContent = function BasicCellContent({
@@ -1124,6 +1148,7 @@ DataTable.BasicCellContent = function BasicCellContent({
1124
1148
  tooltip,
1125
1149
  className,
1126
1150
  textToCopy,
1151
+ disabled,
1127
1152
  ...props
1128
1153
  }: BasicCellContentProps) {
1129
1154
  const [isCopied, copyToClipboard] = useCopyToClipboard();
@@ -1150,8 +1175,10 @@ DataTable.BasicCellContent = function BasicCellContent({
1150
1175
  cellHeight,
1151
1176
  "s-group s-flex s-items-center s-gap-2 s-text-sm",
1152
1177
  "s-text-muted-foreground dark:s-text-muted-foreground-night",
1178
+ disabled && "s-cursor-not-allowed s-opacity-50",
1153
1179
  className
1154
1180
  )}
1181
+ aria-disabled={disabled || undefined}
1155
1182
  {...props}
1156
1183
  >
1157
1184
  <span className="s-truncate">{label}</span>
@@ -1177,8 +1204,10 @@ DataTable.BasicCellContent = function BasicCellContent({
1177
1204
  cellHeight,
1178
1205
  "s-group s-flex s-items-center s-gap-2 s-text-sm",
1179
1206
  "s-text-muted-foreground dark:s-text-muted-foreground-night",
1207
+ disabled && "s-cursor-not-allowed s-opacity-50",
1180
1208
  className
1181
1209
  )}
1210
+ aria-disabled={disabled || undefined}
1182
1211
  {...props}
1183
1212
  >
1184
1213
  <span className="s-truncate">{label}</span>
@@ -52,6 +52,7 @@ type Data = {
52
52
  >;
53
53
  id?: number;
54
54
  roundedAvatar?: boolean;
55
+ avatarStack?: { name: string; visual: string }[];
55
56
  };
56
57
 
57
58
  type TransformedData = {
@@ -181,6 +182,130 @@ const data: TransformedData[] = [
181
182
  },
182
183
  ];
183
184
 
185
+ const avatarStackData: TransformedData[] = [
186
+ {
187
+ name: "Team Alpha",
188
+ description: "Development team",
189
+ usedBy: 12,
190
+ addedBy: "Project Manager",
191
+ lastUpdated: "2024-01-15",
192
+ size: "256kb",
193
+ avatarStack: [
194
+ {
195
+ name: "Alice Johnson",
196
+ visual: "https://avatars.githubusercontent.com/u/1?s=200&v=4",
197
+ },
198
+ {
199
+ name: "Bob Smith",
200
+ visual: "https://avatars.githubusercontent.com/u/2?s=200&v=4",
201
+ },
202
+ {
203
+ name: "Carol Davis",
204
+ visual: "https://avatars.githubusercontent.com/u/3?s=200&v=4",
205
+ },
206
+ {
207
+ name: "David Wilson",
208
+ visual: "https://avatars.githubusercontent.com/u/4?s=200&v=4",
209
+ },
210
+ {
211
+ name: "Eve Brown",
212
+ visual: "https://avatars.githubusercontent.com/u/5?s=200&v=4",
213
+ },
214
+ ],
215
+ onClick: () => alert("Team Alpha clicked"),
216
+ },
217
+ {
218
+ name: "Marketing Team",
219
+ description: "Marketing and communications",
220
+ usedBy: 8,
221
+ addedBy: "Marketing Director",
222
+ lastUpdated: "2024-01-14",
223
+ size: "128kb",
224
+ avatarStack: [
225
+ {
226
+ name: "Frank Miller",
227
+ visual: "https://avatars.githubusercontent.com/u/6?s=200&v=4",
228
+ },
229
+ {
230
+ name: "Grace Lee",
231
+ visual: "https://avatars.githubusercontent.com/u/7?s=200&v=4",
232
+ },
233
+ {
234
+ name: "Henry Taylor",
235
+ visual: "https://avatars.githubusercontent.com/u/8?s=200&v=4",
236
+ },
237
+ ],
238
+ onClick: () => alert("Marketing Team clicked"),
239
+ },
240
+ {
241
+ name: "Design Squad",
242
+ description: "UI/UX design team",
243
+ usedBy: 6,
244
+ addedBy: "Design Lead",
245
+ lastUpdated: "2024-01-13",
246
+ size: "512kb",
247
+ avatarStack: [
248
+ {
249
+ name: "Ivy Chen",
250
+ visual: "https://avatars.githubusercontent.com/u/9?s=200&v=4",
251
+ },
252
+ {
253
+ name: "Jack Rodriguez",
254
+ visual: "https://avatars.githubusercontent.com/u/10?s=200&v=4",
255
+ },
256
+ {
257
+ name: "Kate Anderson",
258
+ visual: "https://avatars.githubusercontent.com/u/11?s=200&v=4",
259
+ },
260
+ {
261
+ name: "Liam Thompson",
262
+ visual: "https://avatars.githubusercontent.com/u/12?s=200&v=4",
263
+ },
264
+ ],
265
+ roundedAvatar: true,
266
+ onClick: () => alert("Design Squad clicked"),
267
+ },
268
+ {
269
+ name: "Large Team",
270
+ description: "Cross-functional team with many members",
271
+ usedBy: 25,
272
+ addedBy: "Team Lead",
273
+ lastUpdated: "2024-01-12",
274
+ size: "1.2mb",
275
+ avatarStack: [
276
+ {
277
+ name: "Maya Patel",
278
+ visual: "https://avatars.githubusercontent.com/u/13?s=200&v=4",
279
+ },
280
+ {
281
+ name: "Noah Garcia",
282
+ visual: "https://avatars.githubusercontent.com/u/14?s=200&v=4",
283
+ },
284
+ {
285
+ name: "Olivia Martinez",
286
+ visual: "https://avatars.githubusercontent.com/u/15?s=200&v=4",
287
+ },
288
+ {
289
+ name: "Paul Kim",
290
+ visual: "https://avatars.githubusercontent.com/u/16?s=200&v=4",
291
+ },
292
+ {
293
+ name: "Quinn White",
294
+ visual: "https://avatars.githubusercontent.com/u/17?s=200&v=4",
295
+ },
296
+ {
297
+ name: "Rachel Green",
298
+ visual: "https://avatars.githubusercontent.com/u/18?s=200&v=4",
299
+ },
300
+ {
301
+ name: "Sam Johnson",
302
+ visual: "https://avatars.githubusercontent.com/u/19?s=200&v=4",
303
+ },
304
+ ],
305
+ onClick: () => alert("Large Team clicked"),
306
+ },
307
+ ];
308
+
184
309
  const columns: ColumnDef<Data>[] = [
185
310
  {
186
311
  accessorKey: "name",
@@ -770,3 +895,113 @@ export const DataTableWithRadioSelectionExample = () => {
770
895
  </div>
771
896
  );
772
897
  };
898
+
899
+ // Column definition for avatar stack story
900
+ const avatarStackColumns: ColumnDef<Data>[] = [
901
+ {
902
+ accessorKey: "name",
903
+ header: "Team Name",
904
+ sortingFn: "text",
905
+ id: "name",
906
+ meta: {
907
+ className: "s-w-full",
908
+ tooltip: "Team name with member avatars",
909
+ },
910
+ cell: (info) => (
911
+ <DataTable.CellContent
912
+ avatarStack={
913
+ info.row.original.avatarStack
914
+ ? {
915
+ items: info.row.original.avatarStack,
916
+ nbVisibleItems: 3,
917
+ }
918
+ : undefined
919
+ }
920
+ description={info.row.original.description}
921
+ roundedAvatar={info.row.original.roundedAvatar}
922
+ >
923
+ {info.row.original.name}
924
+ </DataTable.CellContent>
925
+ ),
926
+ },
927
+ {
928
+ accessorKey: "usedBy",
929
+ id: "usedBy",
930
+ meta: {
931
+ className: "s-w-[82px] s-hidden @xs/table:s-table-cell",
932
+ },
933
+ header: "Members",
934
+ cell: (info) => (
935
+ <DataTable.BasicCellContent label={info.row.original.usedBy} />
936
+ ),
937
+ },
938
+ {
939
+ accessorKey: "addedBy",
940
+ header: "Created by",
941
+ id: "addedBy",
942
+ meta: {
943
+ className: "s-w-[128px]",
944
+ },
945
+ cell: (info) => (
946
+ <DataTable.BasicCellContent
947
+ label={info.row.original.addedBy}
948
+ textToCopy={info.row.original.addedBy}
949
+ tooltip={info.row.original.addedBy}
950
+ />
951
+ ),
952
+ },
953
+ {
954
+ accessorKey: "lastUpdated",
955
+ id: "lastUpdated",
956
+ header: "Last updated",
957
+ meta: {
958
+ className: "s-w-[128px] s-hidden @sm/table:s-table-cell",
959
+ },
960
+ cell: (info) => (
961
+ <DataTable.BasicCellContent label={info.row.original.lastUpdated} />
962
+ ),
963
+ enableSorting: false,
964
+ },
965
+ {
966
+ accessorKey: "size",
967
+ id: "size",
968
+ header: "Size",
969
+ meta: {
970
+ className: "s-w-[48px] s-hidden @sm/table:s-table-cell",
971
+ },
972
+ cell: (info) => (
973
+ <DataTable.BasicCellContent label={info.row.original.size} />
974
+ ),
975
+ },
976
+ ];
977
+
978
+ export const DataTableWithAvatarStackExample = () => {
979
+ const [filter, setFilter] = React.useState<string>("");
980
+
981
+ return (
982
+ <div className="s-flex s-w-full s-max-w-4xl s-flex-col s-gap-6">
983
+ <h3 className="s-text-lg s-font-medium">DataTable with Avatar Stack</h3>
984
+ <p className="s-text-sm s-text-muted-foreground">
985
+ This example demonstrates the DataTable with avatar stacks showing team
986
+ members. The avatar stack displays up to 4 visible avatars with a count
987
+ indicator for additional members.
988
+ </p>
989
+
990
+ <div className="s-flex s-flex-col s-gap-4">
991
+ <Input
992
+ name="filter"
993
+ placeholder="Filter teams..."
994
+ value={filter}
995
+ onChange={(e) => setFilter(e.target.value)}
996
+ />
997
+
998
+ <DataTable
999
+ data={avatarStackData}
1000
+ filter={filter}
1001
+ filterColumn="name"
1002
+ columns={avatarStackColumns}
1003
+ />
1004
+ </div>
1005
+ </div>
1006
+ );
1007
+ };