@pdg/react-table 1.0.23 → 1.0.25

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.
@@ -41,6 +41,7 @@ export interface TableColumn<T = TableItem> {
41
41
  onGetClassName?(item: T, index: number): CommonSxProps['className'];
42
42
  onGetStyle?(item: T, index: number): CommonSxProps['style'];
43
43
  onGetSx?(item: T, index: number): CommonSxProps['sx'];
44
+ onHide?(item: T, index: number): boolean;
44
45
  onGetTooltip?(item: T, index: number): ReactNode;
45
46
  onRender?(item: T, index: number): ReactNode;
46
47
  onClick?(item: T, index: number): void;
package/dist/index.esm.js CHANGED
@@ -8522,6 +8522,7 @@ var TableBodyCell = function (_a) {
8522
8522
  // eslint-disable-next-line react-hooks/exhaustive-deps
8523
8523
  }, [checkDisabled]);
8524
8524
  // Memo --------------------------------------------------------------------------------------------------------------
8525
+ var isHidden = useMemo(function () { return (column.onHide ? column.onHide(item, index) : false); }, [column, index, item]);
8525
8526
  var buttonsBoxJustifyContent = useMemo(function () {
8526
8527
  switch (getTableColumnAlign(column, defaultAlign)) {
8527
8528
  case 'center':
@@ -8614,7 +8615,7 @@ var TableBodyCell = function (_a) {
8614
8615
  }
8615
8616
  }, [column, onClick]);
8616
8617
  // Render ----------------------------------------------------------------------------------------------------------
8617
- return (React__default.createElement(TableCommonCell, { type: 'body', className: 'TableBodyCell', column: column, defaultAlign: defaultAlign, defaultEllipsis: defaultEllipsis, item: item, index: index, onClick: column.onClick || onClick ? handleClick : undefined }, data));
8618
+ return (React__default.createElement(TableCommonCell, { type: 'body', className: 'TableBodyCell', column: column, defaultAlign: defaultAlign, defaultEllipsis: defaultEllipsis, item: item, index: index, onClick: column.onClick || onClick ? handleClick : undefined }, !isHidden && data));
8618
8619
  };
8619
8620
  var templateObject_1;var StyledBodyRow = styled(TableRow)(function (_a) {
8620
8621
  var theme = _a.theme;
@@ -8858,7 +8859,7 @@ var native = {
8858
8859
  }
8859
8860
  var Table = React__default.forwardRef(function (_a, ref) {
8860
8861
  // Ref ---------------------------------------------------------------------------------------------------------------
8861
- var initColumns = _a.columns, initItems = _a.items, initPaging = _a.paging, pagingAlign = _a.pagingAlign, defaultAlign = _a.defaultAlign, defaultEllipsis = _a.defaultEllipsis, stickyHeader = _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 = _a.sortable, onClick = _a.onClick, onGetBodyRowSx = _a.onGetBodyRowSx, onPageChange = _a.onPageChange, onSortChange = _a.onSortChange, onCheckChange = _a.onCheckChange,
8862
+ var 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 = _a.sortable, onClick = _a.onClick, onGetBodyRowSx = _a.onGetBodyRowSx, onPageChange = _a.onPageChange, onSortChange = _a.onSortChange, onCheckChange = _a.onCheckChange,
8862
8863
  // ---------------------------------------------------------------------------------------------------------------
8863
8864
  className = _a.className, initStyle = _a.style, sx = _a.sx;
8864
8865
  var localHeaderDataRef = useRef({});
@@ -9207,6 +9208,7 @@ var Table = React__default.forwardRef(function (_a, ref) {
9207
9208
  // Memo --------------------------------------------------------------------------------------------------------------
9208
9209
  var isNoData = useMemo(function () { return !!sortableItems && sortableItems.length <= 0; }, [sortableItems]);
9209
9210
  var finalPagingHeight = useMemo(function () { return (paging && paging.total > 0 ? pagingHeight || 0 : 0); }, [paging, pagingHeight]);
9211
+ var stickyHeader = useMemo(function () { return !isNoData && initStickyHeader; }, [initStickyHeader, isNoData]);
9210
9212
  var style = useMemo(function () {
9211
9213
  if (fullHeight) {
9212
9214
  return __assign$1(__assign$1({ width: '100%' }, initStyle), { flex: 1, justifyContent: 'flex-end', height: '100%', display: 'flex', flexDirection: 'column', position: 'relative' });
@@ -9218,10 +9220,10 @@ var Table = React__default.forwardRef(function (_a, ref) {
9218
9220
  var simpleBarStyle = useMemo(function () {
9219
9221
  if (fullHeight) {
9220
9222
  return {
9221
- height: (containerHeight || 0) - (finalPagingHeight || 0) - 2,
9223
+ height: (containerHeight || 0) - (finalPagingHeight || 0) - 1,
9222
9224
  flex: 1,
9223
9225
  position: 'absolute',
9224
- top: 1,
9226
+ top: 0,
9225
9227
  left: 0,
9226
9228
  right: 0,
9227
9229
  marginBottom: finalPagingHeight || 0,
@@ -9245,10 +9247,10 @@ var Table = React__default.forwardRef(function (_a, ref) {
9245
9247
  }, [fullHeight]);
9246
9248
  // Render ----------------------------------------------------------------------------------------------------------
9247
9249
  return finalColumns ? (React__default.createElement(TableContextProvider, { value: tableContextValue },
9248
- React__default.createElement(Paper, { ref: fullHeight ? containerHeightDetector : undefined, className: classNames('Table', className), variant: 'outlined', style: style, sx: sx },
9250
+ React__default.createElement(Paper, { ref: fullHeight ? containerHeightDetector : undefined, className: classNames('Table', className, !!stickyHeader && 'sticky-header', !!fullHeight && 'full-height', !!showOddColor && 'odd-color', !!showEvenColor && 'even-color', !!sortable && 'sortable'), variant: 'outlined', style: style, sx: sx },
9249
9251
  React__default.createElement(SimpleBar, { style: simpleBarStyle },
9250
9252
  React__default.createElement(DndContext, { sensors: sensors, collisionDetection: closestCenter, onDragEnd: handleDragEnd },
9251
- React__default.createElement(Table$1, { stickyHeader: !isNoData && stickyHeader, sx: tableSx, style: tableStyle },
9253
+ React__default.createElement(Table$1, { stickyHeader: stickyHeader, sx: tableSx, style: tableStyle },
9252
9254
  React__default.createElement(TableHead, null,
9253
9255
  React__default.createElement(TableRow, null, finalColumns.map(function (column, idx) { return (React__default.createElement(TableHeadCell, { key: idx, column: column, defaultAlign: defaultAlign, onCheckChange: handleHeadCheckChange })); }))),
9254
9256
  React__default.createElement(TableBody, null, sortableItems ? (sortableItems.length > 0 ? (React__default.createElement(SortableContext, { items: sortableItems, strategy: verticalListSortingStrategy }, sortableItems.map(function (item, idx) { return (React__default.createElement(TableBodyRow, { key: item.id, className: classNames(!!showOddColor && 'odd-color', !!showEvenColor && 'even-color'), hover: true, sx: onGetBodyRowSx ? onGetBodyRowSx(item, idx) : undefined, id: item.id, index: idx, defaultAlign: defaultAlign, defaultEllipsis: defaultEllipsis, sortable: sortable, columns: finalColumns, item: item, onClick: onClick, onCheckChange: handleBodyCheckChange })); }))) : (React__default.createElement(StyledBodyRow$1, null,