@pdg/react-table 1.0.46 → 1.0.48
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/InfoTable/InfoTable.style.d.ts +3 -3
- package/dist/Table/Table.styles.d.ts +1 -1
- package/dist/Table/Table.types.d.ts +1 -0
- package/dist/TableBodyRow/TableBodyRow.d.ts +1 -1
- package/dist/TableButton/TableButton.d.ts +1 -1
- package/dist/TableIcon/TableIcon.d.ts +1 -1
- package/dist/TableMenuButton/TableMenuButton.d.ts +1 -1
- package/dist/TableTopHead/TableTopHead.style.d.ts +10 -0
- package/dist/TableTopHead/TableTopHead.types.d.ts +1 -0
- package/dist/index.esm.js +57 -30
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +57 -30
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3252,18 +3252,33 @@ var native = {
|
|
|
3252
3252
|
}
|
|
3253
3253
|
|
|
3254
3254
|
return unsafeStringify(rnds);
|
|
3255
|
-
}var TableTopHeadDefaultProps = {};var
|
|
3255
|
+
}var TableTopHeadDefaultProps = {};var TableTopHeadCaptionRow = material.styled(material.TableRow)(function (_a) {
|
|
3256
|
+
var theme = _a.theme;
|
|
3257
|
+
return ({
|
|
3258
|
+
'> th': {
|
|
3259
|
+
backgroundColor: theme.palette.grey.A100,
|
|
3260
|
+
textAlign: 'center',
|
|
3261
|
+
fontWeight: 700,
|
|
3262
|
+
},
|
|
3263
|
+
});
|
|
3264
|
+
});var BottomLine = material.styled('div')(templateObject_1$1 || (templateObject_1$1 = __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"])));
|
|
3256
3265
|
var TableTopHead = function (_a) {
|
|
3257
3266
|
// Use ---------------------------------------------------------------------------------------------------------------
|
|
3258
|
-
var columnLength = _a.columnLength, rows = _a.rows, onHeightChange = _a.onHeightChange;
|
|
3267
|
+
var columnLength = _a.columnLength, rows = _a.rows, caption = _a.caption, onHeightChange = _a.onHeightChange;
|
|
3259
3268
|
var theme = material.useTheme();
|
|
3260
3269
|
// Ref ---------------------------------------------------------------------------------------------------------------
|
|
3261
3270
|
var headRef = React.useRef(null);
|
|
3271
|
+
var captionRef = React.useRef(null);
|
|
3262
3272
|
var row1Ref = React.useRef(null);
|
|
3263
3273
|
var row2Ref = React.useRef(null);
|
|
3264
3274
|
var row3Ref = React.useRef(null);
|
|
3265
3275
|
// ResizeDetector ----------------------------------------------------------------------------------------------------
|
|
3266
3276
|
var headHeight = useResizeDetector({ targetRef: headRef, handleWidth: false, handleHeight: true }).height;
|
|
3277
|
+
var captionHeight = useResizeDetector({
|
|
3278
|
+
targetRef: captionRef,
|
|
3279
|
+
handleWidth: false,
|
|
3280
|
+
handleHeight: true,
|
|
3281
|
+
}).height;
|
|
3267
3282
|
var row1Height = useResizeDetector({ targetRef: row1Ref, handleWidth: false, handleHeight: true }).height;
|
|
3268
3283
|
var row2Height = useResizeDetector({ targetRef: row2Ref, handleWidth: false, handleHeight: true }).height;
|
|
3269
3284
|
var row3Height = useResizeDetector({ targetRef: row3Ref, handleWidth: false, handleHeight: true }).height;
|
|
@@ -3272,6 +3287,10 @@ var TableTopHead = function (_a) {
|
|
|
3272
3287
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3273
3288
|
}, [headHeight]);
|
|
3274
3289
|
// Function ----------------------------------------------------------------------------------------------------------
|
|
3290
|
+
var captionRow = React.useMemo(function () {
|
|
3291
|
+
return !!caption && (React.createElement(TableTopHeadCaptionRow, { ref: captionRef, className: 'TableTopHeadCaptionRow' },
|
|
3292
|
+
React.createElement(material.TableCell, { colSpan: columnLength }, caption)));
|
|
3293
|
+
}, [caption, columnLength]);
|
|
3275
3294
|
var makeRowCells = React.useCallback(function (row, top) {
|
|
3276
3295
|
var cells = row
|
|
3277
3296
|
.map(function (info, idx) {
|
|
@@ -3289,34 +3308,42 @@ var TableTopHead = function (_a) {
|
|
|
3289
3308
|
return cells;
|
|
3290
3309
|
}, [columnLength, theme.palette.divider]);
|
|
3291
3310
|
// Render ------------------------------------------------------------------------------------------------------------
|
|
3292
|
-
if (!rows || rows.length === 0)
|
|
3311
|
+
if ((!rows || rows.length === 0) && caption === null)
|
|
3293
3312
|
return null;
|
|
3294
|
-
if (
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3313
|
+
if (rows) {
|
|
3314
|
+
if (Array.isArray(rows[0])) {
|
|
3315
|
+
return (React.createElement(material.TableHead, { className: 'TableTopHead', ref: headRef },
|
|
3316
|
+
captionRow,
|
|
3317
|
+
rows.map(function (row, idx) {
|
|
3318
|
+
var ref = undefined;
|
|
3319
|
+
var top = undefined;
|
|
3320
|
+
switch (idx) {
|
|
3321
|
+
case 0:
|
|
3322
|
+
ref = row1Ref;
|
|
3323
|
+
top = captionHeight;
|
|
3324
|
+
break;
|
|
3325
|
+
case 1:
|
|
3326
|
+
ref = row2Ref;
|
|
3327
|
+
top = (captionHeight || 0) + (row1Height || 0);
|
|
3328
|
+
break;
|
|
3329
|
+
case 2:
|
|
3330
|
+
ref = row3Ref;
|
|
3331
|
+
top = (captionHeight || 0) + (row1Height || 0) + (row2Height || 0);
|
|
3332
|
+
break;
|
|
3333
|
+
case 3:
|
|
3334
|
+
top = (captionHeight || 0) + (row1Height || 0) + (row2Height || 0) + (row3Height || 0);
|
|
3335
|
+
}
|
|
3336
|
+
return (React.createElement(material.TableRow, { key: idx, ref: ref, className: 'TableTopHeadRow' }, makeRowCells(row, top)));
|
|
3337
|
+
})));
|
|
3338
|
+
}
|
|
3339
|
+
else {
|
|
3340
|
+
return (React.createElement(material.TableHead, { className: 'TableTopHead', ref: headRef },
|
|
3341
|
+
captionRow,
|
|
3342
|
+
React.createElement(material.TableRow, { className: 'TableTopHeadRow' }, makeRowCells(rows, captionHeight))));
|
|
3343
|
+
}
|
|
3316
3344
|
}
|
|
3317
3345
|
else {
|
|
3318
|
-
return (React.createElement(material.TableHead, { className: 'TableTopHead', ref: headRef },
|
|
3319
|
-
React.createElement(material.TableRow, null, makeRowCells(rows))));
|
|
3346
|
+
return (React.createElement(material.TableHead, { className: 'TableTopHead', ref: headRef }, captionRow));
|
|
3320
3347
|
}
|
|
3321
3348
|
};
|
|
3322
3349
|
TableTopHead.displayName = 'TableTopHead';
|
|
@@ -3326,7 +3353,7 @@ var templateObject_1$1;function columnFilter(v) {
|
|
|
3326
3353
|
}
|
|
3327
3354
|
var Table = React.forwardRef(function (_a, ref) {
|
|
3328
3355
|
// Ref ---------------------------------------------------------------------------------------------------------------
|
|
3329
|
-
var topHeadRows = _a.topHeadRows, initColumns = _a.columns, initItems = _a.items, initPaging = _a.paging, pagingAlign = _a.pagingAlign, defaultAlign = _a.defaultAlign, defaultEllipsis = _a.defaultEllipsis, initStickyHeader = _a.stickyHeader, height = _a.height, minHeight = _a.minHeight, maxHeight = _a.maxHeight, fullHeight = _a.fullHeight, showOddColor = _a.showOddColor, showEvenColor = _a.showEvenColor, cellPadding = _a.cellPadding, footer = _a.footer, noData = _a.noData, pagination = _a.pagination, sortable$1 = _a.sortable, onClick = _a.onClick, onGetBodyRowSx = _a.onGetBodyRowSx, onPageChange = _a.onPageChange, onSortChange = _a.onSortChange, onCheckChange = _a.onCheckChange,
|
|
3356
|
+
var caption = _a.caption, topHeadRows = _a.topHeadRows, initColumns = _a.columns, initItems = _a.items, initPaging = _a.paging, pagingAlign = _a.pagingAlign, defaultAlign = _a.defaultAlign, defaultEllipsis = _a.defaultEllipsis, initStickyHeader = _a.stickyHeader, height = _a.height, minHeight = _a.minHeight, maxHeight = _a.maxHeight, fullHeight = _a.fullHeight, showOddColor = _a.showOddColor, showEvenColor = _a.showEvenColor, cellPadding = _a.cellPadding, footer = _a.footer, noData = _a.noData, pagination = _a.pagination, sortable$1 = _a.sortable, onClick = _a.onClick, onGetBodyRowSx = _a.onGetBodyRowSx, onPageChange = _a.onPageChange, onSortChange = _a.onSortChange, onCheckChange = _a.onCheckChange,
|
|
3330
3357
|
// ---------------------------------------------------------------------------------------------------------------
|
|
3331
3358
|
className = _a.className, initStyle = _a.style, sx = _a.sx;
|
|
3332
3359
|
var localHeaderDataRef = React.useRef({});
|
|
@@ -3758,8 +3785,8 @@ var Table = React.forwardRef(function (_a, ref) {
|
|
|
3758
3785
|
return style;
|
|
3759
3786
|
}, [fullHeight]);
|
|
3760
3787
|
var tableTopHead = React.useMemo(function () {
|
|
3761
|
-
return finalColumns && (React.createElement(TableTopHead, { columnLength: finalColumns.length, rows: topHeadRows, onHeightChange: setTopHeadHeight }));
|
|
3762
|
-
}, [finalColumns, topHeadRows]);
|
|
3788
|
+
return finalColumns && (React.createElement(TableTopHead, { columnLength: finalColumns.length, caption: caption, rows: topHeadRows, onHeightChange: setTopHeadHeight }));
|
|
3789
|
+
}, [caption, finalColumns, topHeadRows]);
|
|
3763
3790
|
var tableHead = React.useMemo(function () {
|
|
3764
3791
|
return finalColumns && (React.createElement(material.TableHead, null,
|
|
3765
3792
|
React.createElement(material.TableRow, null, finalColumns.map(function (column, idx) { return (React.createElement(TableHeadCell, { key: idx, column: column, defaultAlign: defaultAlign, top: stickyHeader ? topHeadHeight : undefined, onCheckChange: handleHeadCheckChange })); }))));
|