@indico-data/design-system 3.0.2 → 3.0.4
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/lib/components/forms/checkbox/Checkbox.d.ts +1 -0
- package/lib/components/tanstackTable/TankstackTable.types.d.ts +1 -0
- package/lib/components/tanstackTable/TanstackTable.d.ts +1 -1
- package/lib/components/tanstackTable/components/TableBody/TableBody.d.ts +1 -3
- package/lib/components/tanstackTable/components/TableLoading/TableLoading.d.ts +6 -0
- package/lib/index.css +5 -24
- package/lib/index.d.ts +3 -1
- package/lib/index.esm.css +5 -24
- package/lib/index.esm.js +35 -28
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +35 -28
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/forms/checkbox/Checkbox.tsx +7 -2
- package/src/components/forms/input/Input.tsx +1 -0
- package/src/components/forms/input/styles/Input.scss +3 -0
- package/src/components/pagination/Pagination.tsx +2 -2
- package/src/components/tanstackTable/TankstackTable.types.ts +1 -0
- package/src/components/tanstackTable/TanstackTable.stories.tsx +10 -0
- package/src/components/tanstackTable/TanstackTable.tsx +11 -4
- package/src/components/tanstackTable/components/NoResults/NoResults.scss +2 -2
- package/src/components/tanstackTable/components/TableBody/TableBody.tsx +1 -25
- package/src/components/tanstackTable/components/TableLoading/TableLoading.tsx +18 -0
- package/src/components/tanstackTable/mock-data/table-configuration.tsx +6 -7
- package/src/components/tanstackTable/styles/table.scss +0 -7
- package/src/components/tanstackTable/styles/test.scss +0 -19
package/lib/index.js
CHANGED
|
@@ -5498,6 +5498,7 @@ const Input = React__namespace.default.forwardRef((_a, ref) => {
|
|
|
5498
5498
|
onChange === null || onChange === void 0 ? void 0 : onChange({ target: { value: '' } });
|
|
5499
5499
|
};
|
|
5500
5500
|
const inputClasses = classNames('input', {
|
|
5501
|
+
'is-clearable': isClearable,
|
|
5501
5502
|
error: hasErrors,
|
|
5502
5503
|
'input--has-icon': iconName,
|
|
5503
5504
|
}, className);
|
|
@@ -5540,7 +5541,7 @@ const Pagination = (_a) => {
|
|
|
5540
5541
|
const isNextButtonDisabled = currentPage === totalPages;
|
|
5541
5542
|
const isPreviousButtonDisabled = currentPage === 1;
|
|
5542
5543
|
const hasError = Number(inputValue) > totalPages || Number(inputValue) < 1;
|
|
5543
|
-
return (jsxRuntime.jsx("div", Object.assign({ className: classes }, rest, { children: jsxRuntime.jsx(Container, { children: jsxRuntime.jsxs(Row, { gutterWidth: 12, align: "center", children: [jsxRuntime.jsx(Col, { xs: "content", children: jsxRuntime.jsx("div", { className: "pagination__previous", children: jsxRuntime.jsx(Button$1, { "data-testid": "pagination-previous-button", ariaLabel: "Previous Page", variant: "link", onClick: handlePreviousPage, iconLeft: "chevron-left", isDisabled: isPreviousButtonDisabled }) }) }), jsxRuntime.jsx(Col, { xs: "content", children: jsxRuntime.jsx("div", { className: "pagination__current-page", children: jsxRuntime.jsx(LabeledInput, { "data-testid": "pagination-current-page-input", className: classNames('pagination__current-page-input', {
|
|
5544
|
+
return (jsxRuntime.jsx("div", Object.assign({ className: classes }, rest, { children: jsxRuntime.jsx(Container, { children: jsxRuntime.jsxs(Row, { gutterWidth: 12, align: "center", children: [jsxRuntime.jsx(Col, { xs: "content", children: jsxRuntime.jsx("div", { className: "pagination__previous", children: jsxRuntime.jsx(Button$1, { "data-testid": "pagination-previous-button", ariaLabel: "Previous Page", variant: "link", onClick: handlePreviousPage, iconLeft: "chevron-left", isDisabled: isPreviousButtonDisabled || totalPages === 0 }) }) }), jsxRuntime.jsx(Col, { xs: "content", children: jsxRuntime.jsx("div", { className: "pagination__current-page", children: jsxRuntime.jsx(LabeledInput, { "data-testid": "pagination-current-page-input", className: classNames('pagination__current-page-input', {
|
|
5544
5545
|
'has-error': hasError,
|
|
5545
5546
|
}), value: totalPages === 0 ? '0' : inputValue, name: "currentPage", label: "Current Page", hasHiddenLabel: true, onKeyDown: (e) => {
|
|
5546
5547
|
if (e.key === 'Enter') {
|
|
@@ -5552,7 +5553,7 @@ const Pagination = (_a) => {
|
|
|
5552
5553
|
if (value === '' || /^\d*$/.test(value)) {
|
|
5553
5554
|
setInputValue(value);
|
|
5554
5555
|
}
|
|
5555
|
-
}, onBlur: (e) => validateAndUpdatePage(e.currentTarget.value) }) }) }), jsxRuntime.jsx(Col, { xs: "content", children: jsxRuntime.jsx("p", { className: "pagination__page-total", children: totalPagesText }) }), jsxRuntime.jsx(Col, { xs: "content", children: jsxRuntime.jsx("div", { className: "pagination__next", children: jsxRuntime.jsx(Button$1, { "data-testid": "pagination-next-button", ariaLabel: "Next Page", variant: "link", onClick: handleNextPage, iconLeft: "chevron-right", isDisabled: isNextButtonDisabled }) }) })] }) }) })));
|
|
5556
|
+
}, onBlur: (e) => validateAndUpdatePage(e.currentTarget.value) }) }) }), jsxRuntime.jsx(Col, { xs: "content", children: jsxRuntime.jsx("p", { className: "pagination__page-total", children: totalPagesText }) }), jsxRuntime.jsx(Col, { xs: "content", children: jsxRuntime.jsx("div", { className: "pagination__next", children: jsxRuntime.jsx(Button$1, { "data-testid": "pagination-next-button", ariaLabel: "Next Page", variant: "link", onClick: handleNextPage, iconLeft: "chevron-right", isDisabled: isNextButtonDisabled || totalPages === 0 }) }) })] }) }) })));
|
|
5556
5557
|
};
|
|
5557
5558
|
|
|
5558
5559
|
const TablePagination$1 = ({ rowsPerPage, rowCount, onChangePage, currentPage, totalEntriesText, }) => {
|
|
@@ -5804,8 +5805,8 @@ const Radio = React__namespace.default.forwardRef((_a, ref) => {
|
|
|
5804
5805
|
});
|
|
5805
5806
|
|
|
5806
5807
|
const Checkbox = React__namespace.default.forwardRef((_a, ref) => {
|
|
5807
|
-
var { id, label, name, value, onChange, isDisabled, isChecked = false } = _a, rest = __rest(_a, ["id", "label", "name", "value", "onChange", "isDisabled", "isChecked"]);
|
|
5808
|
-
return (jsxRuntime.jsx("div", { className: "form-control", children: jsxRuntime.jsxs("div", { className: "checkbox-wrapper", children: [jsxRuntime.jsx("input", Object.assign({ "data-testid": `form-checkbox-input-${name}`, className:
|
|
5808
|
+
var { id, label, name, value, onChange, isDisabled, isChecked = false, className } = _a, rest = __rest(_a, ["id", "label", "name", "value", "onChange", "isDisabled", "isChecked", "className"]);
|
|
5809
|
+
return (jsxRuntime.jsx("div", { className: "form-control", children: jsxRuntime.jsxs("div", { className: "checkbox-wrapper", children: [jsxRuntime.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)), jsxRuntime.jsx("label", { htmlFor: id, className: "checkbox-input-label", "data-testid": `label-checkbox-input-${name}`, children: label })] }) }));
|
|
5809
5810
|
});
|
|
5810
5811
|
|
|
5811
5812
|
const Toggle = React__namespace.default.forwardRef((_a, ref) => {
|
|
@@ -41478,35 +41479,37 @@ const TableHeader = React.forwardRef(({ table }, ref) => {
|
|
|
41478
41479
|
}) }, headerGroup.id))) }));
|
|
41479
41480
|
});
|
|
41480
41481
|
|
|
41482
|
+
const TableBody = ({ table, onRowClick, activeRows }) => {
|
|
41483
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: table.getRowModel().rows.map((row) => (jsxRuntime.jsx("tr", { className: classNames('tanstack-table__tbody__tr', {
|
|
41484
|
+
'is-selected': row.getIsSelected(),
|
|
41485
|
+
'show-hover': !!onRowClick,
|
|
41486
|
+
'is-clicked': activeRows.includes(row.id), // Checkbox Is clicked
|
|
41487
|
+
}), children: row.getVisibleCells().map((cell) => {
|
|
41488
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
41489
|
+
const { columnDef } = cell.column;
|
|
41490
|
+
return (jsxRuntime.jsx("td", { className: classNames('tanstack-table__tbody__td', {
|
|
41491
|
+
'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),
|
|
41492
|
+
}), 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: () => {
|
|
41493
|
+
var _a, _b, _c;
|
|
41494
|
+
// if the cell is not preventRowSelection, then we can click the row
|
|
41495
|
+
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)) {
|
|
41496
|
+
onRowClick === null || onRowClick === void 0 ? void 0 : onRowClick(row);
|
|
41497
|
+
}
|
|
41498
|
+
}, children: flexRender(columnDef.cell, cell.getContext()) }, cell.id));
|
|
41499
|
+
}) }, row.id))) }));
|
|
41500
|
+
};
|
|
41501
|
+
|
|
41481
41502
|
function CirclePulse(_a) {
|
|
41482
41503
|
var { size = 'md', className } = _a, rest = __rest(_a, ["size", "className"]);
|
|
41483
41504
|
return (jsxRuntime.jsx("div", Object.assign({ className: `circle-pulse circle-pulse-${size} ${className}`, "aria-hidden": true }, rest)));
|
|
41484
41505
|
}
|
|
41485
41506
|
|
|
41486
|
-
const
|
|
41487
|
-
return (jsxRuntime.
|
|
41488
|
-
'is-selected': row.getIsSelected(),
|
|
41489
|
-
'show-hover': !!onRowClick,
|
|
41490
|
-
'is-clicked': activeRows.includes(row.id), // Checkbox Is clicked
|
|
41491
|
-
}), children: row.getVisibleCells().map((cell) => {
|
|
41492
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
41493
|
-
const { columnDef } = cell.column;
|
|
41494
|
-
return (jsxRuntime.jsx("td", { className: classNames('tanstack-table__tbody__td', {
|
|
41495
|
-
'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),
|
|
41496
|
-
}), 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: () => {
|
|
41497
|
-
var _a, _b, _c;
|
|
41498
|
-
// if the cell is not preventRowSelection, then we can click the row
|
|
41499
|
-
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)) {
|
|
41500
|
-
onRowClick === null || onRowClick === void 0 ? void 0 : onRowClick(row);
|
|
41501
|
-
}
|
|
41502
|
-
}, children: flexRender(columnDef.cell, cell.getContext()) }, cell.id));
|
|
41503
|
-
}) }, row.id))), isLoading && (jsxRuntime.jsx("tr", { className: "tanstack-table__tbody__tr", children: jsxRuntime.jsxs("td", { className: classNames('tanstack-table__centered-row', {
|
|
41504
|
-
'is-loading': isLoading,
|
|
41505
|
-
}), colSpan: columnsLength, children: [jsxRuntime.jsx("h2", { className: "mb-12", children: "Table is loading..." }), jsxRuntime.jsx(CirclePulse, { "data-testid": "loading-indicator" })] }) }))] }));
|
|
41507
|
+
const TableLoading = ({ columns, message }) => {
|
|
41508
|
+
return (jsxRuntime.jsx("tr", { className: "tanstack-table__tbody__tr ", children: jsxRuntime.jsxs("td", { className: "tanstack-table__centered-row pa-6", colSpan: columns.length, children: [jsxRuntime.jsx("h2", { className: "my-12", children: message }), jsxRuntime.jsx(CirclePulse, { "data-testid": "loading-indicator", className: "mb-14" })] }) }));
|
|
41506
41509
|
};
|
|
41507
41510
|
|
|
41508
41511
|
function TanstackTable(_a) {
|
|
41509
|
-
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"]);
|
|
41512
|
+
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"]);
|
|
41510
41513
|
const { columns, defaultData, windowWidth, rowSelection, // This refers to the checkboxes.
|
|
41511
41514
|
setRowSelection, formattedColumns, setFormattedColumns, } = useTanstackTable({
|
|
41512
41515
|
defaultColumns,
|
|
@@ -41549,12 +41552,16 @@ function TanstackTable(_a) {
|
|
|
41549
41552
|
? (_a = error === null || error === void 0 ? void 0 : error.errorMessage) !== null && _a !== void 0 ? _a : 'There was an error isLoading the data.'
|
|
41550
41553
|
: 'No results found.' }) }) }));
|
|
41551
41554
|
}
|
|
41552
|
-
|
|
41555
|
+
if (isLoading) {
|
|
41556
|
+
return jsxRuntime.jsx(TableLoading, { columns: columns, message: isLoadingMessage });
|
|
41557
|
+
}
|
|
41558
|
+
return (jsxRuntime.jsx(TableBody, { table: table, onRowClick: onRowClick, activeRows: activeRows }));
|
|
41553
41559
|
};
|
|
41554
41560
|
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, {
|
|
41555
|
-
'is-Loading': isLoading,
|
|
41556
41561
|
'is-striped': isStriped,
|
|
41557
|
-
}), children: [jsxRuntime.jsx("thead", { className: "tanstack-table__thead", children: jsxRuntime.jsx(TableHeader, { table: table, ref: thRefs }) }), jsxRuntime.jsx("tbody", { className: "tanstack-table__tbody", children: renderBody() })] }), hasSelectedRows && (jsxRuntime.jsx(ActionBar, { table: table, TableActions: TableActions, className: actionBarClassName }))] }), shouldRenderPagination ? (jsxRuntime.jsx(TablePagination, { currentPage: currentPage, rowCount: rowCount, onChangePage: onChangePage, rowsPerPage: rowsPerPage, totalEntriesText: totalEntriesText !== null && totalEntriesText !== void 0 ? totalEntriesText :
|
|
41562
|
+
}), children: [jsxRuntime.jsx("thead", { className: "tanstack-table__thead", children: jsxRuntime.jsx(TableHeader, { table: table, ref: thRefs }) }), jsxRuntime.jsx("tbody", { className: "tanstack-table__tbody", children: renderBody() })] }), hasSelectedRows && (jsxRuntime.jsx(ActionBar, { table: table, TableActions: TableActions, className: actionBarClassName }))] }), shouldRenderPagination ? (jsxRuntime.jsx(TablePagination, { currentPage: currentPage, rowCount: rowCount, onChangePage: onChangePage, rowsPerPage: rowsPerPage, totalEntriesText: (totalEntriesText !== null && totalEntriesText !== void 0 ? totalEntriesText : rowCount === 1)
|
|
41563
|
+
? '1 entry'
|
|
41564
|
+
: `${totalRowsOnPage} of ${rowCount} entries` })) : null] }));
|
|
41558
41565
|
}
|
|
41559
41566
|
|
|
41560
41567
|
/**
|