@indico-data/design-system 3.0.2 → 3.0.3

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.
@@ -9,5 +9,6 @@ export interface CheckboxProps {
9
9
  onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
10
10
  isDisabled?: boolean;
11
11
  defaultChecked?: boolean;
12
+ className?: string;
12
13
  }
13
14
  export declare const Checkbox: React.ForwardRefExoticComponent<Omit<CheckboxProps, "ref"> & React.RefAttributes<HTMLInputElement>>;
@@ -36,6 +36,7 @@ export type Props<T extends object> = {
36
36
  clearFilters?: () => void;
37
37
  hasFilters?: boolean;
38
38
  isLoading?: boolean;
39
+ isLoadingMessage?: string;
39
40
  defaultPinnedColumns?: string[];
40
41
  onClickRow?: ((row: Row<T>) => void) | null;
41
42
  onRowClick?: (row: T) => void;
@@ -1,4 +1,4 @@
1
1
  import { Props } from './TankstackTable.types';
2
- export declare function TanstackTable<T extends object>({ columns: defaultColumns, data, className, currentPage, rowCount, rowsPerPage, onChangePage, totalEntriesText, TableActions, error, enableRowSelection, clearFilters, hasFilters, showPagination, isLoading, defaultPinnedColumns, onRowClick, activeRows, isStriped, actionBarClassName, defaultSorting, ...rest }: Props<T & {
2
+ export declare function TanstackTable<T extends object>({ columns: defaultColumns, data, className, currentPage, rowCount, rowsPerPage, onChangePage, totalEntriesText, TableActions, error, enableRowSelection, clearFilters, hasFilters, showPagination, isLoading, isLoadingMessage, defaultPinnedColumns, onRowClick, activeRows, isStriped, actionBarClassName, defaultSorting, ...rest }: Props<T & {
3
3
  id: string;
4
4
  }>): import("react/jsx-runtime").JSX.Element;
@@ -4,8 +4,6 @@ export type Props<T> = {
4
4
  onRowClick?: ((row: T & {
5
5
  id: string;
6
6
  }) => void) | null | undefined;
7
- isLoading: boolean;
8
- columnsLength: number;
9
7
  activeRows: string[];
10
8
  };
11
- export declare const TableBody: <T>({ table, onRowClick, isLoading, columnsLength, activeRows, }: Props<T>) => import("react/jsx-runtime").JSX.Element;
9
+ export declare const TableBody: <T>({ table, onRowClick, activeRows }: Props<T>) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,6 @@
1
+ import { ColumnDef } from '@tanstack/react-table';
2
+ export type Props<T> = {
3
+ columns: ColumnDef<T>[];
4
+ message?: string;
5
+ };
6
+ export declare const TableLoading: <T>({ columns, message }: Props<T>) => import("react/jsx-runtime").JSX.Element;
package/lib/index.css CHANGED
@@ -2459,23 +2459,6 @@ body div[class*=select__single-value] {
2459
2459
  --pf-tanstack-table-pagination-font-color: var(--pf-tanstack-table-font-color);
2460
2460
  }
2461
2461
 
2462
- .tanstack-table__action-bar-test {
2463
- left: 20% !important;
2464
- }
2465
-
2466
- .tanstack-table__action-bar-docs {
2467
- bottom: unset !important;
2468
- top: 50% !important;
2469
- transform: translate(-50%, -50%) !important;
2470
- }
2471
-
2472
- .tanstack-table__column.is-pinned {
2473
- opacity: 1;
2474
- }
2475
- .tanstack-table__column.is-not-pinned {
2476
- opacity: 0.3;
2477
- }
2478
-
2479
2462
  .tanstack-table__action-bar {
2480
2463
  position: fixed;
2481
2464
  bottom: 170px;
@@ -2516,10 +2499,10 @@ body div[class*=select__single-value] {
2516
2499
  .tanstack-table__no-results__text {
2517
2500
  font-size: var(--pf-line-height-md);
2518
2501
  font-weight: var(--pf-font-weight-medium);
2519
- color: var(--pf-primary-color-50);
2502
+ color: var(--pf-tanstack-table-font-color);
2520
2503
  }
2521
2504
  .tanstack-table__no-results__text span {
2522
- color: var(--pf-white-color);
2505
+ color: var(--pf-tanstack-table-font-color);
2523
2506
  cursor: pointer;
2524
2507
  }
2525
2508
  .tanstack-table__no-results__text span:hover {
@@ -2582,11 +2565,6 @@ body div[class*=select__single-value] {
2582
2565
  .tanstack-table.is-striped .tanstack-table__tbody tr:nth-child(odd) td {
2583
2566
  background-color: var(--pf-tanstack-table-stripe-color);
2584
2567
  }
2585
- .tanstack-table .is-loading {
2586
- border: var(--pf-border-thin) solid var(--pf-border-color-primary);
2587
- height: 350px;
2588
- width: 100%;
2589
- }
2590
2568
  .tanstack-table__thead {
2591
2569
  position: sticky;
2592
2570
  top: 0;
package/lib/index.d.ts CHANGED
@@ -311,6 +311,7 @@ interface CheckboxProps {
311
311
  onChange: (e: React$1.ChangeEvent<HTMLInputElement>) => void;
312
312
  isDisabled?: boolean;
313
313
  defaultChecked?: boolean;
314
+ className?: string;
314
315
  }
315
316
  declare const Checkbox: React$1.ForwardRefExoticComponent<Omit<CheckboxProps, "ref"> & React$1.RefAttributes<HTMLInputElement>>;
316
317
 
@@ -617,6 +618,7 @@ type Props<T extends object> = {
617
618
  clearFilters?: () => void;
618
619
  hasFilters?: boolean;
619
620
  isLoading?: boolean;
621
+ isLoadingMessage?: string;
620
622
  defaultPinnedColumns?: string[];
621
623
  onClickRow?: ((row: Row$1<T>) => void) | null;
622
624
  onRowClick?: (row: T) => void;
@@ -627,7 +629,7 @@ type Props<T extends object> = {
627
629
  defaultSorting?: SortingState;
628
630
  } & PaginationProps$1;
629
631
 
630
- declare function TanstackTable<T extends object>({ columns: defaultColumns, data, className, currentPage, rowCount, rowsPerPage, onChangePage, totalEntriesText, TableActions, error, enableRowSelection, clearFilters, hasFilters, showPagination, isLoading, defaultPinnedColumns, onRowClick, activeRows, isStriped, actionBarClassName, defaultSorting, ...rest }: Props<T & {
632
+ declare function TanstackTable<T extends object>({ columns: defaultColumns, data, className, currentPage, rowCount, rowsPerPage, onChangePage, totalEntriesText, TableActions, error, enableRowSelection, clearFilters, hasFilters, showPagination, isLoading, isLoadingMessage, defaultPinnedColumns, onRowClick, activeRows, isStriped, actionBarClassName, defaultSorting, ...rest }: Props<T & {
631
633
  id: string;
632
634
  }>): react_jsx_runtime.JSX.Element;
633
635
 
package/lib/index.esm.css CHANGED
@@ -2459,23 +2459,6 @@ body div[class*=select__single-value] {
2459
2459
  --pf-tanstack-table-pagination-font-color: var(--pf-tanstack-table-font-color);
2460
2460
  }
2461
2461
 
2462
- .tanstack-table__action-bar-test {
2463
- left: 20% !important;
2464
- }
2465
-
2466
- .tanstack-table__action-bar-docs {
2467
- bottom: unset !important;
2468
- top: 50% !important;
2469
- transform: translate(-50%, -50%) !important;
2470
- }
2471
-
2472
- .tanstack-table__column.is-pinned {
2473
- opacity: 1;
2474
- }
2475
- .tanstack-table__column.is-not-pinned {
2476
- opacity: 0.3;
2477
- }
2478
-
2479
2462
  .tanstack-table__action-bar {
2480
2463
  position: fixed;
2481
2464
  bottom: 170px;
@@ -2516,10 +2499,10 @@ body div[class*=select__single-value] {
2516
2499
  .tanstack-table__no-results__text {
2517
2500
  font-size: var(--pf-line-height-md);
2518
2501
  font-weight: var(--pf-font-weight-medium);
2519
- color: var(--pf-primary-color-50);
2502
+ color: var(--pf-tanstack-table-font-color);
2520
2503
  }
2521
2504
  .tanstack-table__no-results__text span {
2522
- color: var(--pf-white-color);
2505
+ color: var(--pf-tanstack-table-font-color);
2523
2506
  cursor: pointer;
2524
2507
  }
2525
2508
  .tanstack-table__no-results__text span:hover {
@@ -2582,11 +2565,6 @@ body div[class*=select__single-value] {
2582
2565
  .tanstack-table.is-striped .tanstack-table__tbody tr:nth-child(odd) td {
2583
2566
  background-color: var(--pf-tanstack-table-stripe-color);
2584
2567
  }
2585
- .tanstack-table .is-loading {
2586
- border: var(--pf-border-thin) solid var(--pf-border-color-primary);
2587
- height: 350px;
2588
- width: 100%;
2589
- }
2590
2568
  .tanstack-table__thead {
2591
2569
  position: sticky;
2592
2570
  top: 0;
package/lib/index.esm.js CHANGED
@@ -5779,8 +5779,8 @@ const Radio = React__default.forwardRef((_a, ref) => {
5779
5779
  });
5780
5780
 
5781
5781
  const Checkbox = React__default.forwardRef((_a, ref) => {
5782
- var { id, label, name, value, onChange, isDisabled, isChecked = false } = _a, rest = __rest(_a, ["id", "label", "name", "value", "onChange", "isDisabled", "isChecked"]);
5783
- return (jsx("div", { className: "form-control", children: jsxs("div", { className: "checkbox-wrapper", children: [jsx("input", Object.assign({ "data-testid": `form-checkbox-input-${name}`, className: "checkbox-input", type: "checkbox", id: id, name: name, value: value, checked: isChecked, disabled: isDisabled, ref: ref, onChange: onChange, tabIndex: 0, "aria-describedby": id, "aria-label": label }, rest)), jsx("label", { htmlFor: id, className: "checkbox-input-label", "data-testid": `label-checkbox-input-${name}`, children: label })] }) }));
5782
+ var { id, label, name, value, onChange, isDisabled, isChecked = false, className } = _a, rest = __rest(_a, ["id", "label", "name", "value", "onChange", "isDisabled", "isChecked", "className"]);
5783
+ return (jsx("div", { className: "form-control", children: jsxs("div", { className: "checkbox-wrapper", children: [jsx("input", Object.assign({ "data-testid": `form-checkbox-input-${name}`, className: classNames('checkbox-input', className), type: "checkbox", id: id, name: name, value: value, checked: isChecked, disabled: isDisabled, ref: ref, onChange: onChange, tabIndex: 0, "aria-describedby": id, "aria-label": label }, rest)), jsx("label", { htmlFor: id, className: "checkbox-input-label", "data-testid": `label-checkbox-input-${name}`, children: label })] }) }));
5784
5784
  });
5785
5785
 
5786
5786
  const Toggle = React__default.forwardRef((_a, ref) => {
@@ -41453,35 +41453,37 @@ const TableHeader = forwardRef(({ table }, ref) => {
41453
41453
  }) }, headerGroup.id))) }));
41454
41454
  });
41455
41455
 
41456
+ const TableBody = ({ table, onRowClick, activeRows }) => {
41457
+ return (jsx(Fragment, { children: table.getRowModel().rows.map((row) => (jsx("tr", { className: classNames('tanstack-table__tbody__tr', {
41458
+ 'is-selected': row.getIsSelected(),
41459
+ 'show-hover': !!onRowClick,
41460
+ 'is-clicked': activeRows.includes(row.id), // Checkbox Is clicked
41461
+ }), children: row.getVisibleCells().map((cell) => {
41462
+ var _a, _b, _c, _d, _e, _f, _g, _h;
41463
+ const { columnDef } = cell.column;
41464
+ return (jsx("td", { className: classNames('tanstack-table__tbody__td', {
41465
+ '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),
41466
+ }), 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: () => {
41467
+ var _a, _b, _c;
41468
+ // if the cell is not preventRowSelection, then we can click the row
41469
+ 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)) {
41470
+ onRowClick === null || onRowClick === void 0 ? void 0 : onRowClick(row);
41471
+ }
41472
+ }, children: flexRender(columnDef.cell, cell.getContext()) }, cell.id));
41473
+ }) }, row.id))) }));
41474
+ };
41475
+
41456
41476
  function CirclePulse(_a) {
41457
41477
  var { size = 'md', className } = _a, rest = __rest(_a, ["size", "className"]);
41458
41478
  return (jsx("div", Object.assign({ className: `circle-pulse circle-pulse-${size} ${className}`, "aria-hidden": true }, rest)));
41459
41479
  }
41460
41480
 
41461
- const TableBody = ({ table, onRowClick, isLoading, columnsLength, activeRows, }) => {
41462
- return (jsxs(Fragment, { children: [table.getRowModel().rows.map((row) => (jsx("tr", { className: classNames('tanstack-table__tbody__tr', {
41463
- 'is-selected': row.getIsSelected(),
41464
- 'show-hover': !!onRowClick,
41465
- 'is-clicked': activeRows.includes(row.id), // Checkbox Is clicked
41466
- }), children: row.getVisibleCells().map((cell) => {
41467
- var _a, _b, _c, _d, _e, _f, _g, _h;
41468
- const { columnDef } = cell.column;
41469
- return (jsx("td", { className: classNames('tanstack-table__tbody__td', {
41470
- '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),
41471
- }), 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: () => {
41472
- var _a, _b, _c;
41473
- // if the cell is not preventRowSelection, then we can click the row
41474
- 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)) {
41475
- onRowClick === null || onRowClick === void 0 ? void 0 : onRowClick(row);
41476
- }
41477
- }, children: flexRender(columnDef.cell, cell.getContext()) }, cell.id));
41478
- }) }, row.id))), isLoading && (jsx("tr", { className: "tanstack-table__tbody__tr", children: jsxs("td", { className: classNames('tanstack-table__centered-row', {
41479
- 'is-loading': isLoading,
41480
- }), colSpan: columnsLength, children: [jsx("h2", { className: "mb-12", children: "Table is loading..." }), jsx(CirclePulse, { "data-testid": "loading-indicator" })] }) }))] }));
41481
+ const TableLoading = ({ columns, message }) => {
41482
+ return (jsx("tr", { className: "tanstack-table__tbody__tr ", children: jsxs("td", { className: "tanstack-table__centered-row pa-6", colSpan: columns.length, children: [jsx("h2", { className: "my-12", children: message }), jsx(CirclePulse, { "data-testid": "loading-indicator", className: "mb-14" })] }) }));
41481
41483
  };
41482
41484
 
41483
41485
  function TanstackTable(_a) {
41484
- var { columns: defaultColumns, data, className, currentPage, rowCount, rowsPerPage = 1000, onChangePage, totalEntriesText, TableActions, error, enableRowSelection = true, clearFilters, hasFilters, showPagination = true, isLoading = false, defaultPinnedColumns, onRowClick, activeRows = [], isStriped = true, actionBarClassName, defaultSorting } = _a, rest = __rest(_a, ["columns", "data", "className", "currentPage", "rowCount", "rowsPerPage", "onChangePage", "totalEntriesText", "TableActions", "error", "enableRowSelection", "clearFilters", "hasFilters", "showPagination", "isLoading", "defaultPinnedColumns", "onRowClick", "activeRows", "isStriped", "actionBarClassName", "defaultSorting"]);
41486
+ var { columns: defaultColumns, data, className, currentPage, rowCount, rowsPerPage = 1000, onChangePage, totalEntriesText, TableActions, error, enableRowSelection = true, clearFilters, hasFilters, showPagination = true, isLoading = false, isLoadingMessage = 'Table is loading...', defaultPinnedColumns, onRowClick, activeRows = [], isStriped = true, actionBarClassName, defaultSorting } = _a, rest = __rest(_a, ["columns", "data", "className", "currentPage", "rowCount", "rowsPerPage", "onChangePage", "totalEntriesText", "TableActions", "error", "enableRowSelection", "clearFilters", "hasFilters", "showPagination", "isLoading", "isLoadingMessage", "defaultPinnedColumns", "onRowClick", "activeRows", "isStriped", "actionBarClassName", "defaultSorting"]);
41485
41487
  const { columns, defaultData, windowWidth, rowSelection, // This refers to the checkboxes.
41486
41488
  setRowSelection, formattedColumns, setFormattedColumns, } = useTanstackTable({
41487
41489
  defaultColumns,
@@ -41524,10 +41526,12 @@ function TanstackTable(_a) {
41524
41526
  ? (_a = error === null || error === void 0 ? void 0 : error.errorMessage) !== null && _a !== void 0 ? _a : 'There was an error isLoading the data.'
41525
41527
  : 'No results found.' }) }) }));
41526
41528
  }
41527
- return (jsx(TableBody, { table: table, onRowClick: onRowClick, isLoading: isLoading, columnsLength: columns.length, activeRows: activeRows }));
41529
+ if (isLoading) {
41530
+ return jsx(TableLoading, { columns: columns, message: isLoadingMessage });
41531
+ }
41532
+ return (jsx(TableBody, { table: table, onRowClick: onRowClick, activeRows: activeRows }));
41528
41533
  };
41529
41534
  return (jsxs("div", { className: "tanstack-table__outer-container", children: [jsxs("div", { className: "tanstack-table__container", children: [jsxs("table", { className: classNames('tanstack-table', className, {
41530
- 'is-Loading': isLoading,
41531
41535
  'is-striped': isStriped,
41532
41536
  }), children: [jsx("thead", { className: "tanstack-table__thead", children: jsx(TableHeader, { table: table, ref: thRefs }) }), jsx("tbody", { className: "tanstack-table__tbody", children: renderBody() })] }), hasSelectedRows && (jsx(ActionBar, { table: table, TableActions: TableActions, className: actionBarClassName }))] }), shouldRenderPagination ? (jsx(TablePagination, { currentPage: currentPage, rowCount: rowCount, onChangePage: onChangePage, rowsPerPage: rowsPerPage, totalEntriesText: totalEntriesText !== null && totalEntriesText !== void 0 ? totalEntriesText : `${totalRowsOnPage} of ${rowCount} entries` })) : null] }));
41533
41537
  }