mui-datatables-updated 1.0.0 → 1.0.2

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.js ADDED
@@ -0,0 +1,363 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ var Checkbox = require('@mui/material/Checkbox');
5
+ var Paper = require('@mui/material/Paper');
6
+ var Table = require('@mui/material/Table');
7
+ var TableBody = require('@mui/material/TableBody');
8
+ var TableCell = require('@mui/material/TableCell');
9
+ var TableContainer = require('@mui/material/TableContainer');
10
+ var TablePagination = require('@mui/material/TablePagination');
11
+ var TableRow = require('@mui/material/TableRow');
12
+ var React = require('react');
13
+ var reactToPrint = require('react-to-print');
14
+ var Box = require('@mui/material/Box');
15
+ var TableHead = require('@mui/material/TableHead');
16
+ var TableSortLabel = require('@mui/material/TableSortLabel');
17
+ var utils = require('@mui/utils');
18
+ var iconsMaterial = require('@mui/icons-material');
19
+ var FilterListIcon = require('@mui/icons-material/FilterList');
20
+ var SearchIcon = require('@mui/icons-material/Search');
21
+ var material = require('@mui/material');
22
+ var styles = require('@mui/material/styles');
23
+
24
+ /******************************************************************************
25
+ Copyright (c) Microsoft Corporation.
26
+
27
+ Permission to use, copy, modify, and/or distribute this software for any
28
+ purpose with or without fee is hereby granted.
29
+
30
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
31
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
32
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
33
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
34
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
35
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
36
+ PERFORMANCE OF THIS SOFTWARE.
37
+ ***************************************************************************** */
38
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
39
+
40
+
41
+ function __rest(s, e) {
42
+ var t = {};
43
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
44
+ t[p] = s[p];
45
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
46
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
47
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
48
+ t[p[i]] = s[p[i]];
49
+ }
50
+ return t;
51
+ }
52
+
53
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
54
+ var e = new Error(message);
55
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
56
+ };
57
+
58
+ function EnhancedTableHead({ onSelectAllClick, order, orderBy, numSelected, rowCount, onRequestSort, columns, deactivateSelectAll, }) {
59
+ const createSortHandler = (property) => (event) => {
60
+ onRequestSort(event, property);
61
+ };
62
+ return (jsxRuntime.jsx(TableHead, { children: jsxRuntime.jsxs(TableRow, { children: [!deactivateSelectAll &&
63
+ jsxRuntime.jsx(TableCell, { padding: "checkbox", children: jsxRuntime.jsx(Checkbox, { color: "primary", indeterminate: numSelected > 0 && numSelected < rowCount, checked: rowCount > 0 && numSelected === rowCount, onChange: onSelectAllClick, inputProps: {
64
+ 'aria-label': 'select all items',
65
+ } }) }), columns.map((column) => {
66
+ var _a;
67
+ return (jsxRuntime.jsx(TableCell, { padding: 'normal', sortDirection: orderBy === column.name ? order : false, children: ((_a = column.options) === null || _a === undefined ? undefined : _a.sort) !== false ? (jsxRuntime.jsxs(TableSortLabel, { active: orderBy === column.name, direction: orderBy === column.name ? order : 'asc', onClick: createSortHandler(column.name), sx: { fontWeight: 'bold' }, children: [column.label, orderBy === column.name ? (jsxRuntime.jsx(Box, { component: "span", sx: utils.visuallyHidden, children: order === 'desc' ? 'sorted descending' : 'sorted ascending' })) : null] })) : (jsxRuntime.jsx("span", { style: { fontWeight: 700 }, children: column.label })) }, String(column.name)));
68
+ })] }) }));
69
+ }
70
+
71
+ function EnhancedTableToolbar(props) {
72
+ var _a, _b, _c, _d, _e, _f, _g, _h;
73
+ const { title, numSelected, selected, onFilterChange, onSearch, printFn, columns, CustomToolbar, CustomSelectedToolbar, data, options } = props;
74
+ const [anchorEl, setAnchorEl] = React.useState(null);
75
+ const [filters, setFilters] = React.useState([]);
76
+ const [filterConfig, setFilterConfig] = React.useState([]);
77
+ // rest value to force re-render of filters
78
+ const [resetCounter, setResetCounter] = React.useState(0);
79
+ const [openSearch, setOpenSearch] = React.useState(false);
80
+ function downloadCSV(data, filename = "data.csv") {
81
+ // Base case
82
+ if (data.length === 0) {
83
+ console.warn("No data to export.");
84
+ return;
85
+ }
86
+ // Create CSV content
87
+ const headers = Object.keys(data[0]);
88
+ const csvRows = data.map(obj => headers.map(field => { var _a; return JSON.stringify((_a = obj[field]) !== null && _a !== undefined ? _a : ""); }).join(","));
89
+ const csvContent = [headers.join(","), ...csvRows].join("\n");
90
+ // Create Blob and download
91
+ const blob = new Blob([csvContent], { type: "text/csv" });
92
+ const link = document.createElement("a");
93
+ link.href = URL.createObjectURL(blob);
94
+ link.download = filename;
95
+ document.body.appendChild(link);
96
+ link.click();
97
+ document.body.removeChild(link);
98
+ URL.revokeObjectURL(link.href);
99
+ }
100
+ React.useEffect(() => {
101
+ if (data && data.length > 0) {
102
+ const inferredConfig = columns.map((column) => {
103
+ const key = column.name;
104
+ const values = data.map((row) => row[key]);
105
+ const isNumber = values.every((val) => typeof val === "number");
106
+ const inferredType = isNumber ? "number" : typeof values[0] === "boolean" ? "boolean" : "string";
107
+ return {
108
+ key,
109
+ type: inferredType,
110
+ min: isNumber ? Math.min(...values) : undefined,
111
+ max: isNumber ? Math.max(...values) : undefined,
112
+ };
113
+ });
114
+ setFilterConfig(inferredConfig);
115
+ }
116
+ }, [data, columns]);
117
+ React.useEffect(() => {
118
+ const newFilterFunc = (row) => {
119
+ if (filters.length === 0)
120
+ return true;
121
+ return filters.every((filter) => {
122
+ const rowValue = row[filter.key];
123
+ if (filter.type === "number") {
124
+ const [min, max] = filter.value;
125
+ return rowValue >= min && rowValue <= max;
126
+ }
127
+ if (filter.type === "string") {
128
+ return rowValue.toString().toLowerCase().includes(filter.value.toLowerCase());
129
+ }
130
+ if (filter.type === "boolean") {
131
+ return rowValue === filter.value;
132
+ }
133
+ return true;
134
+ });
135
+ };
136
+ onFilterChange(newFilterFunc);
137
+ }, [filters, onFilterChange]);
138
+ const handleOpen = (event) => {
139
+ setAnchorEl(event.currentTarget);
140
+ };
141
+ const handleClose = () => {
142
+ setAnchorEl(null);
143
+ };
144
+ const handleSearchChange = () => {
145
+ setOpenSearch((prev) => !prev);
146
+ };
147
+ const open = Boolean(anchorEl);
148
+ const getFilter = (key) => filters.find((filter) => filter.key === key);
149
+ const updateFilter = (updatedFilter) => {
150
+ setFilters((prevFilters) => {
151
+ const existingIndex = prevFilters.findIndex((filter) => filter.key === updatedFilter.key);
152
+ if (existingIndex !== -1) {
153
+ // Update existing filter
154
+ const newFilters = [...prevFilters];
155
+ newFilters[existingIndex] = updatedFilter;
156
+ return newFilters;
157
+ }
158
+ // Add new filter
159
+ return [...prevFilters, updatedFilter];
160
+ });
161
+ };
162
+ const removeFilter = (key) => {
163
+ setFilters((prevFilters) => prevFilters.filter((filter) => filter.key !== key));
164
+ };
165
+ const handleFilterChange = (key, value) => {
166
+ if (value === undefined || value === null || value === "") {
167
+ removeFilter(key);
168
+ }
169
+ else {
170
+ const config = filterConfig.find((config) => config.key === key);
171
+ if (!config)
172
+ return;
173
+ updateFilter({
174
+ key,
175
+ type: config.type,
176
+ value,
177
+ });
178
+ }
179
+ };
180
+ const resetFilters = () => {
181
+ setFilters([]);
182
+ setResetCounter((prev) => prev + 1);
183
+ };
184
+ return (jsxRuntime.jsxs(material.Toolbar, { sx: [
185
+ { px: { sm: 2 }, borderBottom: 1, borderColor: "divider" },
186
+ numSelected > 0 && { bgcolor: (theme) => styles.alpha(theme.palette.primary.main, theme.palette.action.activatedOpacity) },
187
+ ], children: [numSelected > 0 ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(material.Typography, { sx: { flex: "1 1 100%" }, color: "inherit", variant: "subtitle1", component: "div", children: ((_a = options === null || options === undefined ? undefined : options.translations) === null || _a === undefined ? undefined : _a.selectedTextRenderer)
188
+ ? options.translations.selectedTextRenderer(numSelected)
189
+ : `${numSelected} selected` }), CustomSelectedToolbar && (jsxRuntime.jsx(CustomSelectedToolbar, { data: data, selected: selected }))] })) : (jsxRuntime.jsxs(material.Stack, { direction: "row", justifyContent: "space-between", width: "100%", alignItems: "center", children: [openSearch ? (jsxRuntime.jsxs(material.Stack, { direction: "row", alignItems: "center", children: [jsxRuntime.jsx(SearchIcon, {}), jsxRuntime.jsx(material.TextField, { placeholder: ((_b = options === null || options === undefined ? undefined : options.translations) === null || _b === undefined ? undefined : _b.searchPlaceholder) || "Search...", onChange: (e) => onSearch(e.target.value), variant: "standard", autoFocus: true, fullWidth: true, sx: { marginLeft: 1 } }), jsxRuntime.jsx(material.IconButton, { onClick: handleSearchChange, sx: { '&:hover': { color: 'error.main' } }, children: jsxRuntime.jsx(iconsMaterial.Close, {}) })] })) : (jsxRuntime.jsx(material.Typography, { sx: { flex: "1 1 100%", alignContent: "center", paddingLeft: 1 }, variant: "h6", id: "tableTitle", component: "div", children: title })), jsxRuntime.jsxs(material.Stack, { direction: "row", spacing: 0.5, children: [jsxRuntime.jsx(material.Tooltip, { title: ((_c = options === null || options === undefined ? undefined : options.translations) === null || _c === undefined ? undefined : _c.searchTooltip) || "Search", children: jsxRuntime.jsx(material.IconButton, { onClick: handleSearchChange, children: jsxRuntime.jsx(SearchIcon, {}) }) }), jsxRuntime.jsx(material.Tooltip, { title: ((_d = options === null || options === undefined ? undefined : options.translations) === null || _d === undefined ? undefined : _d.downloadTooltip) || "Download CSV", children: jsxRuntime.jsx(material.IconButton, { onClick: () => downloadCSV(data, "data.csv"), children: jsxRuntime.jsx(iconsMaterial.CloudDownload, {}) }) }), jsxRuntime.jsx(material.Tooltip, { title: ((_e = options === null || options === undefined ? undefined : options.translations) === null || _e === undefined ? undefined : _e.printTooltip) || "Print", children: jsxRuntime.jsx(material.IconButton, { onClick: () => printFn(), children: jsxRuntime.jsx(iconsMaterial.Print, {}) }) }), jsxRuntime.jsx(material.Tooltip, { title: ((_f = options === null || options === undefined ? undefined : options.translations) === null || _f === undefined ? undefined : _f.filterTooltip) || "Filter list", children: jsxRuntime.jsx(material.IconButton, { onClick: handleOpen, children: jsxRuntime.jsx(FilterListIcon, {}) }) }), CustomToolbar && jsxRuntime.jsx(CustomToolbar, {})] })] })), jsxRuntime.jsxs(material.Popover, { open: open, anchorEl: anchorEl, onClose: handleClose, anchorOrigin: {
190
+ vertical: "bottom",
191
+ horizontal: "right",
192
+ }, transformOrigin: {
193
+ vertical: "top",
194
+ horizontal: "right",
195
+ }, slotProps: {
196
+ paper: { sx: { width: "20%", padding: 2, boxShadow: 2 } }
197
+ }, children: [jsxRuntime.jsxs(material.Stack, { direction: "row", justifyContent: "space-between", children: [jsxRuntime.jsx(material.Typography, { variant: "h6", sx: { marginBottom: 2 }, children: ((_g = options === null || options === undefined ? undefined : options.translations) === null || _g === undefined ? undefined : _g.filtersTitle) || "Filters" }), jsxRuntime.jsx(material.Button, { variant: "contained", size: "small", sx: { height: "fit-content" }, onClick: resetFilters, children: ((_h = options === null || options === undefined ? undefined : options.translations) === null || _h === undefined ? undefined : _h.resetButtonText) || "Reset" })] }), jsxRuntime.jsx(material.Stack, { children: filterConfig.map(({ key, type, min, max }) => {
198
+ var _a, _b, _c, _d, _e, _f;
199
+ const currentFilter = getFilter(key);
200
+ return (jsxRuntime.jsxs(material.Box, { children: [jsxRuntime.jsx(material.Typography, { variant: "subtitle1", children: (_a = columns.find((cell) => cell.name === key)) === null || _a === undefined ? undefined : _a.label }), type === "number" && min !== undefined && max !== undefined && (jsxRuntime.jsx(material.Slider, { value: [
201
+ (_c = (_b = currentFilter === null || currentFilter === undefined ? undefined : currentFilter.value) === null || _b === undefined ? undefined : _b[0]) !== null && _c !== undefined ? _c : min,
202
+ (_e = (_d = currentFilter === null || currentFilter === undefined ? undefined : currentFilter.value) === null || _d === undefined ? undefined : _d[1]) !== null && _e !== undefined ? _e : max,
203
+ ], onChange: (_, newValue) => {
204
+ const [newMin, newMax] = newValue;
205
+ handleFilterChange(key, [newMin, newMax]);
206
+ }, valueLabelDisplay: "auto", min: min || 0, max: max || 100, step: 1 })), type === "string" && (jsxRuntime.jsx(material.TextField, { placeholder: ((_f = options === null || options === undefined ? undefined : options.translations) === null || _f === undefined ? undefined : _f.searchPlaceholder) || "Search...", size: "small", value: (currentFilter === null || currentFilter === undefined ? undefined : currentFilter.value) || "", onChange: (e) => handleFilterChange(key, e.target.value), sx: {
207
+ marginBottom: 1,
208
+ paddingY: 0.5,
209
+ width: "100%",
210
+ } })), type === "boolean" && (jsxRuntime.jsxs(material.Box, { display: "flex", alignItems: "center", children: [jsxRuntime.jsx(material.Checkbox, { checked: (currentFilter === null || currentFilter === undefined ? undefined : currentFilter.value) === true, onChange: (e) => handleFilterChange(key, e.target.checked) }), currentFilter && (jsxRuntime.jsx(iconsMaterial.Close, { color: "error", sx: { cursor: "pointer", fontSize: 15 }, onClick: () => handleFilterChange(key, undefined) }))] }))] }, key));
211
+ }) }, resetCounter)] })] }));
212
+ }
213
+
214
+ function getComparator(order, orderBy) {
215
+ return order === 'desc'
216
+ ? (a, b) => descendingComparator(a[orderBy], b[orderBy])
217
+ : (a, b) => -descendingComparator(a[orderBy], b[orderBy]);
218
+ }
219
+ function descendingComparator(a, b) {
220
+ if (b < a)
221
+ return -1;
222
+ if (b > a)
223
+ return 1;
224
+ return 0;
225
+ }
226
+
227
+ const MUITable = (_a) => {
228
+ var _b, _c;
229
+ var { title, data, deactivateSelect, defaultOrderBy, defaultOrder, excludedColumns, columns: passedColumns, CustomToolbar, CustomSelectedToolbar, options } = _a, rest = __rest(_a, ["title", "data", "deactivateSelect", "defaultOrderBy", "defaultOrder", "excludedColumns", "columns", "CustomToolbar", "CustomSelectedToolbar", "options"]);
230
+ const tableRef = React.useRef(null);
231
+ const reactToPrintFn = reactToPrint.useReactToPrint({ contentRef: tableRef });
232
+ const getDefaultOrderByKey = React.useCallback(() => {
233
+ if (data.length === 0)
234
+ return "id";
235
+ const keys = data.length > 0 ? Object.keys(data[0]) : [];
236
+ if (defaultOrderBy) {
237
+ if (keys.includes(defaultOrderBy)) {
238
+ return defaultOrderBy;
239
+ }
240
+ else {
241
+ console.warn(`{defaultOrderBy}: "${defaultOrderBy}" not found among the object keys. Falling back to automatic key detection.`);
242
+ }
243
+ }
244
+ return (keys.includes("id") ? "id" : keys[0]);
245
+ }, [data, defaultOrderBy]);
246
+ const [state, setState] = React.useState(() => {
247
+ const orderByKey = getDefaultOrderByKey();
248
+ return {
249
+ order: defaultOrder || 'asc',
250
+ orderBy: orderByKey,
251
+ selected: [],
252
+ page: 0,
253
+ rowsPerPage: 5,
254
+ searchQuery: "",
255
+ filterFunc: () => true,
256
+ currentData: data,
257
+ visibleRows: data,
258
+ emptyRows: 0,
259
+ };
260
+ });
261
+ const generateColumns = React.useCallback(() => {
262
+ if (data.length === 0)
263
+ return [];
264
+ return Object.keys(data[0])
265
+ .filter((key) => !(excludedColumns || []).includes(key))
266
+ .map((key) => ({
267
+ name: key,
268
+ label: key.charAt(0).toUpperCase() + key.slice(1),
269
+ }));
270
+ }, [data, excludedColumns]);
271
+ const columns = passedColumns || generateColumns();
272
+ const handleSearch = (query) => {
273
+ setState((prevState) => (Object.assign(Object.assign({}, prevState), { searchQuery: query.toLowerCase() })));
274
+ };
275
+ React.useEffect(() => {
276
+ const orderByKey = getDefaultOrderByKey();
277
+ setState((prevState) => (Object.assign(Object.assign({}, prevState), { orderBy: orderByKey })));
278
+ }, [data, getDefaultOrderByKey]);
279
+ // Data sorting, filtering, and pagination
280
+ React.useEffect(() => {
281
+ // Apply filters, search query, and sort data
282
+ const sortedData = [...data]
283
+ .filter(state.filterFunc)
284
+ .filter((row) => Object.values(row).some((value) => typeof value === "string" &&
285
+ value.toLowerCase().includes(state.searchQuery)))
286
+ .sort(getComparator(state.order, state.orderBy));
287
+ // Paginate the processed data
288
+ const startIndex = state.page * state.rowsPerPage;
289
+ const paginatedData = sortedData.slice(startIndex, startIndex + state.rowsPerPage);
290
+ const calculatedEmptyRows = Math.max(0, (1 + state.page) * state.rowsPerPage - sortedData.length);
291
+ setState((prevState) => (Object.assign(Object.assign({}, prevState), { visibleRows: paginatedData, emptyRows: calculatedEmptyRows, selected: prevState.selected.filter((selectedRow) => data.includes(selectedRow)) })));
292
+ }, [
293
+ state.filterFunc,
294
+ state.order,
295
+ state.orderBy,
296
+ state.page,
297
+ state.rowsPerPage,
298
+ state.searchQuery,
299
+ data,
300
+ ]);
301
+ // Remove selected rows deleted from the data to prevent stale selected state
302
+ React.useEffect(() => {
303
+ setState((prevState) => (Object.assign(Object.assign({}, prevState), { selected: prevState.selected.filter((selectedRow) => data.some((row) => row === selectedRow)) })));
304
+ }, [data]);
305
+ const handleRequestSort = (_event, property) => {
306
+ const isAsc = state.orderBy === property && state.order === 'asc';
307
+ setState((prevState) => (Object.assign(Object.assign({}, prevState), { order: isAsc ? 'desc' : 'asc', orderBy: property })));
308
+ };
309
+ const handleSelectAllClick = (event) => {
310
+ if (event.target.checked) {
311
+ setState((prevState) => (Object.assign(Object.assign({}, prevState), { selected: [...state.currentData] })));
312
+ }
313
+ else {
314
+ setState((prevState) => (Object.assign(Object.assign({}, prevState), { selected: [] })));
315
+ }
316
+ };
317
+ const handleClick = (_event, row) => {
318
+ const selectedIndex = state.selected.findIndex((selectedRow) => selectedRow === row);
319
+ let newSelected = [];
320
+ if (selectedIndex === -1) {
321
+ newSelected = [...state.selected, row];
322
+ }
323
+ else if (selectedIndex === 0) {
324
+ newSelected = state.selected.slice(1);
325
+ }
326
+ else if (selectedIndex === state.selected.length - 1) {
327
+ newSelected = state.selected.slice(0, -1);
328
+ }
329
+ else if (selectedIndex > 0) {
330
+ newSelected = [
331
+ ...state.selected.slice(0, selectedIndex),
332
+ ...state.selected.slice(selectedIndex + 1),
333
+ ];
334
+ }
335
+ setState((prevState) => (Object.assign(Object.assign({}, prevState), { selected: newSelected })));
336
+ };
337
+ const handleChangePage = (_event, newPage) => {
338
+ setState((prevState) => (Object.assign(Object.assign({}, prevState), { page: newPage })));
339
+ };
340
+ const handleChangeRowsPerPage = (event) => {
341
+ setState((prevState) => (Object.assign(Object.assign({}, prevState), { rowsPerPage: parseInt(event.target.value, 10), page: 0 })));
342
+ };
343
+ const handleFilterChange = React.useCallback((filterFunc) => {
344
+ setState((prevState) => (Object.assign(Object.assign({}, prevState), { filterFunc })));
345
+ }, []);
346
+ return (jsxRuntime.jsx("div", Object.assign({}, rest, { ref: tableRef, children: jsxRuntime.jsxs(Paper, { sx: { width: '100%', mb: 2 }, children: [jsxRuntime.jsx(EnhancedTableToolbar, { title: title, numSelected: state.selected.length, selected: state.selected, onFilterChange: handleFilterChange, onSearch: handleSearch, printFn: reactToPrintFn, columns: columns, CustomToolbar: CustomToolbar, CustomSelectedToolbar: CustomSelectedToolbar, data: data, options: options }), jsxRuntime.jsx(TableContainer, { children: jsxRuntime.jsxs(Table, { sx: { minWidth: 750 }, "aria-labelledby": "tableTitle", size: "small", children: [jsxRuntime.jsx(EnhancedTableHead, { columns: columns, numSelected: state.selected.length, order: state.order, orderBy: state.orderBy, onSelectAllClick: deactivateSelect ? undefined : handleSelectAllClick, onRequestSort: handleRequestSort, rowCount: state.currentData.length, deactivateSelectAll: deactivateSelect }), jsxRuntime.jsxs(TableBody, { children: [state.visibleRows.map((row, index) => {
347
+ const isItemSelected = state.selected.some((selectedRow) => selectedRow === row);
348
+ const labelId = `enhanced-table-checkbox-${index}`;
349
+ return (jsxRuntime.jsxs(TableRow, { hover: true, onClick: deactivateSelect ? undefined : (event) => handleClick(event, row), role: "checkbox", "aria-checked": isItemSelected, tabIndex: -1, selected: isItemSelected, sx: { cursor: 'pointer' }, children: [!deactivateSelect && (jsxRuntime.jsx(TableCell, { padding: "checkbox", children: jsxRuntime.jsx(Checkbox, { color: "primary", checked: isItemSelected, inputProps: {
350
+ 'aria-labelledby': labelId,
351
+ } }) })), columns.map((column, cellIndex) => {
352
+ var _a;
353
+ return (jsxRuntime.jsx(TableCell, { component: cellIndex === 0 ? "th" : undefined, id: cellIndex === 0 ? labelId : undefined, scope: cellIndex === 0 ? "row" : undefined, padding: "normal", children: ((_a = column.options) === null || _a === undefined ? undefined : _a.customBodyRender)
354
+ ? column.options.customBodyRender(row[column.name])
355
+ : String(row[column.name]) }, String(column.name)));
356
+ })] }, index));
357
+ }), state.emptyRows > 0 && (jsxRuntime.jsx(TableRow, { style: {
358
+ height: 33 * state.emptyRows,
359
+ }, children: jsxRuntime.jsx(TableCell, { colSpan: columns.length + 1 }) }))] })] }) }), jsxRuntime.jsx(TablePagination, { rowsPerPageOptions: [5, 10, 25], component: "div", count: state.currentData.length, rowsPerPage: state.rowsPerPage, page: state.page, onPageChange: handleChangePage, onRowsPerPageChange: handleChangeRowsPerPage, labelRowsPerPage: ((_b = options === null || options === undefined ? undefined : options.translations) === null || _b === undefined ? undefined : _b.rowsPerPageText) || "Rows per page", labelDisplayedRows: ((_c = options === null || options === undefined ? undefined : options.translations) === null || _c === undefined ? undefined : _c.labelDisplayedRows) || (({ from, to, count }) => `${from}-${to} of ${count}`) })] }) })));
360
+ };
361
+
362
+ module.exports = MUITable;
363
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,11 @@
1
+ import { HeadCell } from "../components/TableHead";
2
+ export interface Data {
3
+ id: number;
4
+ calories: number;
5
+ carbs: number;
6
+ fat: number;
7
+ name: string;
8
+ protein: number;
9
+ }
10
+ export declare const rows: Data[];
11
+ export declare const headCells: HeadCell<typeof rows[0]>[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mui-datatables-updated",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "MUI Datatable library inspired by the gregnb/mui-datatables project, featuring an up-to-date implementation with Typescript Support.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -51,5 +51,8 @@
51
51
  "rollup-plugin-peer-deps-external": "^2.2.4",
52
52
  "rollup-plugin-typescript2": "^0.36.0",
53
53
  "typescript": "^5.7.3"
54
+ },
55
+ "dependencies": {
56
+ "react-to-print": "^3.0.5"
54
57
  }
55
58
  }
package/rollup.config.mjs CHANGED
@@ -16,7 +16,7 @@ export default {
16
16
  },
17
17
  ],
18
18
  plugins: [
19
- peerDepsExternal(),
19
+ peerDepsExternal({ includeDependencies: true }),
20
20
  typescript(),
21
21
  ],
22
22
  external: ['react', 'react-dom', '@mui/material'],