@sustaina/shared-ui 1.4.2 → 1.5.0

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/index.mjs CHANGED
@@ -684,6 +684,15 @@ function getColumnPinningStyles(column) {
684
684
  };
685
685
  return { classes, style };
686
686
  }
687
+ function getRowClickHandlers(handler, { rowData, row, table }) {
688
+ const handleRowClick = (event, clickType) => {
689
+ handler(rowData, { event, row, table, clickType });
690
+ };
691
+ return {
692
+ onClick: (event) => handleRowClick(event, "single"),
693
+ onDoubleClick: (event) => handleRowClick(event, "double")
694
+ };
695
+ }
687
696
  var fallbackData = [];
688
697
  var DataTable = ({
689
698
  tableRef,
@@ -923,11 +932,12 @@ var DataTable = ({
923
932
  key: row.id,
924
933
  className: cn("group", tableDataRowProps?.className),
925
934
  "data-state": row.getIsSelected() ? "selected" : "non-selected",
926
- onClick: (event) => {
927
- if (typeof onRowClick === "function") {
928
- onRowClick(row.original, { event, row, table });
929
- }
930
- }
935
+ ...getRowClickHandlers(onRowClick ?? (() => {
936
+ }), {
937
+ rowData: row.original,
938
+ row,
939
+ table
940
+ })
931
941
  },
932
942
  row.getVisibleCells().map((cell) => {
933
943
  const { classes, style } = getColumnPinningStyles(cell.column);