@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.
@@ -1,8 +1,9 @@
1
1
  import { type ColumnDef, type SortingState } from "@tanstack/react-table";
2
2
  import React, { ReactNode } from "react";
3
+ import { DropdownItemProps } from "@sparkle/components/DropdownMenu";
3
4
  interface TBaseData {
4
5
  onClick?: () => void;
5
- onMoreClick?: () => void;
6
+ moreMenuItems?: DropdownItemProps[];
6
7
  }
7
8
  interface ColumnBreakpoint {
8
9
  [columnId: string]: "xs" | "sm" | "md" | "lg" | "xl";
@@ -22,8 +23,8 @@ export declare namespace DataTable {
22
23
  var Header: ({ children, className, ...props }: HeaderProps) => React.JSX.Element;
23
24
  var Head: ({ children, className, ...props }: HeadProps) => React.JSX.Element;
24
25
  var Body: ({ children, className, ...props }: React.HTMLAttributes<HTMLTableSectionElement>) => React.JSX.Element;
25
- var Row: ({ children, className, onClick, onMoreClick, ...props }: RowProps) => React.JSX.Element;
26
- var Cell: ({ children, className, avatarUrl, icon, iconClassName, description, ...props }: CellProps) => React.JSX.Element;
26
+ var Row: ({ children, className, onClick, moreMenuItems, ...props }: RowProps) => React.JSX.Element;
27
+ var Cell: ({ children, className, avatarUrl, roundedAvatar, icon, iconClassName, description, ...props }: CellProps) => React.JSX.Element;
27
28
  var Caption: ({ children, className, ...props }: React.HTMLAttributes<HTMLTableCaptionElement>) => React.JSX.Element;
28
29
  }
29
30
  interface DataTableRootProps extends React.HTMLAttributes<HTMLTableElement> {
@@ -38,7 +39,7 @@ interface HeadProps extends React.ThHTMLAttributes<HTMLTableCellElement> {
38
39
  interface RowProps extends React.HTMLAttributes<HTMLTableRowElement> {
39
40
  children: ReactNode;
40
41
  onClick?: () => void;
41
- onMoreClick?: () => void;
42
+ moreMenuItems?: DropdownItemProps[];
42
43
  }
43
44
  interface CellProps extends React.TdHTMLAttributes<HTMLTableCellElement> {
44
45
  avatarUrl?: string;
@@ -46,6 +47,7 @@ interface CellProps extends React.TdHTMLAttributes<HTMLTableCellElement> {
46
47
  className?: string;
47
48
  }>;
48
49
  iconClassName?: string;
50
+ roundedAvatar?: boolean;
49
51
  children?: ReactNode;
50
52
  description?: string;
51
53
  }
@@ -1,4 +1,4 @@
1
- import React, { ComponentType, JSXElementConstructor, ReactElement } from "react";
1
+ import React, { ComponentType, JSXElementConstructor, MouseEventHandler, ReactElement } from "react";
2
2
  import { TooltipProps } from "./Tooltip";
3
3
  export interface DropdownMenuProps {
4
4
  className?: string;
@@ -23,9 +23,9 @@ export interface DropdownButtonProps {
23
23
  className?: string;
24
24
  disabled?: boolean;
25
25
  children?: React.ReactNode;
26
- onClick?: () => void;
26
+ onClick?: MouseEventHandler;
27
27
  }
28
- interface DropdownItemProps {
28
+ export interface DropdownItemProps {
29
29
  variant?: "default" | "warning";
30
30
  label: string;
31
31
  description?: string;
package/dist/cjs/index.js CHANGED
@@ -128933,7 +128933,7 @@ function DataTable(_a) {
128933
128933
  : SvgArrowDown$1, size: "xs", className: classNames("s-ml-1", header.column.getIsSorted()
128934
128934
  ? "s-opacity-100"
128935
128935
  : "s-opacity-0") }))))); }))); })),
128936
- React.createElement(DataTable.Body, null, table.getRowModel().rows.map(function (row) { return (React.createElement(DataTable.Row, { key: row.id, onClick: row.original.onClick, onMoreClick: row.original.onMoreClick }, row.getVisibleCells().map(function (cell) { return (React.createElement(DataTable.Cell, { key: cell.id, className: classNames(columnsBreakpoints[cell.column.id]
128936
+ React.createElement(DataTable.Body, null, table.getRowModel().rows.map(function (row) { return (React.createElement(DataTable.Row, { key: row.id, onClick: row.original.onClick, moreMenuItems: row.original.moreMenuItems }, row.getVisibleCells().map(function (cell) { return (React.createElement(DataTable.Cell, { key: cell.id, className: classNames(columnsBreakpoints[cell.column.id]
128937
128937
  ? "s-hidden ".concat(columnsBreakpoints[cell.column.id], ":s-block")
128938
128938
  : "") }, flexRender(cell.column.columnDef.cell, cell.getContext()))); }))); }))));
128939
128939
  }
@@ -128954,20 +128954,22 @@ DataTable.Body = function Body(_a) {
128954
128954
  return (React.createElement("tbody", __assign({ className: className }, props), children));
128955
128955
  };
128956
128956
  DataTable.Row = function Row(_a) {
128957
- var children = _a.children, className = _a.className, onClick = _a.onClick, onMoreClick = _a.onMoreClick, props = __rest(_a, ["children", "className", "onClick", "onMoreClick"]);
128957
+ var children = _a.children, className = _a.className, onClick = _a.onClick, moreMenuItems = _a.moreMenuItems, props = __rest(_a, ["children", "className", "onClick", "moreMenuItems"]);
128958
128958
  return (React.createElement("tr", __assign({ className: classNames("s-border-b s-border-structure-200 s-text-sm", onClick ? "s-cursor-pointer hover:s-bg-gray-50" : "", className || ""), onClick: onClick ? onClick : undefined }, props),
128959
128959
  children,
128960
- onMoreClick && (React.createElement("td", { className: "s-w-1 s-cursor-pointer s-pl-1 s-text-element-600", onClick: function (e) {
128961
- e.stopPropagation(); // Prevent row click event
128962
- onMoreClick === null || onMoreClick === void 0 ? void 0 : onMoreClick();
128963
- } },
128964
- React.createElement(Icon, { visual: SvgMore$1, size: "sm" })))));
128960
+ moreMenuItems && (React.createElement("td", { className: "s-w-1 s-cursor-pointer s-pl-1 s-text-element-600" },
128961
+ React.createElement(DropdownMenu, { className: "s-flex" },
128962
+ React.createElement(DropdownMenu.Button, { onClick: function (e) {
128963
+ e.stopPropagation();
128964
+ } },
128965
+ React.createElement(Icon, { visual: SvgMore$1, size: "sm" })),
128966
+ React.createElement(DropdownMenu.Items, { origin: "topRight", width: 220 }, moreMenuItems === null || moreMenuItems === void 0 ? void 0 : moreMenuItems.map(function (item, index) { return (React.createElement(DropdownMenu.Item, __assign({ key: index }, item))); })))))));
128965
128967
  };
128966
128968
  DataTable.Cell = function Cell(_a) {
128967
- var children = _a.children, className = _a.className, avatarUrl = _a.avatarUrl, icon = _a.icon, iconClassName = _a.iconClassName, description = _a.description, props = __rest(_a, ["children", "className", "avatarUrl", "icon", "iconClassName", "description"]);
128969
+ var children = _a.children, className = _a.className, avatarUrl = _a.avatarUrl, roundedAvatar = _a.roundedAvatar, icon = _a.icon, iconClassName = _a.iconClassName, description = _a.description, props = __rest(_a, ["children", "className", "avatarUrl", "roundedAvatar", "icon", "iconClassName", "description"]);
128968
128970
  return (React.createElement("td", __assign({ className: classNames("s-whitespace-nowrap s-py-2 s-pl-0.5 s-text-element-800", className || "") }, props),
128969
128971
  React.createElement("div", { className: "s-flex" },
128970
- avatarUrl && (React.createElement(Avatar, { visual: avatarUrl, size: "xs", className: "s-mr-2" })),
128972
+ avatarUrl && (React.createElement(Avatar, { visual: avatarUrl, size: "xs", className: "s-mr-2", isRounded: roundedAvatar !== null && roundedAvatar !== void 0 ? roundedAvatar : false })),
128971
128973
  icon && (React.createElement(Icon, { visual: icon, size: "sm", className: classNames("s-mr-2 s-text-element-600", iconClassName || "") })),
128972
128974
  React.createElement("div", { className: "s-flex" },
128973
128975
  React.createElement("span", { className: "s-text-sm s-text-element-800" }, children),