@pdg/react-table 1.0.127 → 1.0.129
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/Table/Table.types.d.ts +10 -2
- package/dist/TableContext/TableContext.types.d.ts +2 -2
- package/dist/TableSortableBody/TableSortableBody.d.ts +4 -0
- package/dist/TableSortableBody/TableSortableBody.types.d.ts +8 -0
- package/dist/TableSortableBody/index.d.ts +4 -0
- package/dist/TableSortableBodyBlock/TableSortableBodyBlock.d.ts +4 -0
- package/dist/TableSortableBodyBlock/TableSortableBodyBlock.types.d.ts +4 -0
- package/dist/TableSortableBodyBlock/index.d.ts +4 -0
- package/dist/index.esm.js +387 -302
- package/dist/index.js +387 -302
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
'use strict';var React=require('react'),classNames=require('classnames'),material=require('@mui/material'),reactResizeDetector=require('react-resize-detector'),
|
|
1
|
+
'use strict';var React=require('react'),classNames=require('classnames'),material=require('@mui/material'),reactResizeDetector=require('react-resize-detector'),reactHook=require('@pdg/react-hook'),core=require('@dnd-kit/core'),sortable=require('@dnd-kit/sortable'),SimpleBar=require('simplebar-react');require('simplebar-react/dist/simplebar.min.css');var uuid=require('uuid'),dayjs=require('dayjs'),util=require('@pdg/util'),reactIntersectionObserver=require('react-intersection-observer'),reactForm=require('@pdg/react-form'),reactComponent=require('@pdg/react-component');function styleInject(css, ref) {
|
|
2
2
|
if ( ref === void 0 ) ref = {};
|
|
3
3
|
var insertAt = ref.insertAt;
|
|
4
4
|
|
|
@@ -83,57 +83,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
83
83
|
});
|
|
84
84
|
});
|
|
85
85
|
var StyledNoDataDiv = material.styled('div')(templateObject_1$4 || (templateObject_1$4 = __makeTemplateObject(["\n text-align: center;\n padding: 30px 0;\n font-weight: 500;\n font-size: 13px;\n color: #94a0b2;\n opacity: 0.8;\n\n .material-icons {\n font-size: 40px;\n margin-bottom: 5px;\n }\n"], ["\n text-align: center;\n padding: 30px 0;\n font-weight: 500;\n font-size: 13px;\n color: #94a0b2;\n opacity: 0.8;\n\n .material-icons {\n font-size: 40px;\n margin-bottom: 5px;\n }\n"])));
|
|
86
|
-
var templateObject_1$4;
|
|
87
|
-
Translate: {
|
|
88
|
-
toString(transform) {
|
|
89
|
-
if (!transform) {
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
const {
|
|
94
|
-
x,
|
|
95
|
-
y
|
|
96
|
-
} = transform;
|
|
97
|
-
return "translate3d(" + (x ? Math.round(x) : 0) + "px, " + (y ? Math.round(y) : 0) + "px, 0)";
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
},
|
|
101
|
-
Scale: {
|
|
102
|
-
toString(transform) {
|
|
103
|
-
if (!transform) {
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
const {
|
|
108
|
-
scaleX,
|
|
109
|
-
scaleY
|
|
110
|
-
} = transform;
|
|
111
|
-
return "scaleX(" + scaleX + ") scaleY(" + scaleY + ")";
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
},
|
|
115
|
-
Transform: {
|
|
116
|
-
toString(transform) {
|
|
117
|
-
if (!transform) {
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
return [CSS.Translate.toString(transform), CSS.Scale.toString(transform)].join(' ');
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
},
|
|
125
|
-
Transition: {
|
|
126
|
-
toString(_ref) {
|
|
127
|
-
let {
|
|
128
|
-
property,
|
|
129
|
-
duration,
|
|
130
|
-
easing
|
|
131
|
-
} = _ref;
|
|
132
|
-
return property + " " + duration + "ms " + easing;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
}
|
|
136
|
-
});function getTableColumnAlign(column, defaultAlign) {
|
|
86
|
+
var templateObject_1$4;function getTableColumnAlign(column, defaultAlign) {
|
|
137
87
|
switch (column.type) {
|
|
138
88
|
case 'number':
|
|
139
89
|
return column.align ? column.align : 'right';
|
|
@@ -170,7 +120,6 @@ function typographyColorToSxColor(color) {
|
|
|
170
120
|
}var TableContextDefaultValue = {
|
|
171
121
|
menuOpen: false,
|
|
172
122
|
openMenuId: undefined,
|
|
173
|
-
inViewRender: false,
|
|
174
123
|
setMenuOpen: function () { },
|
|
175
124
|
setItemColumnChecked: function () { },
|
|
176
125
|
setItemColumnCheckDisabled: function () { },
|
|
@@ -340,19 +289,286 @@ var TableCommonCell = React.forwardRef(function (_a, ref) {
|
|
|
340
289
|
* ******************************************************************************************************************/
|
|
341
290
|
return (React.createElement(StyledTableCell, { ref: ref, align: align, className: classNames(className, 'TableCommonCell', ellipsis && 'ellipsis', column.type ? "column-type-".concat(column.type) : false), style: style, sx: sx, onClick: type === 'body' ? handleClick : undefined }, children));
|
|
342
291
|
});
|
|
343
|
-
var templateObject_1$3;var
|
|
292
|
+
var templateObject_1$3;var TableFooterCell = function (_a) {
|
|
293
|
+
/********************************************************************************************************************
|
|
294
|
+
* Memo
|
|
295
|
+
* ******************************************************************************************************************/
|
|
296
|
+
var column = _a.column, items = _a.items, defaultAlign = _a.defaultAlign;
|
|
297
|
+
var data = React.useMemo(function () {
|
|
298
|
+
var _a, _b, _c;
|
|
299
|
+
if ((_a = column.footer) === null || _a === void 0 ? void 0 : _a.onRender) {
|
|
300
|
+
return (_b = column.footer) === null || _b === void 0 ? void 0 : _b.onRender(items);
|
|
301
|
+
}
|
|
302
|
+
else {
|
|
303
|
+
return (_c = column.footer) === null || _c === void 0 ? void 0 : _c.value;
|
|
304
|
+
}
|
|
305
|
+
}, [column.footer, items]);
|
|
306
|
+
/********************************************************************************************************************
|
|
307
|
+
* Render
|
|
308
|
+
* ******************************************************************************************************************/
|
|
309
|
+
return (React.createElement(TableCommonCell, { type: 'head', className: 'TableFooterCell', column: column, defaultAlign: defaultAlign }, data));
|
|
310
|
+
};var TablePagination = function (_a) {
|
|
311
|
+
var className = _a.className, style = _a.style, sx = _a.sx, paging = _a.paging, align = _a.align, onChange = _a.onChange;
|
|
312
|
+
return (React.createElement(material.Stack, { alignItems: align },
|
|
313
|
+
React.createElement(material.Pagination, { count: paging.last_page, page: paging.current_page, color: 'primary', className: classNames('TablePagination', className), style: style, sx: sx, onChange: function (e, page) {
|
|
314
|
+
if (onChange)
|
|
315
|
+
onChange(page);
|
|
316
|
+
} })));
|
|
317
|
+
};var TableContextProvider = function (_a) {
|
|
318
|
+
var children = _a.children, value = _a.value;
|
|
319
|
+
return React.createElement(TableContext.Provider, { value: value }, children);
|
|
320
|
+
};var TableTopHeadCaptionRow = material.styled(material.TableRow)(function (_a) {
|
|
321
|
+
var theme = _a.theme;
|
|
322
|
+
return ({
|
|
323
|
+
'> th': {
|
|
324
|
+
backgroundColor: theme.palette.grey.A100,
|
|
325
|
+
textAlign: 'center',
|
|
326
|
+
fontWeight: 700,
|
|
327
|
+
},
|
|
328
|
+
});
|
|
329
|
+
});var TableHeadCell = function (_a) {
|
|
330
|
+
/********************************************************************************************************************
|
|
331
|
+
* Use
|
|
332
|
+
* ******************************************************************************************************************/
|
|
333
|
+
var column = _a.column, items = _a.items, defaultAlign = _a.defaultAlign, top = _a.top, onCheckChange = _a.onCheckChange;
|
|
334
|
+
var _b = useTableState(), setHeadColumnChecked = _b.setHeadColumnChecked, setHeadColumnCommands = _b.setHeadColumnCommands;
|
|
335
|
+
/********************************************************************************************************************
|
|
336
|
+
* State
|
|
337
|
+
* ******************************************************************************************************************/
|
|
338
|
+
var _c = React.useState(false), checked = _c[0], setChecked = _c[1];
|
|
339
|
+
var _d = React.useState(false), checkDisabled = _d[0], setCheckDisabled = _d[1];
|
|
340
|
+
/********************************************************************************************************************
|
|
341
|
+
* Effect
|
|
342
|
+
* ******************************************************************************************************************/
|
|
343
|
+
React.useEffect(function () {
|
|
344
|
+
if (column.type === 'check') {
|
|
345
|
+
setHeadColumnChecked(column, checked);
|
|
346
|
+
}
|
|
347
|
+
}, [column, checked, setHeadColumnChecked]);
|
|
348
|
+
React.useEffect(function () {
|
|
349
|
+
setHeadColumnCommands(column, {
|
|
350
|
+
setChecked: function (checked) {
|
|
351
|
+
if (column.type === 'check') {
|
|
352
|
+
setChecked(checked);
|
|
353
|
+
}
|
|
354
|
+
},
|
|
355
|
+
setCheckDisabled: function (checkDisabled) {
|
|
356
|
+
if (column.type === 'check') {
|
|
357
|
+
setCheckDisabled(checkDisabled);
|
|
358
|
+
}
|
|
359
|
+
},
|
|
360
|
+
});
|
|
361
|
+
}, [setHeadColumnCommands, column]);
|
|
362
|
+
/********************************************************************************************************************
|
|
363
|
+
* Memo
|
|
364
|
+
* ******************************************************************************************************************/
|
|
365
|
+
var data = React.useMemo(function () {
|
|
366
|
+
var _a, _b, _c, _d;
|
|
367
|
+
if (column.type === 'check') {
|
|
368
|
+
if (column.hideAllCheck) {
|
|
369
|
+
if ((_a = column.head) === null || _a === void 0 ? void 0 : _a.onRender) {
|
|
370
|
+
return (_b = column.head) === null || _b === void 0 ? void 0 : _b.onRender(items);
|
|
371
|
+
}
|
|
372
|
+
else {
|
|
373
|
+
if (typeof column.label === 'string') {
|
|
374
|
+
return React.createElement("div", { dangerouslySetInnerHTML: { __html: column.label } });
|
|
375
|
+
}
|
|
376
|
+
else {
|
|
377
|
+
return column.label;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
else {
|
|
382
|
+
return (React.createElement(material.Checkbox, { checked: checked, disabled: checkDisabled, onChange: function (e, newChecked) {
|
|
383
|
+
setChecked(newChecked);
|
|
384
|
+
onCheckChange && onCheckChange(column, newChecked);
|
|
385
|
+
} }));
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
else {
|
|
389
|
+
if ((_c = column.head) === null || _c === void 0 ? void 0 : _c.onRender) {
|
|
390
|
+
return (_d = column.head) === null || _d === void 0 ? void 0 : _d.onRender(items);
|
|
391
|
+
}
|
|
392
|
+
else {
|
|
393
|
+
if (typeof column.label === 'string') {
|
|
394
|
+
return React.createElement("div", { dangerouslySetInnerHTML: { __html: column.label } });
|
|
395
|
+
}
|
|
396
|
+
else {
|
|
397
|
+
return column.label;
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
}, [checkDisabled, checked, column, items, onCheckChange]);
|
|
402
|
+
/********************************************************************************************************************
|
|
403
|
+
* Render
|
|
404
|
+
* ******************************************************************************************************************/
|
|
405
|
+
return (React.createElement(TableCommonCell, { type: 'head', className: 'TableHeadCell', style: top !== undefined ? { top: top } : undefined, column: column, defaultAlign: defaultAlign }, data));
|
|
406
|
+
};var BottomLine = material.styled('div')(templateObject_1$2 || (templateObject_1$2 = __makeTemplateObject(["\n height: 1px;\n position: absolute;\n left: 3px;\n right: 3px;\n bottom: 0;\n"], ["\n height: 1px;\n position: absolute;\n left: 3px;\n right: 3px;\n bottom: 0;\n"])));
|
|
407
|
+
var TableTopHead = function (_a) {
|
|
408
|
+
/********************************************************************************************************************
|
|
409
|
+
* Use
|
|
410
|
+
* ******************************************************************************************************************/
|
|
411
|
+
var columns = _a.columns, items = _a.items, rows = _a.rows, caption = _a.caption, defaultAlign = _a.defaultAlign, onCheckChange = _a.onCheckChange;
|
|
412
|
+
var theme = material.useTheme();
|
|
413
|
+
/********************************************************************************************************************
|
|
414
|
+
* Ref
|
|
415
|
+
* ******************************************************************************************************************/
|
|
416
|
+
var captionRef = React.useRef(null);
|
|
417
|
+
var row1Ref = React.useRef(null);
|
|
418
|
+
var row2Ref = React.useRef(null);
|
|
419
|
+
var row3Ref = React.useRef(null);
|
|
420
|
+
/********************************************************************************************************************
|
|
421
|
+
* ResizeDetector
|
|
422
|
+
* ******************************************************************************************************************/
|
|
423
|
+
var captionHeight = reactResizeDetector.useResizeDetector({
|
|
424
|
+
targetRef: captionRef,
|
|
425
|
+
handleWidth: false,
|
|
426
|
+
handleHeight: true,
|
|
427
|
+
}).height;
|
|
428
|
+
var row1Height = reactResizeDetector.useResizeDetector({ targetRef: row1Ref, handleWidth: false, handleHeight: true }).height;
|
|
429
|
+
var row2Height = reactResizeDetector.useResizeDetector({ targetRef: row2Ref, handleWidth: false, handleHeight: true }).height;
|
|
430
|
+
var row3Height = reactResizeDetector.useResizeDetector({ targetRef: row3Ref, handleWidth: false, handleHeight: true }).height;
|
|
431
|
+
/********************************************************************************************************************
|
|
432
|
+
* Function
|
|
433
|
+
* ******************************************************************************************************************/
|
|
434
|
+
var makeRowCells = React.useCallback(function (row, top) {
|
|
435
|
+
var totalColumns = 0;
|
|
436
|
+
var cells = row
|
|
437
|
+
.map(function (info, idx) {
|
|
438
|
+
if (info) {
|
|
439
|
+
totalColumns += info.colSpan || 1;
|
|
440
|
+
return (React.createElement(material.TableCell, { key: idx, colSpan: info.colSpan, align: info.align, style: {
|
|
441
|
+
top: top,
|
|
442
|
+
borderBottom: 0,
|
|
443
|
+
} },
|
|
444
|
+
info.label,
|
|
445
|
+
info.label != null && React.createElement(BottomLine, { style: { backgroundColor: theme.palette.divider } })));
|
|
446
|
+
}
|
|
447
|
+
})
|
|
448
|
+
.filter(function (cell) { return !!cell; });
|
|
449
|
+
if (totalColumns < columns.length) {
|
|
450
|
+
cells.push(React.createElement(material.TableCell, { key: columns.length, colSpan: columns.length - cells.length, style: { top: top, borderBottom: 0 } }));
|
|
451
|
+
}
|
|
452
|
+
return cells;
|
|
453
|
+
}, [columns, theme.palette.divider]);
|
|
454
|
+
var columnRow = React.useMemo(function () {
|
|
455
|
+
var top = (captionHeight || 0) + (row1Height || 0) + (row2Height || 0) + (row3Height || 0);
|
|
456
|
+
return (React.createElement(material.TableRow, null, columns.map(function (column, idx) { return (React.createElement(TableHeadCell, { key: idx, column: column, items: items, defaultAlign: defaultAlign, top: top, onCheckChange: onCheckChange })); })));
|
|
457
|
+
}, [captionHeight, columns, defaultAlign, items, onCheckChange, row1Height, row2Height, row3Height]);
|
|
458
|
+
/********************************************************************************************************************
|
|
459
|
+
* Variable
|
|
460
|
+
* ******************************************************************************************************************/
|
|
461
|
+
var captionRow = !!caption && (React.createElement(TableTopHeadCaptionRow, { ref: captionRef, className: 'TableTopHeadCaptionRow' },
|
|
462
|
+
React.createElement(material.TableCell, { colSpan: columns.length }, caption)));
|
|
463
|
+
/********************************************************************************************************************
|
|
464
|
+
* Render
|
|
465
|
+
* ******************************************************************************************************************/
|
|
466
|
+
if (rows) {
|
|
467
|
+
if (Array.isArray(rows[0])) {
|
|
468
|
+
return (React.createElement(material.TableHead, { className: 'TableHead' },
|
|
469
|
+
captionRow,
|
|
470
|
+
rows.map(function (row, idx) {
|
|
471
|
+
var ref = undefined;
|
|
472
|
+
var top = undefined;
|
|
473
|
+
switch (idx) {
|
|
474
|
+
case 0:
|
|
475
|
+
ref = row1Ref;
|
|
476
|
+
top = captionHeight;
|
|
477
|
+
break;
|
|
478
|
+
case 1:
|
|
479
|
+
ref = row2Ref;
|
|
480
|
+
top = (captionHeight || 0) + (row1Height || 0);
|
|
481
|
+
break;
|
|
482
|
+
case 2:
|
|
483
|
+
ref = row3Ref;
|
|
484
|
+
top = (captionHeight || 0) + (row1Height || 0) + (row2Height || 0);
|
|
485
|
+
break;
|
|
486
|
+
case 3:
|
|
487
|
+
top = (captionHeight || 0) + (row1Height || 0) + (row2Height || 0) + (row3Height || 0);
|
|
488
|
+
}
|
|
489
|
+
return (React.createElement(material.TableRow, { key: idx, ref: ref, className: 'TableHeadRow' }, makeRowCells(row, top)));
|
|
490
|
+
})));
|
|
491
|
+
}
|
|
492
|
+
else {
|
|
493
|
+
return (React.createElement(material.TableHead, { className: 'TableHead' },
|
|
494
|
+
captionRow,
|
|
495
|
+
React.createElement(material.TableRow, { ref: row1Ref, className: 'TableHeadRow' }, makeRowCells(rows, captionHeight)),
|
|
496
|
+
columnRow));
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
else {
|
|
500
|
+
return (React.createElement(material.TableHead, { className: 'TableHead' },
|
|
501
|
+
captionRow,
|
|
502
|
+
columnRow));
|
|
503
|
+
}
|
|
504
|
+
};
|
|
505
|
+
var templateObject_1$2;var makeSortableItems = function (items) {
|
|
506
|
+
return items === null || items === void 0 ? void 0 : items.map(function (_a, index) {
|
|
507
|
+
var id = _a.id, item = __rest(_a, ["id"]);
|
|
508
|
+
return __assign({ id: id == null ? "".concat(uuid.v4(), "_").concat(index) : id }, item);
|
|
509
|
+
});
|
|
510
|
+
};const CSS = /*#__PURE__*/Object.freeze({
|
|
511
|
+
Translate: {
|
|
512
|
+
toString(transform) {
|
|
513
|
+
if (!transform) {
|
|
514
|
+
return;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
const {
|
|
518
|
+
x,
|
|
519
|
+
y
|
|
520
|
+
} = transform;
|
|
521
|
+
return "translate3d(" + (x ? Math.round(x) : 0) + "px, " + (y ? Math.round(y) : 0) + "px, 0)";
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
},
|
|
525
|
+
Scale: {
|
|
526
|
+
toString(transform) {
|
|
527
|
+
if (!transform) {
|
|
528
|
+
return;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
const {
|
|
532
|
+
scaleX,
|
|
533
|
+
scaleY
|
|
534
|
+
} = transform;
|
|
535
|
+
return "scaleX(" + scaleX + ") scaleY(" + scaleY + ")";
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
},
|
|
539
|
+
Transform: {
|
|
540
|
+
toString(transform) {
|
|
541
|
+
if (!transform) {
|
|
542
|
+
return;
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
return [CSS.Translate.toString(transform), CSS.Scale.toString(transform)].join(' ');
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
},
|
|
549
|
+
Transition: {
|
|
550
|
+
toString(_ref) {
|
|
551
|
+
let {
|
|
552
|
+
property,
|
|
553
|
+
duration,
|
|
554
|
+
easing
|
|
555
|
+
} = _ref;
|
|
556
|
+
return property + " " + duration + "ms " + easing;
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
}
|
|
560
|
+
});var StyledButtonsBox = material.styled(material.Box)(templateObject_1$1 || (templateObject_1$1 = __makeTemplateObject(["\n display: flex;\n flex-wrap: wrap;\n gap: 5px;\n"], ["\n display: flex;\n flex-wrap: wrap;\n gap: 5px;\n"])));
|
|
344
561
|
var TableBodyCell = React.forwardRef(function (_a, ref) {
|
|
345
562
|
/********************************************************************************************************************
|
|
346
563
|
* Use
|
|
347
564
|
* ******************************************************************************************************************/
|
|
348
565
|
var className = _a.className, style = _a.style, sx = _a.sx, item = _a.item, index = _a.index, column = _a.column, defaultAlign = _a.defaultAlign, defaultEllipsis = _a.defaultEllipsis, onClick = _a.onClick, onCheckChange = _a.onCheckChange;
|
|
349
|
-
var _b = useTableState(), menuOpen = _b.menuOpen,
|
|
350
|
-
var _c = reactIntersectionObserver.useInView({ threshold: 0 }), inViewRef = _c.ref, inView = _c.inView;
|
|
566
|
+
var _b = useTableState(), menuOpen = _b.menuOpen, setItemColumnChecked = _b.setItemColumnChecked, setItemColumnCheckDisabled = _b.setItemColumnCheckDisabled, setItemColumnCommands = _b.setItemColumnCommands;
|
|
351
567
|
/********************************************************************************************************************
|
|
352
568
|
* State
|
|
353
569
|
* ******************************************************************************************************************/
|
|
354
|
-
var
|
|
355
|
-
var
|
|
570
|
+
var _c = React.useState(false), checked = _c[0], setChecked = _c[1];
|
|
571
|
+
var _d = React.useState(false), checkDisabled = _d[0], setCheckDisabled = _d[1];
|
|
356
572
|
/********************************************************************************************************************
|
|
357
573
|
* Effect
|
|
358
574
|
* ******************************************************************************************************************/
|
|
@@ -406,7 +622,7 @@ var TableBodyCell = React.forwardRef(function (_a, ref) {
|
|
|
406
622
|
var data;
|
|
407
623
|
if (column.type !== 'check') {
|
|
408
624
|
if (column.onRender) {
|
|
409
|
-
data = column.onRender(item, index
|
|
625
|
+
data = column.onRender(item, index);
|
|
410
626
|
}
|
|
411
627
|
else if (column.name) {
|
|
412
628
|
data = item[column.name];
|
|
@@ -515,7 +731,7 @@ var TableBodyCell = React.forwardRef(function (_a, ref) {
|
|
|
515
731
|
}
|
|
516
732
|
}
|
|
517
733
|
return data;
|
|
518
|
-
}, [column, item, index,
|
|
734
|
+
}, [column, item, index, menuOpen, checked, checkDisabled, buttonsBoxJustifyContent, onCheckChange]);
|
|
519
735
|
/********************************************************************************************************************
|
|
520
736
|
* Event Handler
|
|
521
737
|
* ******************************************************************************************************************/
|
|
@@ -531,21 +747,9 @@ var TableBodyCell = React.forwardRef(function (_a, ref) {
|
|
|
531
747
|
/********************************************************************************************************************
|
|
532
748
|
* Render
|
|
533
749
|
* ******************************************************************************************************************/
|
|
534
|
-
return (React.createElement(TableCommonCell, { ref:
|
|
535
|
-
if (inViewRender) {
|
|
536
|
-
inViewRef(cellRef);
|
|
537
|
-
}
|
|
538
|
-
if (ref) {
|
|
539
|
-
if (typeof ref === 'function') {
|
|
540
|
-
ref(cellRef);
|
|
541
|
-
}
|
|
542
|
-
else {
|
|
543
|
-
ref.current = cellRef;
|
|
544
|
-
}
|
|
545
|
-
}
|
|
546
|
-
}, type: 'body', className: classNames('TableBodyCell', className), style: style, sx: sx, column: column, defaultAlign: defaultAlign, defaultEllipsis: defaultEllipsis, item: item, index: index, onClick: column.onClick || onClick ? handleClick : undefined }, !isHidden && data));
|
|
750
|
+
return (React.createElement(TableCommonCell, { ref: ref, type: 'body', className: classNames('TableBodyCell', className), style: style, sx: sx, column: column, defaultAlign: defaultAlign, defaultEllipsis: defaultEllipsis, item: item, index: index, onClick: column.onClick || onClick ? handleClick : undefined }, !isHidden && data));
|
|
547
751
|
});
|
|
548
|
-
var templateObject_1$
|
|
752
|
+
var templateObject_1$1;var StyledBodyRow = material.styled(material.TableRow)(function (_a) {
|
|
549
753
|
var theme = _a.theme;
|
|
550
754
|
return ({
|
|
551
755
|
'&.odd-color:nth-of-type(odd):not(:hover)': {
|
|
@@ -573,224 +777,104 @@ var TableBodyRow = function (_a) {
|
|
|
573
777
|
return (React.createElement(React.Fragment, null,
|
|
574
778
|
React.createElement(StyledBodyRow, __assign({ className: classNames('TableBodyRow', className), style: sortable$1
|
|
575
779
|
? __assign(__assign({}, style), { transform: CSS.Transform.toString(transform), transition: transition }) : style }, props, sortableProps), columns.map(function (column, columnIdx) { return (React.createElement(TableBodyCell, { className: onGetColumnClassName ? onGetColumnClassName(column, item, index) : undefined, sx: onGetColumnSx ? onGetColumnSx(column, item, index) : undefined, style: onGetColumnStyle ? onGetColumnStyle(column, item, index) : undefined, key: columnIdx, index: index, item: item, defaultAlign: defaultAlign, defaultEllipsis: defaultEllipsis, column: column, onClick: onClick, onCheckChange: onCheckChange })); }))));
|
|
576
|
-
};var
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
* ******************************************************************************************************************/
|
|
580
|
-
var column = _a.column, items = _a.items, defaultAlign = _a.defaultAlign;
|
|
581
|
-
var data = React.useMemo(function () {
|
|
582
|
-
var _a, _b, _c;
|
|
583
|
-
if ((_a = column.footer) === null || _a === void 0 ? void 0 : _a.onRender) {
|
|
584
|
-
return (_b = column.footer) === null || _b === void 0 ? void 0 : _b.onRender(items);
|
|
585
|
-
}
|
|
586
|
-
else {
|
|
587
|
-
return (_c = column.footer) === null || _c === void 0 ? void 0 : _c.value;
|
|
588
|
-
}
|
|
589
|
-
}, [column.footer, items]);
|
|
590
|
-
/********************************************************************************************************************
|
|
591
|
-
* Render
|
|
592
|
-
* ******************************************************************************************************************/
|
|
593
|
-
return (React.createElement(TableCommonCell, { type: 'head', className: 'TableFooterCell', column: column, defaultAlign: defaultAlign }, data));
|
|
594
|
-
};var TablePagination = function (_a) {
|
|
595
|
-
var className = _a.className, style = _a.style, sx = _a.sx, paging = _a.paging, align = _a.align, onChange = _a.onChange;
|
|
596
|
-
return (React.createElement(material.Stack, { alignItems: align },
|
|
597
|
-
React.createElement(material.Pagination, { count: paging.last_page, page: paging.current_page, color: 'primary', className: classNames('TablePagination', className), style: style, sx: sx, onChange: function (e, page) {
|
|
598
|
-
if (onChange)
|
|
599
|
-
onChange(page);
|
|
600
|
-
} })));
|
|
601
|
-
};var TableContextProvider = function (_a) {
|
|
602
|
-
var children = _a.children, value = _a.value;
|
|
603
|
-
return React.createElement(TableContext.Provider, { value: value }, children);
|
|
604
|
-
};var TableTopHeadCaptionRow = material.styled(material.TableRow)(function (_a) {
|
|
605
|
-
var theme = _a.theme;
|
|
606
|
-
return ({
|
|
607
|
-
'> th': {
|
|
608
|
-
backgroundColor: theme.palette.grey.A100,
|
|
609
|
-
textAlign: 'center',
|
|
610
|
-
fontWeight: 700,
|
|
611
|
-
},
|
|
612
|
-
});
|
|
613
|
-
});var TableHeadCell = function (_a) {
|
|
780
|
+
};var TableSortableBodyBlock = function (_a) {
|
|
781
|
+
var items = _a.items, baseIndex = _a.baseIndex, columns = _a.columns, showOddColor = _a.showOddColor, showEvenColor = _a.showEvenColor, onGetBodyRowStyle = _a.onGetBodyRowStyle, onGetBodyRowSx = _a.onGetBodyRowSx, onGetBodyRowClassName = _a.onGetBodyRowClassName, onGetBodyColumnClassName = _a.onGetBodyColumnClassName, onGetBodyColumnStyle = _a.onGetBodyColumnStyle, onGetBodyColumnSx = _a.onGetBodyColumnSx, defaultAlign = _a.defaultAlign, defaultEllipsis = _a.defaultEllipsis, sortable = _a.sortable, onClick = _a.onClick, onCheckChange = _a.onCheckChange;
|
|
782
|
+
var progressiveVisible = useTableState().progressiveVisible;
|
|
614
783
|
/********************************************************************************************************************
|
|
615
784
|
* Use
|
|
616
785
|
* ******************************************************************************************************************/
|
|
617
|
-
var
|
|
618
|
-
var _b = useTableState(), setHeadColumnChecked = _b.setHeadColumnChecked, setHeadColumnCommands = _b.setHeadColumnCommands;
|
|
786
|
+
var _b = reactIntersectionObserver.useInView({ threshold: 0, triggerOnce: true }), ref = _b.ref, inView = _b.inView;
|
|
619
787
|
/********************************************************************************************************************
|
|
620
788
|
* State
|
|
621
789
|
* ******************************************************************************************************************/
|
|
622
|
-
var _c = React.useState(
|
|
623
|
-
var _d = React.useState(false), checkDisabled = _d[0], setCheckDisabled = _d[1];
|
|
790
|
+
var _c = React.useState(baseIndex === 0), canInView = _c[0], setCanInView = _c[1];
|
|
624
791
|
/********************************************************************************************************************
|
|
625
792
|
* Effect
|
|
626
793
|
* ******************************************************************************************************************/
|
|
627
794
|
React.useEffect(function () {
|
|
628
|
-
if (
|
|
629
|
-
|
|
795
|
+
if (progressiveVisible && baseIndex > 0) {
|
|
796
|
+
setTimeout(function () {
|
|
797
|
+
setCanInView(true);
|
|
798
|
+
}, baseIndex * util.ifUndefined(progressiveVisible.delay, 300));
|
|
630
799
|
}
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
setHeadColumnCommands(column, {
|
|
634
|
-
setChecked: function (checked) {
|
|
635
|
-
if (column.type === 'check') {
|
|
636
|
-
setChecked(checked);
|
|
637
|
-
}
|
|
638
|
-
},
|
|
639
|
-
setCheckDisabled: function (checkDisabled) {
|
|
640
|
-
if (column.type === 'check') {
|
|
641
|
-
setCheckDisabled(checkDisabled);
|
|
642
|
-
}
|
|
643
|
-
},
|
|
644
|
-
});
|
|
645
|
-
}, [setHeadColumnCommands, column]);
|
|
800
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
801
|
+
}, [progressiveVisible]);
|
|
646
802
|
/********************************************************************************************************************
|
|
647
803
|
* Memo
|
|
648
804
|
* ******************************************************************************************************************/
|
|
649
|
-
var
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
return (_d = column.head) === null || _d === void 0 ? void 0 : _d.onRender(items);
|
|
675
|
-
}
|
|
676
|
-
else {
|
|
677
|
-
if (typeof column.label === 'string') {
|
|
678
|
-
return React.createElement("div", { dangerouslySetInnerHTML: { __html: column.label } });
|
|
679
|
-
}
|
|
680
|
-
else {
|
|
681
|
-
return column.label;
|
|
682
|
-
}
|
|
683
|
-
}
|
|
684
|
-
}
|
|
685
|
-
}, [checkDisabled, checked, column, items, onCheckChange]);
|
|
805
|
+
var renderItems = React.useMemo(function () {
|
|
806
|
+
return !progressiveVisible || inView ? (items.map(function (item, idx) { return (React.createElement(TableBodyRow, { key: item.id, id: item.id, index: baseIndex + idx, className: classNames(showOddColor && 'odd-color', showEvenColor && 'even-color', onGetBodyRowClassName ? onGetBodyRowClassName(item, baseIndex + idx) : undefined), style: onGetBodyRowStyle ? onGetBodyRowStyle(item, baseIndex + idx) : undefined, sx: onGetBodyRowSx ? onGetBodyRowSx(item, baseIndex + idx) : undefined, hover: true, onGetColumnClassName: onGetBodyColumnClassName, onGetColumnStyle: onGetBodyColumnStyle, onGetColumnSx: onGetBodyColumnSx, defaultAlign: defaultAlign, defaultEllipsis: defaultEllipsis, sortable: sortable, columns: columns, item: item, onClick: onClick, onCheckChange: onCheckChange })); })) : (React.createElement(material.TableRow, { ref: canInView ? ref : undefined },
|
|
807
|
+
React.createElement(material.TableCell, { colSpan: columns.length, style: { height: progressiveVisible.rowHeight * items.length, border: 'none' } })));
|
|
808
|
+
}, [
|
|
809
|
+
baseIndex,
|
|
810
|
+
canInView,
|
|
811
|
+
columns,
|
|
812
|
+
defaultAlign,
|
|
813
|
+
defaultEllipsis,
|
|
814
|
+
inView,
|
|
815
|
+
items,
|
|
816
|
+
onCheckChange,
|
|
817
|
+
onClick,
|
|
818
|
+
onGetBodyColumnClassName,
|
|
819
|
+
onGetBodyColumnStyle,
|
|
820
|
+
onGetBodyColumnSx,
|
|
821
|
+
onGetBodyRowClassName,
|
|
822
|
+
onGetBodyRowStyle,
|
|
823
|
+
onGetBodyRowSx,
|
|
824
|
+
progressiveVisible,
|
|
825
|
+
ref,
|
|
826
|
+
showEvenColor,
|
|
827
|
+
showOddColor,
|
|
828
|
+
sortable,
|
|
829
|
+
]);
|
|
686
830
|
/********************************************************************************************************************
|
|
687
831
|
* Render
|
|
688
832
|
* ******************************************************************************************************************/
|
|
689
|
-
return
|
|
690
|
-
};var
|
|
691
|
-
var
|
|
833
|
+
return React.createElement(React.Fragment, null, renderItems);
|
|
834
|
+
};var chunkArray = function (array, size) {
|
|
835
|
+
var result = [];
|
|
836
|
+
for (var i = 0; i < array.length; i += size) {
|
|
837
|
+
result.push(array.slice(i, i + size));
|
|
838
|
+
}
|
|
839
|
+
return result;
|
|
840
|
+
};var TableSortableBody = function (_a) {
|
|
692
841
|
/********************************************************************************************************************
|
|
693
842
|
* Use
|
|
694
843
|
* ******************************************************************************************************************/
|
|
695
|
-
var columns = _a.columns,
|
|
696
|
-
var
|
|
697
|
-
/********************************************************************************************************************
|
|
698
|
-
* Ref
|
|
699
|
-
* ******************************************************************************************************************/
|
|
700
|
-
var captionRef = React.useRef(null);
|
|
701
|
-
var row1Ref = React.useRef(null);
|
|
702
|
-
var row2Ref = React.useRef(null);
|
|
703
|
-
var row3Ref = React.useRef(null);
|
|
704
|
-
/********************************************************************************************************************
|
|
705
|
-
* ResizeDetector
|
|
706
|
-
* ******************************************************************************************************************/
|
|
707
|
-
var captionHeight = reactResizeDetector.useResizeDetector({
|
|
708
|
-
targetRef: captionRef,
|
|
709
|
-
handleWidth: false,
|
|
710
|
-
handleHeight: true,
|
|
711
|
-
}).height;
|
|
712
|
-
var row1Height = reactResizeDetector.useResizeDetector({ targetRef: row1Ref, handleWidth: false, handleHeight: true }).height;
|
|
713
|
-
var row2Height = reactResizeDetector.useResizeDetector({ targetRef: row2Ref, handleWidth: false, handleHeight: true }).height;
|
|
714
|
-
var row3Height = reactResizeDetector.useResizeDetector({ targetRef: row3Ref, handleWidth: false, handleHeight: true }).height;
|
|
844
|
+
var items = _a.items, columns = _a.columns, showOddColor = _a.showOddColor, showEvenColor = _a.showEvenColor, onGetBodyRowStyle = _a.onGetBodyRowStyle, onGetBodyRowSx = _a.onGetBodyRowSx, onGetBodyRowClassName = _a.onGetBodyRowClassName, onGetBodyColumnClassName = _a.onGetBodyColumnClassName, onGetBodyColumnStyle = _a.onGetBodyColumnStyle, onGetBodyColumnSx = _a.onGetBodyColumnSx, defaultAlign = _a.defaultAlign, defaultEllipsis = _a.defaultEllipsis, sortable$1 = _a.sortable, onClick = _a.onClick, onCheckChange = _a.onCheckChange;
|
|
845
|
+
var progressiveVisible = useTableState().progressiveVisible;
|
|
715
846
|
/********************************************************************************************************************
|
|
716
|
-
*
|
|
847
|
+
* Memo
|
|
717
848
|
* ******************************************************************************************************************/
|
|
718
|
-
var
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
.map(function (info, idx) {
|
|
722
|
-
if (info) {
|
|
723
|
-
totalColumns += info.colSpan || 1;
|
|
724
|
-
return (React.createElement(material.TableCell, { key: idx, colSpan: info.colSpan, align: info.align, style: {
|
|
725
|
-
top: top,
|
|
726
|
-
borderBottom: 0,
|
|
727
|
-
} },
|
|
728
|
-
info.label,
|
|
729
|
-
info.label != null && React.createElement(BottomLine, { style: { backgroundColor: theme.palette.divider } })));
|
|
730
|
-
}
|
|
731
|
-
})
|
|
732
|
-
.filter(function (cell) { return !!cell; });
|
|
733
|
-
if (totalColumns < columns.length) {
|
|
734
|
-
cells.push(React.createElement(material.TableCell, { key: columns.length, colSpan: columns.length - cells.length, style: { top: top, borderBottom: 0 } }));
|
|
849
|
+
var renderBlock = React.useMemo(function () {
|
|
850
|
+
if (progressiveVisible) {
|
|
851
|
+
return (React.createElement(React.Fragment, null, chunkArray(items, util.ifUndefined(progressiveVisible.blockSize, 20)).map(function (bItems, index) { return (React.createElement(TableSortableBodyBlock, { key: index, items: bItems, baseIndex: index, columns: columns, showOddColor: showOddColor, showEvenColor: showEvenColor, onGetBodyRowStyle: onGetBodyRowStyle, onGetBodyRowSx: onGetBodyRowSx, onGetBodyRowClassName: onGetBodyRowClassName, onGetBodyColumnClassName: onGetBodyColumnClassName, onGetBodyColumnStyle: onGetBodyColumnStyle, onGetBodyColumnSx: onGetBodyColumnSx, defaultAlign: defaultAlign, defaultEllipsis: defaultEllipsis, sortable: sortable$1, onClick: onClick, onCheckChange: onCheckChange })); })));
|
|
735
852
|
}
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
853
|
+
else {
|
|
854
|
+
return (React.createElement(TableSortableBodyBlock, { items: items, baseIndex: 0, columns: columns, showOddColor: showOddColor, showEvenColor: showEvenColor, onGetBodyRowStyle: onGetBodyRowStyle, onGetBodyRowSx: onGetBodyRowSx, onGetBodyRowClassName: onGetBodyRowClassName, onGetBodyColumnClassName: onGetBodyColumnClassName, onGetBodyColumnStyle: onGetBodyColumnStyle, onGetBodyColumnSx: onGetBodyColumnSx, defaultAlign: defaultAlign, defaultEllipsis: defaultEllipsis, sortable: sortable$1, onClick: onClick, onCheckChange: onCheckChange }));
|
|
855
|
+
}
|
|
856
|
+
}, [
|
|
857
|
+
columns,
|
|
858
|
+
defaultAlign,
|
|
859
|
+
defaultEllipsis,
|
|
860
|
+
items,
|
|
861
|
+
onCheckChange,
|
|
862
|
+
onClick,
|
|
863
|
+
onGetBodyColumnClassName,
|
|
864
|
+
onGetBodyColumnStyle,
|
|
865
|
+
onGetBodyColumnSx,
|
|
866
|
+
onGetBodyRowClassName,
|
|
867
|
+
onGetBodyRowStyle,
|
|
868
|
+
onGetBodyRowSx,
|
|
869
|
+
progressiveVisible,
|
|
870
|
+
showEvenColor,
|
|
871
|
+
showOddColor,
|
|
872
|
+
sortable$1,
|
|
873
|
+
]);
|
|
747
874
|
/********************************************************************************************************************
|
|
748
875
|
* Render
|
|
749
876
|
* ******************************************************************************************************************/
|
|
750
|
-
|
|
751
|
-
if (Array.isArray(rows[0])) {
|
|
752
|
-
return (React.createElement(material.TableHead, { className: 'TableHead' },
|
|
753
|
-
captionRow,
|
|
754
|
-
rows.map(function (row, idx) {
|
|
755
|
-
var ref = undefined;
|
|
756
|
-
var top = undefined;
|
|
757
|
-
switch (idx) {
|
|
758
|
-
case 0:
|
|
759
|
-
ref = row1Ref;
|
|
760
|
-
top = captionHeight;
|
|
761
|
-
break;
|
|
762
|
-
case 1:
|
|
763
|
-
ref = row2Ref;
|
|
764
|
-
top = (captionHeight || 0) + (row1Height || 0);
|
|
765
|
-
break;
|
|
766
|
-
case 2:
|
|
767
|
-
ref = row3Ref;
|
|
768
|
-
top = (captionHeight || 0) + (row1Height || 0) + (row2Height || 0);
|
|
769
|
-
break;
|
|
770
|
-
case 3:
|
|
771
|
-
top = (captionHeight || 0) + (row1Height || 0) + (row2Height || 0) + (row3Height || 0);
|
|
772
|
-
}
|
|
773
|
-
return (React.createElement(material.TableRow, { key: idx, ref: ref, className: 'TableHeadRow' }, makeRowCells(row, top)));
|
|
774
|
-
})));
|
|
775
|
-
}
|
|
776
|
-
else {
|
|
777
|
-
return (React.createElement(material.TableHead, { className: 'TableHead' },
|
|
778
|
-
captionRow,
|
|
779
|
-
React.createElement(material.TableRow, { ref: row1Ref, className: 'TableHeadRow' }, makeRowCells(rows, captionHeight)),
|
|
780
|
-
columnRow));
|
|
781
|
-
}
|
|
782
|
-
}
|
|
783
|
-
else {
|
|
784
|
-
return (React.createElement(material.TableHead, { className: 'TableHead' },
|
|
785
|
-
captionRow,
|
|
786
|
-
columnRow));
|
|
787
|
-
}
|
|
788
|
-
};
|
|
789
|
-
var templateObject_1$1;var makeSortableItems = function (items) {
|
|
790
|
-
return items === null || items === void 0 ? void 0 : items.map(function (_a, index) {
|
|
791
|
-
var id = _a.id, item = __rest(_a, ["id"]);
|
|
792
|
-
return __assign({ id: id == null ? "".concat(uuid.v4(), "_").concat(index) : id }, item);
|
|
793
|
-
});
|
|
877
|
+
return sortable$1 ? (React.createElement(sortable.SortableContext, { items: items, strategy: sortable.verticalListSortingStrategy }, renderBlock)) : (renderBlock);
|
|
794
878
|
};function columnFilter(v) {
|
|
795
879
|
return v !== undefined && v !== null && v !== false;
|
|
796
880
|
}
|
|
@@ -799,7 +883,7 @@ var Table = React.forwardRef(function (_a, ref) {
|
|
|
799
883
|
/********************************************************************************************************************
|
|
800
884
|
* Ref
|
|
801
885
|
* ******************************************************************************************************************/
|
|
802
|
-
var className = _a.className, initStyle = _a.style, sx = _a.sx, caption = _a.caption, topHeadRows = _a.topHeadRows, initColumns = _a.columns, initItems = _a.items, initPaging = _a.paging, _b = _a.pagingAlign, pagingAlign = _b === void 0 ? 'center' : _b, _c = _a.defaultAlign, defaultAlign = _c === void 0 ? 'left' : _c, defaultEllipsis = _a.defaultEllipsis, initStickyHeader = _a.stickyHeader, height = _a.height, minHeight = _a.minHeight, maxHeight = _a.maxHeight, fullHeight = _a.fullHeight, showOddColor = _a.showOddColor, showEvenColor = _a.showEvenColor, _d = _a.cellPadding, cellPadding = _d === void 0 ? 13 : _d,
|
|
886
|
+
var className = _a.className, initStyle = _a.style, sx = _a.sx, caption = _a.caption, topHeadRows = _a.topHeadRows, initColumns = _a.columns, initItems = _a.items, initPaging = _a.paging, _b = _a.pagingAlign, pagingAlign = _b === void 0 ? 'center' : _b, _c = _a.defaultAlign, defaultAlign = _c === void 0 ? 'left' : _c, defaultEllipsis = _a.defaultEllipsis, initStickyHeader = _a.stickyHeader, height = _a.height, minHeight = _a.minHeight, maxHeight = _a.maxHeight, fullHeight = _a.fullHeight, showOddColor = _a.showOddColor, showEvenColor = _a.showEvenColor, _d = _a.cellPadding, cellPadding = _d === void 0 ? 13 : _d, footer = _a.footer, noData = _a.noData, pagination = _a.pagination, sortable$1 = _a.sortable, progressiveVisible = _a.progressiveVisible, onClick = _a.onClick, onGetBodyRowClassName = _a.onGetBodyRowClassName, onGetBodyRowStyle = _a.onGetBodyRowStyle, onGetBodyRowSx = _a.onGetBodyRowSx, onGetBodyColumnClassName = _a.onGetBodyColumnClassName, onGetBodyColumnStyle = _a.onGetBodyColumnStyle, onGetBodyColumnSx = _a.onGetBodyColumnSx, onPageChange = _a.onPageChange, onSortChange = _a.onSortChange, onCheckChange = _a.onCheckChange;
|
|
803
887
|
var localHeaderDataRef = React.useRef({});
|
|
804
888
|
var localBodyDataRef = React.useRef({});
|
|
805
889
|
var updateHeadCheckTimer = React.useRef(undefined);
|
|
@@ -865,19 +949,6 @@ var Table = React.forwardRef(function (_a, ref) {
|
|
|
865
949
|
}
|
|
866
950
|
},
|
|
867
951
|
}).ref;
|
|
868
|
-
/********************************************************************************************************************
|
|
869
|
-
* Memo
|
|
870
|
-
* ******************************************************************************************************************/
|
|
871
|
-
var tableSx = React.useMemo(function () {
|
|
872
|
-
var sx = {
|
|
873
|
-
padding: typeof cellPadding === 'number' ? "".concat(cellPadding, "px") : cellPadding,
|
|
874
|
-
};
|
|
875
|
-
return {
|
|
876
|
-
'> .MuiTableHead-root > .MuiTableRow-root > .MuiTableCell-root ': sx,
|
|
877
|
-
'> .MuiTableBody-root > .MuiTableRow-root > .MuiTableCell-root ': sx,
|
|
878
|
-
'> .MuiTableFooter-root > .MuiTableRow-root > .MuiTableCell-root ': sx,
|
|
879
|
-
};
|
|
880
|
-
}, [cellPadding]);
|
|
881
952
|
/********************************************************************************************************************
|
|
882
953
|
* Function
|
|
883
954
|
* ******************************************************************************************************************/
|
|
@@ -1271,28 +1342,42 @@ var Table = React.forwardRef(function (_a, ref) {
|
|
|
1271
1342
|
var isNoData = !!sortableItems && sortableItems.length <= 0;
|
|
1272
1343
|
var finalPagingHeight = paging && paging.total > 0 ? pagingHeight || 0 : 0;
|
|
1273
1344
|
var stickyHeader = !isNoData && initStickyHeader;
|
|
1274
|
-
var
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
?
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1345
|
+
var _p = React.useMemo(function () {
|
|
1346
|
+
var style = fullHeight
|
|
1347
|
+
? __assign(__assign({ width: '100%' }, initStyle), { flex: 1, justifyContent: 'flex-end', height: '100%', display: 'flex', flexDirection: 'column', position: 'relative' }) : __assign({ width: '100%' }, initStyle);
|
|
1348
|
+
var sx = { padding: typeof cellPadding === 'number' ? "".concat(cellPadding, "px") : cellPadding };
|
|
1349
|
+
var tableSx = {
|
|
1350
|
+
'> .MuiTableHead-root > .MuiTableRow-root > .MuiTableCell-root ': sx,
|
|
1351
|
+
'> .MuiTableBody-root > .MuiTableRow-root > .MuiTableCell-root ': sx,
|
|
1352
|
+
'> .MuiTableFooter-root > .MuiTableRow-root > .MuiTableCell-root ': sx,
|
|
1353
|
+
};
|
|
1354
|
+
// pageStyle
|
|
1355
|
+
var pagingStyle = { padding: '13px 0', borderTop: '1px solid rgba(224, 224, 224, 1)' };
|
|
1356
|
+
if (fullHeight) {
|
|
1357
|
+
pagingStyle.position = 'sticky';
|
|
1358
|
+
}
|
|
1359
|
+
return { style: style, tableSx: tableSx, pagingStyle: pagingStyle };
|
|
1360
|
+
}, [cellPadding, fullHeight, initStyle]), style = _p.style, tableSx = _p.tableSx, pagingStyle = _p.pagingStyle;
|
|
1361
|
+
var _q = React.useMemo(function () {
|
|
1362
|
+
var simpleBarStyle = fullHeight
|
|
1363
|
+
? {
|
|
1364
|
+
height: (containerHeight || 0) - (finalPagingHeight || 0) - 1,
|
|
1365
|
+
flex: 1,
|
|
1366
|
+
position: 'absolute',
|
|
1367
|
+
top: 0,
|
|
1368
|
+
left: 0,
|
|
1369
|
+
right: 0,
|
|
1370
|
+
marginBottom: finalPagingHeight || 0,
|
|
1371
|
+
}
|
|
1372
|
+
: { height: height, minHeight: minHeight, maxHeight: maxHeight, marginBottom: -1 };
|
|
1373
|
+
var tableStyle = fullHeight && isNoData ? { flex: 1, height: (containerHeight || 0) - finalPagingHeight - 2 } : undefined;
|
|
1374
|
+
return { simpleBarStyle: simpleBarStyle, tableStyle: tableStyle };
|
|
1375
|
+
}, [containerHeight, finalPagingHeight, fullHeight, height, isNoData, maxHeight, minHeight]), simpleBarStyle = _q.simpleBarStyle, tableStyle = _q.tableStyle;
|
|
1376
|
+
var tableTopHead = React.useMemo(function () {
|
|
1377
|
+
return finalColumns && (React.createElement(TableTopHead, { caption: caption, rows: topHeadRows, columns: finalColumns, items: items, defaultAlign: defaultAlign, onCheckChange: handleHeadCheckChange }));
|
|
1378
|
+
}, [caption, defaultAlign, finalColumns, handleHeadCheckChange, items, topHeadRows]);
|
|
1294
1379
|
var tableBody = React.useMemo(function () {
|
|
1295
|
-
return finalColumns && (React.createElement(material.TableBody, null, sortableItems ? (sortableItems.length > 0 ? (React.createElement(
|
|
1380
|
+
return finalColumns && (React.createElement(material.TableBody, null, sortableItems ? (sortableItems.length > 0 ? (React.createElement(TableSortableBody, { items: sortableItems, columns: finalColumns, showOddColor: showOddColor, showEvenColor: showEvenColor, defaultAlign: defaultAlign, defaultEllipsis: defaultEllipsis, sortable: sortable$1, onClick: onClick, onCheckChange: handleBodyCheckChange, onGetBodyRowClassName: onGetBodyRowClassName, onGetBodyRowStyle: onGetBodyRowStyle, onGetBodyRowSx: onGetBodyRowSx, onGetBodyColumnClassName: onGetBodyColumnClassName, onGetBodyColumnSx: onGetBodyColumnSx, onGetBodyColumnStyle: onGetBodyColumnStyle })) : (React.createElement(StyledBodyRow$1, null,
|
|
1296
1381
|
React.createElement(material.TableCell, { colSpan: finalColumns.length, style: { flex: 1 } }, noData ? (noData) : (React.createElement(StyledNoDataDiv, null,
|
|
1297
1382
|
React.createElement("div", null,
|
|
1298
1383
|
React.createElement(material.Icon, null, "error")),
|
|
@@ -1327,7 +1412,7 @@ var Table = React.forwardRef(function (_a, ref) {
|
|
|
1327
1412
|
return finalColumns ? (React.createElement(TableContextProvider, { value: {
|
|
1328
1413
|
menuOpen: menuOpen,
|
|
1329
1414
|
openMenuId: openMenuId,
|
|
1330
|
-
|
|
1415
|
+
progressiveVisible: progressiveVisible,
|
|
1331
1416
|
setMenuOpen: TableContextSetMenuOpen,
|
|
1332
1417
|
setItemColumnChecked: TableContextSetItemColumnChecked,
|
|
1333
1418
|
setItemColumnCheckDisabled: TableContextSetItemColumnCheckDisabled,
|