@insticc/react-datagrid-2 1.1.10 → 1.1.12
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/build/wrapper/ActionButton.js +10 -3
- package/build/wrapper/images/cache.png +0 -0
- package/build/wrapper/images/cacheloading.png +0 -0
- package/build/wrapper/index.js +321 -132
- package/build/wrapper/styles/styles.css +16 -0
- package/build/wrapper/utils/gridFixedHeader.js +47 -0
- package/package.json +2 -1
|
@@ -21,13 +21,18 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
|
|
|
21
21
|
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
22
22
|
var ActionButton = function ActionButton(_ref) {
|
|
23
23
|
var table = _ref.table,
|
|
24
|
+
_ref$toggle = _ref.toggle,
|
|
25
|
+
toggle = _ref$toggle === void 0 ? false : _ref$toggle,
|
|
26
|
+
_ref$active = _ref.active,
|
|
27
|
+
active = _ref$active === void 0 ? false : _ref$active,
|
|
24
28
|
_ref$name = _ref.name,
|
|
25
29
|
name = _ref$name === void 0 ? '' : _ref$name,
|
|
26
30
|
tooltip = _ref.tooltip,
|
|
27
31
|
onClick = _ref.onClick,
|
|
28
32
|
_ref$color = _ref.color,
|
|
29
33
|
color = _ref$color === void 0 ? 'blue' : _ref$color,
|
|
30
|
-
icon = _ref.icon,
|
|
34
|
+
_ref$icon = _ref.icon,
|
|
35
|
+
icon = _ref$icon === void 0 ? null : _ref$icon,
|
|
31
36
|
_ref$selectionMode = _ref.selectionMode,
|
|
32
37
|
selectionMode = _ref$selectionMode === void 0 ? 'always' : _ref$selectionMode,
|
|
33
38
|
_ref$confirmMessage = _ref.confirmMessage,
|
|
@@ -129,6 +134,8 @@ var ActionButton = function ActionButton(_ref) {
|
|
|
129
134
|
title: tooltip || name,
|
|
130
135
|
arrow: true
|
|
131
136
|
}, /*#__PURE__*/_react["default"].createElement("span", null, /*#__PURE__*/_react["default"].createElement(_semanticUiReact.Button, _extends({
|
|
137
|
+
toggle: toggle,
|
|
138
|
+
active: active,
|
|
132
139
|
disabled: disabled || shouldDisableActionButton(table),
|
|
133
140
|
onClick: function onClick() {
|
|
134
141
|
return hasConfirmMessage ? setEnableConfirmMessage(true) : handleConfirm();
|
|
@@ -137,7 +144,7 @@ var ActionButton = function ActionButton(_ref) {
|
|
|
137
144
|
}, name ? {
|
|
138
145
|
content: name
|
|
139
146
|
} : {}, {
|
|
140
|
-
basic:
|
|
147
|
+
basic: !active,
|
|
141
148
|
color: color,
|
|
142
149
|
style: {
|
|
143
150
|
display: 'flex',
|
|
@@ -189,7 +196,7 @@ ActionButton.propTypes = {
|
|
|
189
196
|
// the callback to be called when the action button is clicked
|
|
190
197
|
color: _propTypes["default"].oneOf(['blue', 'red', 'green', 'yellow', 'orange', 'black', 'grey', 'purple', 'teal', 'brown', 'violet', 'purple', 'olive', 'pink']),
|
|
191
198
|
// the color of the action button
|
|
192
|
-
icon: _propTypes["default"].oneOfType([_propTypes["default"].element, _propTypes["default"].string])
|
|
199
|
+
icon: _propTypes["default"].oneOfType([_propTypes["default"].element, _propTypes["default"].string]),
|
|
193
200
|
// the action button icon
|
|
194
201
|
selectionMode: _propTypes["default"].oneOf(['single', 'multi', 'always']),
|
|
195
202
|
// the action button selection mode
|
|
Binary file
|
|
Binary file
|
package/build/wrapper/index.js
CHANGED
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports["default"] = void 0;
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
-
var _propTypes =
|
|
9
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
10
|
var _materialReactTable = require("material-react-table");
|
|
11
11
|
var _xDatePickers = require("@mui/x-date-pickers");
|
|
12
12
|
var _AdapterDateFns = require("@mui/x-date-pickers/AdapterDateFns");
|
|
@@ -16,6 +16,7 @@ var _ColumnFilter = _interopRequireDefault(require("./ColumnFilter"));
|
|
|
16
16
|
var _ExportActions = _interopRequireDefault(require("./ExportActions"));
|
|
17
17
|
var _ActionButton = _interopRequireDefault(require("./ActionButton"));
|
|
18
18
|
var _GridHelper = _interopRequireDefault(require("./utils/GridHelper"));
|
|
19
|
+
var _gridFixedHeader = _interopRequireDefault(require("./utils/gridFixedHeader"));
|
|
19
20
|
var _filters = require("./utils/filters");
|
|
20
21
|
require("bootstrap/dist/css/bootstrap.min.css");
|
|
21
22
|
require("semantic-ui-css/semantic.min.css");
|
|
@@ -39,7 +40,8 @@ var DataGrid = function DataGrid(_ref) {
|
|
|
39
40
|
columnVisibilityState = _ref.columnVisibilityState,
|
|
40
41
|
columnOrder = _ref.columnOrder,
|
|
41
42
|
createRows = _ref.createRows,
|
|
42
|
-
actions = _ref.actions,
|
|
43
|
+
_ref$actions = _ref.actions,
|
|
44
|
+
actions = _ref$actions === void 0 ? null : _ref$actions,
|
|
43
45
|
_ref$hasExcelExport = _ref.hasExcelExport,
|
|
44
46
|
hasExcelExport = _ref$hasExcelExport === void 0 ? false : _ref$hasExcelExport,
|
|
45
47
|
_ref$excelOption = _ref.excelOption,
|
|
@@ -50,6 +52,8 @@ var DataGrid = function DataGrid(_ref) {
|
|
|
50
52
|
pdfOption = _ref$pdfOption === void 0 ? 'selectedRows' : _ref$pdfOption,
|
|
51
53
|
_ref$rowHeight = _ref.rowHeight,
|
|
52
54
|
rowHeight = _ref$rowHeight === void 0 ? 75 : _ref$rowHeight,
|
|
55
|
+
_ref$fontSize = _ref.fontSize,
|
|
56
|
+
fontSize = _ref$fontSize === void 0 ? 14 : _ref$fontSize,
|
|
53
57
|
_ref$globalFilterFn = _ref.globalFilterFn,
|
|
54
58
|
globalFilterFn = _ref$globalFilterFn === void 0 ? 'contains' : _ref$globalFilterFn,
|
|
55
59
|
_ref$disableSelect = _ref.disableSelect,
|
|
@@ -80,10 +84,21 @@ var DataGrid = function DataGrid(_ref) {
|
|
|
80
84
|
enableExpanding = _ref$enableExpanding === void 0 ? false : _ref$enableExpanding,
|
|
81
85
|
_ref$enablePagination = _ref.enablePagination,
|
|
82
86
|
enablePagination = _ref$enablePagination === void 0 ? true : _ref$enablePagination,
|
|
87
|
+
_ref$enableTopToolbar = _ref.enableTopToolbar,
|
|
88
|
+
enableTopToolbar = _ref$enableTopToolbar === void 0 ? true : _ref$enableTopToolbar,
|
|
89
|
+
_ref$enableBottomTool = _ref.enableBottomToolbar,
|
|
90
|
+
enableBottomToolbar = _ref$enableBottomTool === void 0 ? false : _ref$enableBottomTool,
|
|
83
91
|
_ref$enableVirtualiza = _ref.enableVirtualization,
|
|
84
92
|
enableVirtualization = _ref$enableVirtualiza === void 0 ? false : _ref$enableVirtualiza,
|
|
93
|
+
_ref$enableFixedHeade = _ref.enableFixedHeader,
|
|
94
|
+
enableFixedHeader = _ref$enableFixedHeade === void 0 ? false : _ref$enableFixedHeade,
|
|
85
95
|
_ref$gridHeight = _ref.gridHeight,
|
|
86
96
|
gridHeight = _ref$gridHeight === void 0 ? 600 : _ref$gridHeight,
|
|
97
|
+
onVisibleRowsChange = _ref.onVisibleRowsChange,
|
|
98
|
+
updateCache = _ref.updateCache,
|
|
99
|
+
cacheUpdateText = _ref.cacheUpdateText,
|
|
100
|
+
cacheUpdating = _ref.cacheUpdating,
|
|
101
|
+
getRowStyle = _ref.getRowStyle,
|
|
87
102
|
_ref$gridHelper = _ref.gridHelper,
|
|
88
103
|
gridHelper = _ref$gridHelper === void 0 ? null : _ref$gridHelper,
|
|
89
104
|
_ref$disableRows = _ref.disableRows,
|
|
@@ -91,7 +106,9 @@ var DataGrid = function DataGrid(_ref) {
|
|
|
91
106
|
_ref$selectAllMode = _ref.selectAllMode,
|
|
92
107
|
selectAllMode = _ref$selectAllMode === void 0 ? 'page' : _ref$selectAllMode,
|
|
93
108
|
_ref$hasClearFiltersB = _ref.hasClearFiltersBtn,
|
|
94
|
-
hasClearFiltersBtn = _ref$hasClearFiltersB === void 0 ? true : _ref$hasClearFiltersB
|
|
109
|
+
hasClearFiltersBtn = _ref$hasClearFiltersB === void 0 ? true : _ref$hasClearFiltersB,
|
|
110
|
+
_ref$enableCompactSty = _ref.enableCompactStyleMode,
|
|
111
|
+
enableCompactStyleMode = _ref$enableCompactSty === void 0 ? false : _ref$enableCompactSty;
|
|
95
112
|
var _useState = (0, _react.useState)(selectedIds.reduce(function (a, v) {
|
|
96
113
|
return _objectSpread(_objectSpread({}, a), {}, _defineProperty({}, v, true));
|
|
97
114
|
}, {})),
|
|
@@ -234,6 +251,150 @@ var DataGrid = function DataGrid(_ref) {
|
|
|
234
251
|
});
|
|
235
252
|
});
|
|
236
253
|
};
|
|
254
|
+
var renderTopToolbarCustomActions = function renderTopToolbarCustomActions(_ref2) {
|
|
255
|
+
var table = _ref2.table;
|
|
256
|
+
var selectedRows = table.getSelectedRowModel().flatRows;
|
|
257
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
258
|
+
style: {
|
|
259
|
+
display: 'flex',
|
|
260
|
+
flexDirection: 'column',
|
|
261
|
+
gap: '.5em',
|
|
262
|
+
width: '100%'
|
|
263
|
+
}
|
|
264
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
265
|
+
style: {
|
|
266
|
+
display: 'flex',
|
|
267
|
+
justifyContent: 'space-between'
|
|
268
|
+
}
|
|
269
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
270
|
+
style: {
|
|
271
|
+
display: 'flex',
|
|
272
|
+
flexDirection: 'row',
|
|
273
|
+
gap: '.5em',
|
|
274
|
+
flexWrap: 'wrap'
|
|
275
|
+
}
|
|
276
|
+
}, (actions === null || actions === void 0 ? void 0 : actions.length) > 0 && actions.map(function (e) {
|
|
277
|
+
var isVisible = e.visible !== undefined ? e.visible : true;
|
|
278
|
+
if (isVisible) {
|
|
279
|
+
return /*#__PURE__*/_react["default"].createElement(_ActionButton["default"], {
|
|
280
|
+
table: table,
|
|
281
|
+
key: e.key || e.name,
|
|
282
|
+
toggle: e.toggle,
|
|
283
|
+
active: e.active,
|
|
284
|
+
name: e.name,
|
|
285
|
+
tooltip: e.tooltip,
|
|
286
|
+
onClick: e["function"],
|
|
287
|
+
icon: e.icon,
|
|
288
|
+
color: e.color,
|
|
289
|
+
selectionMode: e.selectionMode,
|
|
290
|
+
confirmMessage: e.confirmMessage,
|
|
291
|
+
hasConfirmMessage: e.hasConfirmMessage,
|
|
292
|
+
disabled: e.disabled
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
}), /*#__PURE__*/_react["default"].createElement(_ExportActions["default"], {
|
|
296
|
+
table: table,
|
|
297
|
+
data: createRows,
|
|
298
|
+
columns: columns,
|
|
299
|
+
hasExcelExport: hasExcelExport,
|
|
300
|
+
hasPdfExport: hasPdfExport,
|
|
301
|
+
pdfOption: pdfOption,
|
|
302
|
+
excelOption: excelOption
|
|
303
|
+
})), /*#__PURE__*/_react["default"].createElement("div", {
|
|
304
|
+
style: {
|
|
305
|
+
display: 'flex',
|
|
306
|
+
alignSelf: 'flex-end',
|
|
307
|
+
justifyContent: 'end',
|
|
308
|
+
flexDirection: 'row',
|
|
309
|
+
flexWrap: 'wrap'
|
|
310
|
+
}
|
|
311
|
+
}, updateCache && /*#__PURE__*/_react["default"].createElement(_material.Tooltip, {
|
|
312
|
+
title: cacheUpdateText,
|
|
313
|
+
arrow: true
|
|
314
|
+
}, /*#__PURE__*/_react["default"].createElement("span", null, /*#__PURE__*/_react["default"].createElement(_semanticUiReact.Button, {
|
|
315
|
+
circular: true,
|
|
316
|
+
disabled: cacheUpdating,
|
|
317
|
+
onClick: function onClick() {
|
|
318
|
+
return updateCache();
|
|
319
|
+
},
|
|
320
|
+
content: /*#__PURE__*/_react["default"].createElement("img", {
|
|
321
|
+
src: cacheUpdating ? require('./images/cacheloading.png') : require('./images/cache.png'),
|
|
322
|
+
alt: "cache",
|
|
323
|
+
style: {
|
|
324
|
+
width: "60px"
|
|
325
|
+
}
|
|
326
|
+
}),
|
|
327
|
+
primary: true,
|
|
328
|
+
inverted: true,
|
|
329
|
+
style: {
|
|
330
|
+
display: 'flex',
|
|
331
|
+
height: '36px',
|
|
332
|
+
alignItems: 'center',
|
|
333
|
+
justifyContent: 'center'
|
|
334
|
+
}
|
|
335
|
+
}))), (!disableSelect || disableRows.length > 0) && /*#__PURE__*/_react["default"].createElement(_material.Tooltip, {
|
|
336
|
+
title: "Clear all rows selected",
|
|
337
|
+
arrow: true
|
|
338
|
+
}, /*#__PURE__*/_react["default"].createElement("span", null, /*#__PURE__*/_react["default"].createElement(_semanticUiReact.Button, {
|
|
339
|
+
circular: true,
|
|
340
|
+
disabled: selectedRows.length < 1,
|
|
341
|
+
onClick: function onClick() {
|
|
342
|
+
return table.resetRowSelection();
|
|
343
|
+
},
|
|
344
|
+
content: /*#__PURE__*/_react["default"].createElement("span", null, /*#__PURE__*/_react["default"].createElement(_semanticUiReact.Icon, {
|
|
345
|
+
style: {
|
|
346
|
+
margin: 0,
|
|
347
|
+
color: 'inherit'
|
|
348
|
+
},
|
|
349
|
+
name: "square outline"
|
|
350
|
+
}), /*#__PURE__*/_react["default"].createElement(_semanticUiReact.Icon, {
|
|
351
|
+
style: {
|
|
352
|
+
margin: 0,
|
|
353
|
+
color: 'inherit'
|
|
354
|
+
},
|
|
355
|
+
name: "close"
|
|
356
|
+
})),
|
|
357
|
+
primary: true,
|
|
358
|
+
basic: true
|
|
359
|
+
// style={{ display: 'flex', height: '40px', alignItems: 'center', justifyContent: 'center' }}
|
|
360
|
+
}))), hasClearFiltersBtn && /*#__PURE__*/_react["default"].createElement(_material.Tooltip, {
|
|
361
|
+
title: "Clear Filters",
|
|
362
|
+
arrow: true
|
|
363
|
+
}, /*#__PURE__*/_react["default"].createElement("span", null, /*#__PURE__*/_react["default"].createElement(_semanticUiReact.Button, {
|
|
364
|
+
circular: true,
|
|
365
|
+
onClick: function onClick() {
|
|
366
|
+
return table.resetColumnFilters();
|
|
367
|
+
},
|
|
368
|
+
content: /*#__PURE__*/_react["default"].createElement("span", null, /*#__PURE__*/_react["default"].createElement(_semanticUiReact.Icon, {
|
|
369
|
+
style: {
|
|
370
|
+
margin: 0,
|
|
371
|
+
color: 'inherit'
|
|
372
|
+
},
|
|
373
|
+
name: "filter"
|
|
374
|
+
}), /*#__PURE__*/_react["default"].createElement(_semanticUiReact.Icon, {
|
|
375
|
+
style: {
|
|
376
|
+
margin: 0,
|
|
377
|
+
color: 'inherit'
|
|
378
|
+
},
|
|
379
|
+
name: "close"
|
|
380
|
+
})),
|
|
381
|
+
inverted: true,
|
|
382
|
+
color: "orange"
|
|
383
|
+
// style={{ display: 'flex', height: '40px', alignItems: 'center', justifyContent: 'center' }}
|
|
384
|
+
}))), gridHelper && /*#__PURE__*/_react["default"].createElement(_material.Tooltip, {
|
|
385
|
+
title: "Grid Help",
|
|
386
|
+
arrow: true
|
|
387
|
+
}, /*#__PURE__*/_react["default"].createElement("span", null, /*#__PURE__*/_react["default"].createElement(_semanticUiReact.Button, {
|
|
388
|
+
circular: true,
|
|
389
|
+
onClick: function onClick() {
|
|
390
|
+
return setOpen(true);
|
|
391
|
+
},
|
|
392
|
+
icon: "help",
|
|
393
|
+
color: "blue"
|
|
394
|
+
// style={{ display: 'flex', height: '40px', alignItems: 'center', justifyContent: 'center' }}
|
|
395
|
+
}))))));
|
|
396
|
+
};
|
|
397
|
+
|
|
237
398
|
/**
|
|
238
399
|
* Generates all the table's properties.
|
|
239
400
|
*/
|
|
@@ -312,164 +473,161 @@ var DataGrid = function DataGrid(_ref) {
|
|
|
312
473
|
filterRegex: 'Regex',
|
|
313
474
|
filterLogical: 'Logical'
|
|
314
475
|
},
|
|
315
|
-
renderColumnFilterModeMenuItems: function renderColumnFilterModeMenuItems(
|
|
316
|
-
var internalFilterOptions =
|
|
317
|
-
onSelectFilterMode =
|
|
476
|
+
renderColumnFilterModeMenuItems: function renderColumnFilterModeMenuItems(_ref3) {
|
|
477
|
+
var internalFilterOptions = _ref3.internalFilterOptions,
|
|
478
|
+
onSelectFilterMode = _ref3.onSelectFilterMode;
|
|
318
479
|
return [/*#__PURE__*/_react["default"].createElement(_ColumnFilter["default"], {
|
|
319
480
|
key: "filters",
|
|
320
481
|
filterOptions: internalFilterOptions,
|
|
321
482
|
onSelectFilterMode: onSelectFilterMode
|
|
322
483
|
})];
|
|
323
484
|
},
|
|
324
|
-
|
|
325
|
-
var table =
|
|
485
|
+
renderTopToolbar: function renderTopToolbar(_ref4) {
|
|
486
|
+
var table = _ref4.table;
|
|
326
487
|
var selectedRows = table.getSelectedRowModel().flatRows;
|
|
488
|
+
var _table$getState$pagin = table.getState().pagination,
|
|
489
|
+
pageIndex = _table$getState$pagin.pageIndex,
|
|
490
|
+
pageSize = _table$getState$pagin.pageSize;
|
|
491
|
+
var filteredRowCount = table.getFilteredRowModel().rows.length;
|
|
327
492
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
328
493
|
style: {
|
|
329
494
|
display: 'flex',
|
|
330
495
|
flexDirection: 'column',
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
display: 'flex',
|
|
337
|
-
justifyContent: 'space-between'
|
|
338
|
-
}
|
|
339
|
-
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
496
|
+
padding: '8px',
|
|
497
|
+
gap: '8px'
|
|
498
|
+
},
|
|
499
|
+
className: "grid-sticky-actions"
|
|
500
|
+
}, renderTopToolbarCustomActions && /*#__PURE__*/_react["default"].createElement("div", {
|
|
340
501
|
style: {
|
|
341
|
-
|
|
342
|
-
flexDirection: 'row',
|
|
343
|
-
gap: '.5em',
|
|
344
|
-
flexWrap: 'wrap'
|
|
345
|
-
}
|
|
346
|
-
}, actions && actions.map(function (e) {
|
|
347
|
-
var isVisible = e.visible !== undefined ? e.visible : true;
|
|
348
|
-
if (isVisible) {
|
|
349
|
-
return /*#__PURE__*/_react["default"].createElement(_ActionButton["default"], {
|
|
350
|
-
table: table,
|
|
351
|
-
key: e.key || e.name,
|
|
352
|
-
name: e.name,
|
|
353
|
-
tooltip: e.tooltip,
|
|
354
|
-
onClick: e["function"],
|
|
355
|
-
icon: e.icon,
|
|
356
|
-
color: e.color,
|
|
357
|
-
selectionMode: e.selectionMode,
|
|
358
|
-
confirmMessage: e.confirmMessage,
|
|
359
|
-
hasConfirmMessage: e.hasConfirmMessage,
|
|
360
|
-
disabled: e.disabled
|
|
361
|
-
});
|
|
502
|
+
width: '100%'
|
|
362
503
|
}
|
|
363
|
-
}
|
|
364
|
-
table: table
|
|
365
|
-
data: createRows,
|
|
366
|
-
columns: columns,
|
|
367
|
-
hasExcelExport: hasExcelExport,
|
|
368
|
-
hasPdfExport: hasPdfExport,
|
|
369
|
-
pdfOption: pdfOption,
|
|
370
|
-
excelOption: excelOption
|
|
504
|
+
}, renderTopToolbarCustomActions({
|
|
505
|
+
table: table
|
|
371
506
|
})), /*#__PURE__*/_react["default"].createElement("div", {
|
|
372
507
|
style: {
|
|
373
508
|
display: 'flex',
|
|
374
|
-
|
|
509
|
+
alignItems: 'center',
|
|
510
|
+
gap: '8px',
|
|
511
|
+
alignSelf: 'flex-end'
|
|
375
512
|
}
|
|
376
|
-
},
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
513
|
+
}, /*#__PURE__*/_react["default"].createElement(_material.Stack, {
|
|
514
|
+
direction: "row",
|
|
515
|
+
alignItems: "center",
|
|
516
|
+
justifyContent: "space-between"
|
|
517
|
+
}, /*#__PURE__*/_react["default"].createElement(_material.TablePagination, {
|
|
518
|
+
component: "div",
|
|
519
|
+
count: filteredRowCount,
|
|
520
|
+
page: 0,
|
|
521
|
+
onPageChange: function onPageChange() {},
|
|
522
|
+
rowsPerPage: pageSize,
|
|
523
|
+
onRowsPerPageChange: function onRowsPerPageChange(e) {
|
|
524
|
+
return table.setPageSize(Number(e.target.value));
|
|
384
525
|
},
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
color: 'inherit'
|
|
389
|
-
},
|
|
390
|
-
name: "square outline"
|
|
391
|
-
}), /*#__PURE__*/_react["default"].createElement(_semanticUiReact.Icon, {
|
|
392
|
-
style: {
|
|
393
|
-
margin: 0,
|
|
394
|
-
color: 'inherit'
|
|
395
|
-
},
|
|
396
|
-
name: "close"
|
|
397
|
-
})),
|
|
398
|
-
primary: true,
|
|
399
|
-
basic: true
|
|
400
|
-
// style={{ display: 'flex', height: '40px', alignItems: 'center', justifyContent: 'center' }}
|
|
401
|
-
}))), hasClearFiltersBtn && /*#__PURE__*/_react["default"].createElement(_material.Tooltip, {
|
|
402
|
-
title: "Clear Filters",
|
|
403
|
-
arrow: true
|
|
404
|
-
}, /*#__PURE__*/_react["default"].createElement("span", null, /*#__PURE__*/_react["default"].createElement(_semanticUiReact.Button, {
|
|
405
|
-
circular: true,
|
|
406
|
-
onClick: function onClick() {
|
|
407
|
-
return table.resetColumnFilters();
|
|
526
|
+
rowsPerPageOptions: itemsPerPage,
|
|
527
|
+
labelDisplayedRows: function labelDisplayedRows() {
|
|
528
|
+
return "";
|
|
408
529
|
},
|
|
409
|
-
|
|
410
|
-
|
|
530
|
+
showFirstButton: false,
|
|
531
|
+
showLastButton: false,
|
|
532
|
+
sx: {
|
|
533
|
+
'& .MuiTablePagination-toolbar': {
|
|
534
|
+
padding: 0,
|
|
411
535
|
margin: 0,
|
|
412
|
-
|
|
536
|
+
gap: '4px'
|
|
413
537
|
},
|
|
414
|
-
|
|
415
|
-
}), /*#__PURE__*/_react["default"].createElement(_semanticUiReact.Icon, {
|
|
416
|
-
style: {
|
|
538
|
+
'& *': {
|
|
417
539
|
margin: 0,
|
|
418
|
-
|
|
540
|
+
fontSize: '14px'
|
|
419
541
|
},
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
circular: true,
|
|
430
|
-
onClick: function onClick() {
|
|
431
|
-
return setOpen(true);
|
|
542
|
+
"& .MuiTablePagination-actions": {
|
|
543
|
+
display: "none"
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
}), /*#__PURE__*/_react["default"].createElement(_material.Pagination, {
|
|
547
|
+
count: Math.ceil(filteredRowCount / pageSize),
|
|
548
|
+
page: pageIndex + 1,
|
|
549
|
+
onChange: function onChange(_, value) {
|
|
550
|
+
return table.setPageIndex(value - 1);
|
|
432
551
|
},
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
}))))), /*#__PURE__*/_react["default"].createElement("div", {
|
|
552
|
+
showFirstButton: true,
|
|
553
|
+
showLastButton: true
|
|
554
|
+
})), /*#__PURE__*/_react["default"].createElement("div", {
|
|
437
555
|
style: {
|
|
438
|
-
|
|
439
|
-
|
|
556
|
+
marginRight: '5px',
|
|
557
|
+
fontSize: '14px'
|
|
440
558
|
}
|
|
441
559
|
}, /*#__PURE__*/_react["default"].createElement(_material.Tooltip, {
|
|
442
560
|
title: "Selected/Filtered/Total",
|
|
443
561
|
arrow: true
|
|
444
|
-
}, /*#__PURE__*/_react["default"].createElement("span", null, selectedRows.length, "/",
|
|
562
|
+
}, /*#__PURE__*/_react["default"].createElement("span", null, !disableSelect && "".concat(selectedRows.length, "/"), filteredRowCount, "/", createRows.length)))));
|
|
563
|
+
},
|
|
564
|
+
muiTableHeadProps: {
|
|
565
|
+
className: 'grid-sticky-header'
|
|
445
566
|
},
|
|
446
567
|
muiTableHeadCellProps: {
|
|
447
|
-
sx: {
|
|
568
|
+
sx: _objectSpread({}, enableCompactStyleMode ? {
|
|
569
|
+
fontWeight: 'bold',
|
|
570
|
+
fontSize: "clamp(".concat(fontSize - 3, "px, 1.2vw, ").concat(fontSize + 1, "px)"),
|
|
571
|
+
borderRight: '1px solid #D7D7D7',
|
|
572
|
+
borderTop: '1px solid #D7D7D7',
|
|
573
|
+
padding: '7px',
|
|
574
|
+
margin: 0,
|
|
575
|
+
'& .Mui-TableHeadCell-ResizeHandle-Wrapper': {
|
|
576
|
+
padding: '0 !important',
|
|
577
|
+
width: '2px !important'
|
|
578
|
+
},
|
|
579
|
+
'& .MuiBox-root.css-17xkj1h': {
|
|
580
|
+
padding: '0 !important',
|
|
581
|
+
margin: '0 !important'
|
|
582
|
+
},
|
|
583
|
+
'& .MuiInputBase-root': {
|
|
584
|
+
fontSize: "clamp(".concat(fontSize - 4, "px, 1vw, ").concat(fontSize - 1, "px)"),
|
|
585
|
+
height: '17px',
|
|
586
|
+
padding: '0 2px',
|
|
587
|
+
width: '100%',
|
|
588
|
+
margin: 0
|
|
589
|
+
},
|
|
590
|
+
'& .MuiFormHelperText-root': {
|
|
591
|
+
fontSize: "clamp(".concat(fontSize - 4, "px, 0.9vw, ").concat(fontSize - 2, "px)")
|
|
592
|
+
},
|
|
593
|
+
'& .MuiCollapse-root': {
|
|
594
|
+
maxHeight: enableColumnFilterModes ? '37px' : '17px'
|
|
595
|
+
}
|
|
596
|
+
} : {
|
|
448
597
|
fontWeight: 'bold',
|
|
449
598
|
// fontSize: '11px',
|
|
450
599
|
fontSize: '14px',
|
|
451
600
|
borderRight: '1px solid #D7D7D7',
|
|
452
601
|
borderTop: '1px solid #D7D7D7',
|
|
453
602
|
padding: 'auto'
|
|
454
|
-
}
|
|
603
|
+
})
|
|
455
604
|
},
|
|
456
|
-
muiTableBodyCellProps: function muiTableBodyCellProps(
|
|
457
|
-
var row =
|
|
605
|
+
muiTableBodyCellProps: function muiTableBodyCellProps(_ref5) {
|
|
606
|
+
var row = _ref5.row;
|
|
458
607
|
var isDisabled = disableRows.length > 0 ? disableRows.includes(row.original[rowKey]) : false;
|
|
459
608
|
return {
|
|
460
|
-
sx: {
|
|
609
|
+
sx: _objectSpread(_objectSpread({
|
|
461
610
|
fontWeight: row.getIsSelected() ? "bold" : "normal",
|
|
462
611
|
backgroundColor: isDisabled ? "#e3e3e3" : row.depth === 1 ? "lightgrey" : row.depth === 2 ? "grey" : "white",
|
|
463
612
|
borderRight: "1px solid #D7D7D7",
|
|
613
|
+
minHeight: rowHeight
|
|
614
|
+
}, enableCompactStyleMode ? {
|
|
615
|
+
padding: '2px',
|
|
616
|
+
paddingLeft: row.depth ? "".concat(row.depth * 7, " px") : '7px',
|
|
617
|
+
boxSizing: 'border-box',
|
|
618
|
+
fontSize: "clamp(".concat(fontSize - 3, "px, 1.1vw, ").concat(fontSize, "px)"),
|
|
619
|
+
whiteSpace: 'nowrap'
|
|
620
|
+
} : {
|
|
464
621
|
padding: "auto",
|
|
465
|
-
height: rowHeight,
|
|
466
622
|
paddingLeft: row.depth ? "".concat(row.depth * 15, "px") : "12px",
|
|
467
623
|
boxSizing: "border-box"
|
|
468
|
-
}
|
|
624
|
+
}), getRowStyle && getRowStyle({
|
|
625
|
+
row: row
|
|
626
|
+
}))
|
|
469
627
|
};
|
|
470
628
|
},
|
|
471
|
-
muiTableBodyRowProps: function muiTableBodyRowProps(
|
|
472
|
-
var row =
|
|
629
|
+
muiTableBodyRowProps: function muiTableBodyRowProps(_ref6) {
|
|
630
|
+
var row = _ref6.row;
|
|
473
631
|
return {
|
|
474
632
|
style: {
|
|
475
633
|
backgroundColor: row.depth > 0 ? '#f0f0f0' : 'white'
|
|
@@ -506,14 +664,17 @@ var DataGrid = function DataGrid(_ref) {
|
|
|
506
664
|
}
|
|
507
665
|
},
|
|
508
666
|
muiTableHeadCellProps: {
|
|
509
|
-
sx: {
|
|
510
|
-
|
|
511
|
-
|
|
667
|
+
sx: _objectSpread(_objectSpread({}, enableCompactStyleMode ? {
|
|
668
|
+
fontSize: "".concat(fontSize, " px"),
|
|
669
|
+
justifyContent: 'center'
|
|
670
|
+
} : {
|
|
512
671
|
fontSize: '14px',
|
|
513
|
-
borderRight: '1px solid #D7D7D7',
|
|
514
|
-
borderTop: '1px solid #D7D7D7',
|
|
515
672
|
padding: enableMultiRowSelection && '0 18px'
|
|
516
|
-
}
|
|
673
|
+
}), {}, {
|
|
674
|
+
fontWeight: 'bold',
|
|
675
|
+
borderRight: '1px solid #D7D7D7',
|
|
676
|
+
borderTop: '1px solid #D7D7D7'
|
|
677
|
+
})
|
|
517
678
|
}
|
|
518
679
|
},
|
|
519
680
|
'mrt-row-expand': {
|
|
@@ -547,11 +708,12 @@ var DataGrid = function DataGrid(_ref) {
|
|
|
547
708
|
onRowSelectionChange: setRowSelection,
|
|
548
709
|
onSortingChange: setSorting,
|
|
549
710
|
enablePagination: enablePagination,
|
|
550
|
-
|
|
711
|
+
enableTopToolbar: enableTopToolbar,
|
|
712
|
+
enableBottomToolbar: enableBottomToolbar,
|
|
551
713
|
enableExpanding: enableExpanding,
|
|
552
714
|
// the subrow only affect the subrow checkbox and the parent row checkbox is not affected, the parent row checkbox is only affected by the parent row checkbox
|
|
553
|
-
muiSelectCheckboxProps: function muiSelectCheckboxProps(
|
|
554
|
-
var row =
|
|
715
|
+
muiSelectCheckboxProps: function muiSelectCheckboxProps(_ref7) {
|
|
716
|
+
var row = _ref7.row;
|
|
555
717
|
return hasSubRows && {
|
|
556
718
|
checked: rowSelection[row.id] || false,
|
|
557
719
|
indeterminate: false,
|
|
@@ -570,12 +732,6 @@ var DataGrid = function DataGrid(_ref) {
|
|
|
570
732
|
});
|
|
571
733
|
}
|
|
572
734
|
};
|
|
573
|
-
},
|
|
574
|
-
muiTableHeadProps: {
|
|
575
|
-
className: 'grid-sticky-header'
|
|
576
|
-
},
|
|
577
|
-
muiTopToolbarProps: {
|
|
578
|
-
className: 'grid-sticky-actions'
|
|
579
735
|
}
|
|
580
736
|
// renderToolbarAlertBannerContent: (e) => {
|
|
581
737
|
// console.log(e);
|
|
@@ -585,6 +741,15 @@ var DataGrid = function DataGrid(_ref) {
|
|
|
585
741
|
// </div>
|
|
586
742
|
// )}
|
|
587
743
|
});
|
|
744
|
+
(0, _react.useEffect)(function () {
|
|
745
|
+
var rows = table.getRowModel().rows.map(function (r) {
|
|
746
|
+
return r.original;
|
|
747
|
+
});
|
|
748
|
+
onVisibleRowsChange === null || onVisibleRowsChange === void 0 || onVisibleRowsChange(rows);
|
|
749
|
+
}, [table.getRowModel().rows]);
|
|
750
|
+
(0, _react.useEffect)(function () {
|
|
751
|
+
return (0, _gridFixedHeader["default"])('fixed-header', enableFixedHeader);
|
|
752
|
+
}, []);
|
|
588
753
|
return /*#__PURE__*/_react["default"].createElement(_xDatePickers.LocalizationProvider, {
|
|
589
754
|
dateAdapter: _AdapterDateFns.AdapterDateFns
|
|
590
755
|
}, open && /*#__PURE__*/_react["default"].createElement(_GridHelper["default"], {
|
|
@@ -594,9 +759,11 @@ var DataGrid = function DataGrid(_ref) {
|
|
|
594
759
|
open: open,
|
|
595
760
|
title: gridHelper.title,
|
|
596
761
|
content: gridHelper.content
|
|
597
|
-
}), /*#__PURE__*/_react["default"].createElement(
|
|
762
|
+
}), /*#__PURE__*/_react["default"].createElement("span", {
|
|
763
|
+
id: "fixed-header"
|
|
764
|
+
}, /*#__PURE__*/_react["default"].createElement(_materialReactTable.MaterialReactTable, {
|
|
598
765
|
table: table
|
|
599
|
-
}));
|
|
766
|
+
})));
|
|
600
767
|
};
|
|
601
768
|
DataGrid.propTypes = {
|
|
602
769
|
columns: _propTypes["default"].array.isRequired,
|
|
@@ -612,7 +779,7 @@ DataGrid.propTypes = {
|
|
|
612
779
|
"function": _propTypes["default"].func.isRequired,
|
|
613
780
|
tooltip: _propTypes["default"].string,
|
|
614
781
|
color: _propTypes["default"].oneOf(['blue', 'red', 'green', 'yellow', 'orange', 'black', 'grey', 'teal', 'brown', 'violet', 'purple', 'olive', 'pink']),
|
|
615
|
-
icon: _propTypes["default"].oneOfType([_propTypes["default"].element, _propTypes["default"].string])
|
|
782
|
+
icon: _propTypes["default"].oneOfType([_propTypes["default"].element, _propTypes["default"].string]),
|
|
616
783
|
selectionMode: _propTypes["default"].oneOf(['single', 'multi', 'always']),
|
|
617
784
|
confirmMessage: _propTypes["default"].oneOfType([_propTypes["default"].element, _propTypes["default"].string]),
|
|
618
785
|
hasConfirmMessage: _propTypes["default"].bool
|
|
@@ -628,12 +795,16 @@ DataGrid.propTypes = {
|
|
|
628
795
|
// defines the export pdf option
|
|
629
796
|
rowHeight: _propTypes["default"].number,
|
|
630
797
|
// defines the row height
|
|
798
|
+
fontSize: _propTypes["default"].number,
|
|
799
|
+
// defines the font size
|
|
631
800
|
globalFilterFn: _propTypes["default"].oneOf(['contains', 'fuzzy', 'between', 'equals', 'greaterThan', 'lessThan', 'notEquals', 'lessThanOrEqualTo', 'greaterThanOrEqualTo', 'empty', 'notEmpty', 'startsWith', 'endsWith', 'endsWith', 'betweenInclusive']),
|
|
632
801
|
// defines the global filter option
|
|
633
802
|
disableSelect: _propTypes["default"].bool,
|
|
634
803
|
// defines whether the data grid has row selection (checkboxes)
|
|
635
804
|
enableColumnFilterModes: _propTypes["default"].bool,
|
|
636
805
|
// enables/disables column filtering modes
|
|
806
|
+
hasClearFiltersBtn: _propTypes["default"].bool,
|
|
807
|
+
// Defines whether there is an clear filters button
|
|
637
808
|
pagination: _propTypes["default"].oneOf(['top', 'bottom', 'both']),
|
|
638
809
|
// defines the pagination position
|
|
639
810
|
itemsPerPage: _propTypes["default"].arrayOf(_propTypes["default"].number),
|
|
@@ -648,6 +819,12 @@ DataGrid.propTypes = {
|
|
|
648
819
|
enableFullScreenToggle: _propTypes["default"].bool,
|
|
649
820
|
enableDensityToggle: _propTypes["default"].bool,
|
|
650
821
|
enableGlobalFilter: _propTypes["default"].bool,
|
|
822
|
+
enableTopToolbar: _propTypes["default"].bool,
|
|
823
|
+
// Defines whether there is top toolbar
|
|
824
|
+
enableBottomToolbar: _propTypes["default"].bool,
|
|
825
|
+
// Defines whether there is bottom toolbar
|
|
826
|
+
enablePagination: _propTypes["default"].bool,
|
|
827
|
+
// Defines whether there is an pagination
|
|
651
828
|
enableVirtualization: _propTypes["default"].bool,
|
|
652
829
|
gridHeight: _propTypes["default"].oneOfType([_propTypes["default"].number, _propTypes["default"].string]),
|
|
653
830
|
// defines the height of the grid content, can be a number like 600, or a string like '600px' or 'fit-content'
|
|
@@ -659,7 +836,19 @@ DataGrid.propTypes = {
|
|
|
659
836
|
]),
|
|
660
837
|
disableRows: _propTypes["default"].array,
|
|
661
838
|
selectAllMode: _propTypes["default"].string,
|
|
662
|
-
|
|
839
|
+
onVisibleRowsChange: _propTypes["default"].func,
|
|
840
|
+
// Function called with the currently visible rows whenever the table updates its visible row model.
|
|
841
|
+
enableFixedHeader: _propTypes["default"].bool,
|
|
842
|
+
// Defines whether action buttons and headers are pinned to the top
|
|
843
|
+
updateCache: _propTypes["default"].func,
|
|
844
|
+
// Function triggered when the cache update button is clicked.
|
|
845
|
+
cacheUpdateText: _propTypes["default"].string,
|
|
846
|
+
// Tooltip text shown on hover over the cache update button.
|
|
847
|
+
cacheUpdating: _propTypes["default"].bool,
|
|
848
|
+
// Indicates whether a cache update is currently in progress.
|
|
849
|
+
getRowStyle: _propTypes["default"].func,
|
|
850
|
+
// Function that defines custom styles for each row.
|
|
851
|
+
enableCompactStyleMode: _propTypes["default"].bool // Enables/disables the compact style mode
|
|
663
852
|
};
|
|
664
853
|
var _default = exports["default"] = DataGrid; // DataGrid.defaultProps = {
|
|
665
854
|
// hasExcelExport: false,
|
|
@@ -12,4 +12,20 @@
|
|
|
12
12
|
.clearFilter:hover {
|
|
13
13
|
background-color: #ff8c18;
|
|
14
14
|
/* box-shadow: 0 0 0 1px rgb(206, 145, 0); */
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.fixed-position {
|
|
18
|
+
position: fixed !important;
|
|
19
|
+
z-Index: 99 !important;
|
|
20
|
+
width: calc(100% - 50px) !important;
|
|
21
|
+
background-color: white !important;
|
|
22
|
+
top: 0 !important;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.fixed-actions {
|
|
26
|
+
position: fixed !important;
|
|
27
|
+
z-Index: 99 !important;
|
|
28
|
+
width: calc(100% - 50px) !important;
|
|
29
|
+
background-color: white !important;
|
|
30
|
+
top: 70px !important;
|
|
15
31
|
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = gridFixedHeader;
|
|
7
|
+
/**
|
|
8
|
+
* Makes a MUI-DataGrid header – and optionally its toolbar – stick to the top
|
|
9
|
+
* once the page is scrolled past a given point.
|
|
10
|
+
*
|
|
11
|
+
* @param {string|null} referenceDiv – id of a wrapper element whose top edge defines the sticky offset.
|
|
12
|
+
* @param {boolean} fixedGridActions – if true, also pin the toolbar (class "Mui-ToolbarDropZone").
|
|
13
|
+
*
|
|
14
|
+
* @returns {Function} cleanup – call if you need to remove the scroll listener.
|
|
15
|
+
*/
|
|
16
|
+
function gridFixedHeader(referenceDiv) {
|
|
17
|
+
var fixedGridActions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
18
|
+
var cssClassName = 'fixed-position';
|
|
19
|
+
var gridHeaderRowClassName = 'grid-sticky-header';
|
|
20
|
+
var cssActionsClassName = 'fixed-actions';
|
|
21
|
+
var gridToolbarClassName = 'grid-sticky-actions';
|
|
22
|
+
var handleScroll = function handleScroll() {
|
|
23
|
+
var _refEl$getBoundingCli;
|
|
24
|
+
var refEl = referenceDiv ? document.getElementById(referenceDiv) : null;
|
|
25
|
+
var headerEl = (refEl !== null && refEl !== void 0 ? refEl : document).getElementsByClassName(gridHeaderRowClassName)[0];
|
|
26
|
+
var toolbarEl = fixedGridActions ? (refEl !== null && refEl !== void 0 ? refEl : document).getElementsByClassName(gridToolbarClassName)[0] : null;
|
|
27
|
+
if (!headerEl) return;
|
|
28
|
+
var offset = referenceDiv ? window.scrollY + ((_refEl$getBoundingCli = refEl === null || refEl === void 0 ? void 0 : refEl.getBoundingClientRect().top) !== null && _refEl$getBoundingCli !== void 0 ? _refEl$getBoundingCli : 0) : 270;
|
|
29
|
+
if (window.scrollY > offset) {
|
|
30
|
+
headerEl.classList.add(cssClassName);
|
|
31
|
+
toolbarEl === null || toolbarEl === void 0 || toolbarEl.classList.add(cssActionsClassName);
|
|
32
|
+
var spacer = ((toolbarEl === null || toolbarEl === void 0 ? void 0 : toolbarEl.offsetHeight) || 0) + ((headerEl === null || headerEl === void 0 ? void 0 : headerEl.offsetHeight) || 0);
|
|
33
|
+
(refEl !== null && refEl !== void 0 ? refEl : document.body).style.paddingTop = "".concat(spacer, "px");
|
|
34
|
+
} else {
|
|
35
|
+
headerEl.classList.remove(cssClassName);
|
|
36
|
+
toolbarEl === null || toolbarEl === void 0 || toolbarEl.classList.remove(cssActionsClassName);
|
|
37
|
+
(refEl !== null && refEl !== void 0 ? refEl : document.body).style.paddingTop = '';
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
window.addEventListener('scroll', handleScroll, {
|
|
41
|
+
passive: true
|
|
42
|
+
});
|
|
43
|
+
handleScroll();
|
|
44
|
+
return function () {
|
|
45
|
+
return window.removeEventListener('scroll', handleScroll);
|
|
46
|
+
};
|
|
47
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@insticc/react-datagrid-2",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.12",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"@mui/styled-engine-sc": "^6.0.0-alpha.18",
|
|
36
36
|
"@mui/x-data-grid": "^7.1.0",
|
|
37
37
|
"@mui/x-date-pickers": "^7.1.0",
|
|
38
|
+
"babel": "^6.23.0",
|
|
38
39
|
"bootstrap": "^5.3.3",
|
|
39
40
|
"date-fns": "^2.29.3",
|
|
40
41
|
"jspdf": "^2.5.1",
|