@indico-data/design-system 2.51.0 → 2.51.1

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.
Files changed (29) hide show
  1. package/lib/components/tanstackTable/TankstackTable.types.d.ts +7 -2
  2. package/lib/components/tanstackTable/TanstackTable.stories.d.ts +1 -0
  3. package/lib/components/tanstackTable/TanstakTable.d.ts +1 -1
  4. package/lib/components/tanstackTable/components/TableBody/TableBody.d.ts +5 -6
  5. package/lib/components/tanstackTable/components/TablePagination/TablePagination.d.ts +1 -1
  6. package/lib/components/tanstackTable/useTanstackTable.d.ts +0 -2
  7. package/lib/index.css +33 -18
  8. package/lib/index.d.ts +8 -3
  9. package/lib/index.esm.css +33 -18
  10. package/lib/index.esm.js +22 -45
  11. package/lib/index.esm.js.map +1 -1
  12. package/lib/index.js +22 -45
  13. package/lib/index.js.map +1 -1
  14. package/package.json +1 -1
  15. package/src/components/tanstackTable/TankstackTable.types.ts +7 -2
  16. package/src/components/tanstackTable/TanstackTable.stories.tsx +34 -10
  17. package/src/components/tanstackTable/TanstakTable.tsx +8 -9
  18. package/src/components/tanstackTable/__tests__/TanstackTable.test.tsx +3 -17
  19. package/src/components/tanstackTable/components/ActionBar/ActionBar.scss +1 -1
  20. package/src/components/tanstackTable/components/ActionBar/ActionBar.tsx +0 -8
  21. package/src/components/tanstackTable/components/ActionBar/__tests__/ActionBar.test.tsx +0 -22
  22. package/src/components/tanstackTable/components/TableBody/TableBody.tsx +12 -22
  23. package/src/components/tanstackTable/components/TablePagination/TablePagination.tsx +2 -2
  24. package/src/components/tanstackTable/helpers.ts +1 -1
  25. package/src/components/tanstackTable/mock-data/table-configuration.tsx +4 -1
  26. package/src/components/tanstackTable/styles/table.scss +36 -22
  27. package/src/components/tanstackTable/tanstack-table.d.ts +1 -0
  28. package/src/components/tanstackTable/useTanstackTable.tsx +0 -3
  29. package/src/stylesAndAnimations/utilityClasses/UtilityClassesTable.tsx +16 -2
package/lib/index.js CHANGED
@@ -25669,12 +25669,7 @@ function ActionBar({ table, TableActions, className, children, }) {
25669
25669
  row.toggleSelected(false);
25670
25670
  });
25671
25671
  };
25672
- const getSelectedItemsText = () => {
25673
- if (selectedItems.length === 1)
25674
- return '1 item selected';
25675
- return `${selectedItems.length} items selected`;
25676
- };
25677
- return (jsxRuntime.jsx(Card, { className: classNames('tanstack-table__action-bar', className), children: children !== null && children !== void 0 ? children : (jsxRuntime.jsxs("div", { className: "tanstack-table__action-bar__container", children: [jsxRuntime.jsx("div", { className: "tanstack-table__action-bar__text-container", children: jsxRuntime.jsx("span", { children: getSelectedItemsText() }) }), TableActions && (jsxRuntime.jsx("div", { className: "tanstack-table__action-bar__button-container", children: jsxRuntime.jsx(TableActions, { selectedItems: selectedItems, unselectRows: unselectRows }) }))] })) }));
25672
+ return (jsxRuntime.jsx(Card, { className: classNames('tanstack-table__action-bar', className), children: children !== null && children !== void 0 ? children : (jsxRuntime.jsx("div", { className: "tanstack-table__action-bar__container", children: TableActions && (jsxRuntime.jsx("div", { className: "tanstack-table__action-bar__button-container", children: jsxRuntime.jsx(TableActions, { selectedItems: selectedItems, unselectRows: unselectRows }) })) })) }));
25678
25673
  }
25679
25674
 
25680
25675
  function NoResults({ clearFilters, hasFilters, message }) {
@@ -42887,7 +42882,7 @@ var lodashExports = lodash.exports;
42887
42882
 
42888
42883
  const TablePagination = ({ rowsPerPage, rowCount, onChangePage, currentPage, totalEntriesText, }) => {
42889
42884
  const totalPages = Math.ceil(rowCount / rowsPerPage);
42890
- return (jsxRuntime.jsx("div", { className: "table__pagination", "data-testid": "tanstack-table-pagination", children: jsxRuntime.jsxs(Row, { align: "center", justify: "between", children: [jsxRuntime.jsx(Col, { xs: "content", children: totalEntriesText && (jsxRuntime.jsx("span", { "data-testid": "table-pagination-total-entries", className: "table__pagination-total-entries", children: totalEntriesText })) }), jsxRuntime.jsx(Col, { xs: "content", children: jsxRuntime.jsx(Pagination, { "data-testid": "table-pagination-component", totalPages: totalPages, currentPage: currentPage, onChange: (page) => onChangePage(page, rowsPerPage) }) })] }) }));
42885
+ return (jsxRuntime.jsx("div", { className: "table__pagination", "data-testid": "tanstack-table-pagination", children: jsxRuntime.jsxs(Row, { align: "center", justify: "between", children: [jsxRuntime.jsx(Col, { xs: "content", children: totalEntriesText && (jsxRuntime.jsx("span", { "data-testid": "table-pagination-total-entries", className: "table__pagination-total-entries", children: totalEntriesText })) }), jsxRuntime.jsx(Col, { xs: "content", children: jsxRuntime.jsx(Pagination, { "data-testid": "table-pagination-component", totalPages: totalPages, currentPage: currentPage, onChange: (page) => onChangePage(page) }) })] }) }));
42891
42886
  };
42892
42887
 
42893
42888
  function useTanstackTable({ defaultColumns }) {
@@ -42896,7 +42891,6 @@ function useTanstackTable({ defaultColumns }) {
42896
42891
  const [windowWidth, setWindowWidth] = React.useState(window.innerWidth);
42897
42892
  const [rowSelection, setRowSelection] = React.useState({});
42898
42893
  const [formattedColumns, setFormattedColumns] = React.useState(columns);
42899
- const [isClickedRow, setIsClickedRow] = React.useState([]);
42900
42894
  // Tracks changes to browser width to allow for updating of column widths
42901
42895
  React.useEffect(() => {
42902
42896
  const handleResize = () => {
@@ -42915,8 +42909,6 @@ function useTanstackTable({ defaultColumns }) {
42915
42909
  windowWidth,
42916
42910
  formattedColumns,
42917
42911
  setFormattedColumns,
42918
- isClickedRow,
42919
- setIsClickedRow,
42920
42912
  };
42921
42913
  }
42922
42914
 
@@ -42927,7 +42919,7 @@ const getCommonPinningStyles = (column) => {
42927
42919
  return {
42928
42920
  boxShadow: isLastLeftPinnedColumn ? '-4px 0 4px -4px gray inset' : undefined,
42929
42921
  left: isPinned === 'left' ? `${column.getStart('left')}px` : undefined,
42930
- position: isPinned ? 'sticky' : 'relative',
42922
+ position: isPinned ? 'sticky' : 'initial',
42931
42923
  zIndex: isPinned ? 1 : 0,
42932
42924
  };
42933
42925
  };
@@ -42971,37 +42963,32 @@ const TableHeader = React.forwardRef(({ table }, ref) => {
42971
42963
  }) }, headerGroup.id))) }));
42972
42964
  });
42973
42965
 
42974
- const TableBody = ({ table, onClickRow, isLoading, columnsLength, isClickedRow, setIsClickedRow, }) => {
42975
- const toggleRow = (id) => {
42976
- if (isClickedRow.includes(id)) {
42977
- setIsClickedRow((state) => state.filter((item) => item !== id));
42978
- }
42979
- else {
42980
- setIsClickedRow((state) => [...state, id]);
42981
- }
42982
- };
42966
+ const TableBody = ({ table, onRowClick, isLoading, columnsLength, activeRows, }) => {
42983
42967
  return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [table.getRowModel().rows.map((row) => (jsxRuntime.jsx("tr", { className: classNames('tanstack-table__tbody__tr', {
42984
42968
  'is-selected': row.getIsSelected(),
42985
- 'show-hover': !!onClickRow,
42986
- 'is-clicked': isClickedRow.includes(row.id),
42987
- }), onClick: () => {
42988
- if (!!onClickRow) {
42989
- toggleRow(row.id);
42990
- onClickRow(row);
42991
- }
42992
- }, children: row.getVisibleCells().map((cell) => {
42969
+ 'show-hover': !!onRowClick,
42970
+ 'is-clicked': activeRows.includes(row.id), // Checkbox Is clicked
42971
+ }), children: row.getVisibleCells().map((cell) => {
42993
42972
  var _a, _b, _c, _d, _e, _f, _g, _h;
42994
42973
  const { columnDef } = cell.column;
42995
42974
  return (jsxRuntime.jsx("td", { className: classNames('tanstack-table__tbody__td', {
42996
42975
  'pa-0': !!((_c = (_b = (_a = columnDef.meta) === null || _a === void 0 ? void 0 : _a.styles) === null || _b === void 0 ? void 0 : _b.cell) === null || _c === void 0 ? void 0 : _c.hasNoPadding),
42997
- }), style: Object.assign({}, getTdStyles(cell.column, (_f = (_e = (_d = columnDef.meta) === null || _d === void 0 ? void 0 : _d.styles) === null || _e === void 0 ? void 0 : _e.cell) === null || _f === void 0 ? void 0 : _f.textAlign, (_h = (_g = columnDef.meta) === null || _g === void 0 ? void 0 : _g.styles) === null || _h === void 0 ? void 0 : _h.definedColumnSize, cell.column.getSize())), children: flexRender(columnDef.cell, cell.getContext()) }, cell.id));
42976
+ }), style: Object.assign({}, getTdStyles(cell.column, (_f = (_e = (_d = columnDef.meta) === null || _d === void 0 ? void 0 : _d.styles) === null || _e === void 0 ? void 0 : _e.cell) === null || _f === void 0 ? void 0 : _f.textAlign, (_h = (_g = columnDef.meta) === null || _g === void 0 ? void 0 : _g.styles) === null || _h === void 0 ? void 0 : _h.definedColumnSize, cell.column.getSize())), onClick: () => {
42977
+ var _a, _b, _c;
42978
+ // if the cell is not preventRowSelection, then we can click the row
42979
+ if (!((_c = (_b = (_a = columnDef.meta) === null || _a === void 0 ? void 0 : _a.styles) === null || _b === void 0 ? void 0 : _b.cell) === null || _c === void 0 ? void 0 : _c.preventRowSelection)) {
42980
+ onRowClick === null || onRowClick === void 0 ? void 0 : onRowClick(row);
42981
+ }
42982
+ }, children: flexRender(columnDef.cell, cell.getContext()) }, cell.id));
42998
42983
  }) }, row.id))), isLoading && (jsxRuntime.jsx("tr", { className: "tanstack-table__tbody__tr", children: jsxRuntime.jsx("td", { className: classNames('tanstack-table__centered-row', {
42999
42984
  'is-Loading': isLoading,
43000
42985
  }), colSpan: columnsLength, children: jsxRuntime.jsx(CirclePulse, { "data-testid": "loading-indicator" }) }) }))] }));
43001
42986
  };
43002
42987
 
43003
- function TanstackTable({ columns: defaultColumns, data, className, currentPage, rowCount, rowsPerPage = 1000, onChangePage, totalEntriesText, TableActions, error, enableRowSelection = true, clearFilters, hasFilters, showPagination = true, isLoading = false, defaultPinnedColumns, onClickRow = null, actionBarClassName, }) {
43004
- const { columns, defaultData, windowWidth, rowSelection, setRowSelection, formattedColumns, setFormattedColumns, isClickedRow, setIsClickedRow, } = useTanstackTable({
42988
+ function TanstackTable(_a) {
42989
+ var { columns: defaultColumns, data, className, currentPage, rowCount, rowsPerPage = 1000, onChangePage, totalEntriesText, TableActions, error, enableRowSelection = true, clearFilters, hasFilters, showPagination = true, isLoading = false, defaultPinnedColumns, onRowClick, activeRows = [], actionBarClassName } = _a, rest = __rest(_a, ["columns", "data", "className", "currentPage", "rowCount", "rowsPerPage", "onChangePage", "totalEntriesText", "TableActions", "error", "enableRowSelection", "clearFilters", "hasFilters", "showPagination", "isLoading", "defaultPinnedColumns", "onRowClick", "activeRows", "actionBarClassName"]);
42990
+ const { columns, defaultData, windowWidth, rowSelection, // This refers to the checkboxes.
42991
+ setRowSelection, formattedColumns, setFormattedColumns, } = useTanstackTable({
43005
42992
  defaultColumns,
43006
42993
  });
43007
42994
  const thRefs = React.useRef({});
@@ -43014,23 +43001,13 @@ function TanstackTable({ columns: defaultColumns, data, className, currentPage,
43014
43001
  });
43015
43002
  setFormattedColumns(updatedColumns);
43016
43003
  }, [data, columns, windowWidth]);
43017
- const table = useReactTable({
43018
- data: data !== null && data !== void 0 ? data : defaultData,
43019
- columns: formattedColumns,
43020
- state: {
43004
+ const table = useReactTable(Object.assign(Object.assign({}, rest), { data: data !== null && data !== void 0 ? data : defaultData, columns: formattedColumns, state: {
43021
43005
  rowSelection,
43022
- },
43023
- enableRowSelection,
43024
- onRowSelectionChange: setRowSelection,
43025
- getCoreRowModel: getCoreRowModel(),
43026
- manualPagination: true,
43027
- debugTable: true,
43028
- initialState: {
43006
+ }, enableRowSelection, onRowSelectionChange: setRowSelection, getCoreRowModel: getCoreRowModel(), manualPagination: true, getRowId: (row) => row === null || row === void 0 ? void 0 : row.id, initialState: {
43029
43007
  columnPinning: {
43030
43008
  left: defaultPinnedColumns,
43031
43009
  },
43032
- },
43033
- });
43010
+ } }));
43034
43011
  const totalRowsOnPage = table.getRowModel().rows.length;
43035
43012
  const hasPaginationProps = !lodashExports.isNil(currentPage) &&
43036
43013
  !lodashExports.isNil(rowCount) &&
@@ -43047,7 +43024,7 @@ function TanstackTable({ columns: defaultColumns, data, className, currentPage,
43047
43024
  ? (_a = error === null || error === void 0 ? void 0 : error.errorMessage) !== null && _a !== void 0 ? _a : 'There was an error isLoading the data.'
43048
43025
  : 'No results found.' }) }) }));
43049
43026
  }
43050
- return (jsxRuntime.jsx(TableBody, { table: table, onClickRow: onClickRow, isLoading: isLoading, columnsLength: columns.length, isClickedRow: isClickedRow, setIsClickedRow: setIsClickedRow }));
43027
+ return (jsxRuntime.jsx(TableBody, { table: table, onRowClick: onRowClick, isLoading: isLoading, columnsLength: columns.length, activeRows: activeRows }));
43051
43028
  };
43052
43029
  return (jsxRuntime.jsxs("div", { className: "tanstack-table__outer-container", children: [jsxRuntime.jsxs("div", { className: "tanstack-table__container", children: [jsxRuntime.jsxs("table", { className: classNames('tanstack-table', className, {
43053
43030
  'is-Loading': isLoading,