@pdg/react-table 1.0.12 → 1.0.13

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.
@@ -55,6 +55,7 @@ export interface TableProps<T = TableItem> extends CommonSxProps {
55
55
  height?: string | number;
56
56
  maxHeight?: string | number;
57
57
  minHeight?: string | number;
58
+ fullHeight?: boolean;
58
59
  showOddColor?: boolean;
59
60
  showEvenColor?: boolean;
60
61
  cellPadding?: string | number;
package/dist/index.esm.js CHANGED
@@ -8699,7 +8699,7 @@ styleInject(css_248z);function columnFilter(v) {
8699
8699
  }
8700
8700
  var Table = React__default.forwardRef(function (_a, ref) {
8701
8701
  // sortable --------------------------------------------------------------------------------------------------------
8702
- 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, 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,
8702
+ 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,
8703
8703
  // ---------------------------------------------------------------------------------------------------------------
8704
8704
  className = _a.className, initStyle = _a.style, sx = _a.sx;
8705
8705
  var sensors = useSensors(useSensor(MouseSensor, {
@@ -8716,26 +8716,40 @@ var Table = React__default.forwardRef(function (_a, ref) {
8716
8716
  }), useSensor(KeyboardSensor, {
8717
8717
  coordinateGetter: sortableKeyboardCoordinates,
8718
8718
  }));
8719
+ // State - containerHeight -------------------------------------------------------------------------------------------
8720
+ var _b = useState(), containerHeight = _b[0], setContainerHeight = _b[1];
8721
+ var containerHeightDetector = useResizeDetector({
8722
+ handleHeight: true,
8723
+ handleWidth: false,
8724
+ onResize: function () {
8725
+ if (containerHeightDetector.current) {
8726
+ setContainerHeight(containerHeightDetector.current.getBoundingClientRect().height);
8727
+ }
8728
+ else {
8729
+ setContainerHeight(undefined);
8730
+ }
8731
+ },
8732
+ }).ref;
8719
8733
  // State - footerHeight --------------------------------------------------------------------------------------------
8720
- var _b = useState(), footerHeight = _b[0], setFooterHeight = _b[1];
8721
- var footerHeightResizeDetector = useResizeDetector({
8734
+ var _c = useState(), pagingHeight = _c[0], setPagingHeight = _c[1];
8735
+ var pagingHeightResizeDetector = useResizeDetector({
8722
8736
  handleHeight: true,
8723
8737
  handleWidth: false,
8724
8738
  onResize: function () {
8725
- if (footerHeightResizeDetector.current) {
8726
- setFooterHeight(footerHeightResizeDetector.current.getBoundingClientRect().height);
8739
+ if (pagingHeightResizeDetector.current) {
8740
+ setPagingHeight(pagingHeightResizeDetector.current.getBoundingClientRect().height);
8727
8741
  }
8728
8742
  else {
8729
- setFooterHeight(undefined);
8743
+ setPagingHeight(undefined);
8730
8744
  }
8731
8745
  },
8732
8746
  }).ref;
8733
8747
  // State -----------------------------------------------------------------------------------------------------------
8734
- var _c = useAutoUpdateLayoutState(initColumns), columns = _c[0], setColumns = _c[1];
8735
- var _d = useState(), finalColumns = _d[0], setFinalColumns = _d[1];
8736
- var _e = useAutoUpdateLayoutState(initItems), items = _e[0], setItems = _e[1];
8737
- var _f = useState(), sortableItems = _f[0], setSortableItems = _f[1];
8738
- var _g = useAutoUpdateLayoutState(initPaging), paging = _g[0], setPaging = _g[1];
8748
+ var _d = useAutoUpdateLayoutState(initColumns), columns = _d[0], setColumns = _d[1];
8749
+ var _e = useState(), finalColumns = _e[0], setFinalColumns = _e[1];
8750
+ var _f = useAutoUpdateLayoutState(initItems), items = _f[0], setItems = _f[1];
8751
+ var _g = useState(), sortableItems = _g[0], setSortableItems = _g[1];
8752
+ var _h = useAutoUpdateLayoutState(initPaging), paging = _h[0], setPaging = _h[1];
8739
8753
  // Memo --------------------------------------------------------------------------------------------------------------
8740
8754
  var tableSx = useMemo(function () {
8741
8755
  var sx = {
@@ -8827,32 +8841,53 @@ var Table = React__default.forwardRef(function (_a, ref) {
8827
8841
  }
8828
8842
  }, [onSortChange]);
8829
8843
  // Memo --------------------------------------------------------------------------------------------------------------
8830
- var style = useMemo(function () { return (__assign$1({ width: '100%' }, initStyle)); }, [initStyle]);
8844
+ var style = useMemo(function () {
8845
+ if (fullHeight) {
8846
+ return __assign$1(__assign$1({ width: '100%' }, initStyle), { flex: 1, justifyContent: 'flex-end', height: '100%', display: 'flex', flexDirection: 'column', position: 'relative' });
8847
+ }
8848
+ else {
8849
+ return __assign$1({ width: '100%' }, initStyle);
8850
+ }
8851
+ }, [initStyle, fullHeight]);
8852
+ var simpleBarStyle = useMemo(function () {
8853
+ if (fullHeight) {
8854
+ return {
8855
+ height: (containerHeight || 0) - (pagingHeight || 0),
8856
+ flex: 1,
8857
+ position: 'absolute',
8858
+ left: 0,
8859
+ right: 0,
8860
+ marginBottom: pagingHeight,
8861
+ };
8862
+ }
8863
+ else {
8864
+ return { height: height, minHeight: minHeight, maxHeight: maxHeight };
8865
+ }
8866
+ }, [containerHeight, fullHeight, height, maxHeight, minHeight, pagingHeight]);
8867
+ var pagingStyle = useMemo(function () {
8868
+ if (fullHeight) {
8869
+ return { position: 'sticky', padding: '13px 0' };
8870
+ }
8871
+ else {
8872
+ return { padding: '13px 0' };
8873
+ }
8874
+ }, [fullHeight]);
8831
8875
  // Render ----------------------------------------------------------------------------------------------------------
8832
- return finalColumns ? (React__default.createElement(Paper, { className: classNames('Table', className), variant: 'outlined', style: style, sx: sx },
8833
- React__default.createElement(SimpleBar, { style: { height: height, minHeight: minHeight, maxHeight: maxHeight } },
8876
+ return finalColumns ? (React__default.createElement(Paper, { ref: fullHeight ? containerHeightDetector : undefined, className: classNames('Table', className), variant: 'outlined', style: style, sx: sx },
8877
+ React__default.createElement(SimpleBar, { style: simpleBarStyle },
8834
8878
  React__default.createElement(DndContext, { sensors: sensors, collisionDetection: closestCenter, onDragEnd: handleDragEnd },
8835
8879
  React__default.createElement(Table$1, { stickyHeader: stickyHeader, sx: tableSx },
8836
8880
  React__default.createElement(TableHead, null,
8837
8881
  React__default.createElement(TableRow, null, finalColumns.map(function (column, idx) { return (React__default.createElement(TableHeadCell, { key: idx, column: column, defaultAlign: defaultAlign })); }))),
8838
- React__default.createElement(TableBody, { style: { paddingBottom: footerHeight || 65 } }, 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 })); }))) : (React__default.createElement(StyledBodyRow$1, null,
8882
+ 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 })); }))) : (React__default.createElement(StyledBodyRow$1, null,
8839
8883
  React__default.createElement(TableCell, { colSpan: finalColumns.length }, noData ? (noData) : (React__default.createElement(StyledNoDataDiv, null,
8840
8884
  React__default.createElement("div", null,
8841
8885
  React__default.createElement(Icon, null, "error")),
8842
8886
  React__default.createElement("div", null, "\uAC80\uC0C9\uB41C \uC815\uBCF4\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4."))))))) : undefined),
8843
- paging && (React__default.createElement(TableFooter, { ref: footerHeightResizeDetector, sx: {
8844
- left: 0,
8845
- bottom: 0,
8846
- zIndex: 2,
8847
- position: 'sticky',
8848
- backgroundColor: '#fff',
8849
- } },
8850
- React__default.createElement(TableRow, null,
8851
- React__default.createElement(TableCell, { colSpan: finalColumns.length, style: { borderBottom: 0, borderTop: '1px solid rgba(224, 224, 224, 1)' } },
8852
- React__default.createElement(Stack, { alignItems: pagingAlign },
8853
- React__default.createElement(TablePagination, { className: pagination === null || pagination === void 0 ? void 0 : pagination.className, style: pagination === null || pagination === void 0 ? void 0 : pagination.style, sx: pagination === null || pagination === void 0 ? void 0 : pagination.sx, paging: paging, align: pagingAlign, onChange: onPageChange })))))),
8854
8887
  footer && (React__default.createElement(TableFooter, null,
8855
- React__default.createElement(TableRow, null, finalColumns.map(function (column, idx) { return (React__default.createElement(TableFooterCell, { key: idx, column: column, defaultAlign: defaultAlign })); }))))))))) : null;
8888
+ React__default.createElement(TableRow, null, finalColumns.map(function (column, idx) { return (React__default.createElement(TableFooterCell, { key: idx, column: column, defaultAlign: defaultAlign })); }))))))),
8889
+ paging && (React__default.createElement(Stack, { ref: fullHeight ? pagingHeightResizeDetector : undefined, alignItems: pagingAlign, style: pagingStyle },
8890
+ React__default.createElement(TablePagination, { className: pagination === null || pagination === void 0 ? void 0 : pagination.className, style: pagination === null || pagination === void 0 ? void 0 : pagination.style, sx: pagination === null || pagination === void 0 ? void 0 : pagination.sx, paging: paging, align: pagingAlign, onChange: onPageChange }))))) : null;
8856
8891
  });
8857
8892
  Table.displayName = 'Table';
8858
8893
  Table.defaultProps = TableDefaultProps;var SearchTableDefaultProps = {};var SearchTable = React__default.forwardRef(function (_a, ref) {