@pdg/react-table 1.0.12 → 1.0.15

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/index.js CHANGED
@@ -8343,7 +8343,7 @@ var equal = function (v1, v2) {
8343
8343
  var TableCommonCell = function (_a) {
8344
8344
  var children = _a.children, initClassName = _a.className, initStyle = _a.style, initSx = _a.sx, type = _a.type, column = _a.column, defaultAlign = _a.defaultAlign, initDefaultEllipsis = _a.defaultEllipsis, index = _a.index, item = _a.item, onClick = _a.onClick;
8345
8345
  var align = React.useMemo(function () { return getTableColumnAlign(column, defaultAlign); }, [column, defaultAlign]);
8346
- var ellipsis = React.useMemo(function () { return (column.ellipsis != null ? column.ellipsis : !!initDefaultEllipsis); }, [column, initDefaultEllipsis]);
8346
+ var ellipsis = React.useMemo(function () { return type !== 'head' && (column.ellipsis != null ? column.ellipsis : !!initDefaultEllipsis); }, [type, column, initDefaultEllipsis]);
8347
8347
  var className = React.useMemo(function () {
8348
8348
  var _a, _b, _c, _d, _e, _f;
8349
8349
  var className;
@@ -8699,7 +8699,7 @@ styleInject(css_248z);function columnFilter(v) {
8699
8699
  }
8700
8700
  var Table = React__default["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$1 = _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$1 = _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 = core.useSensors(core.useSensor(core.MouseSensor, {
@@ -8716,26 +8716,40 @@ var Table = React__default["default"].forwardRef(function (_a, ref) {
8716
8716
  }), core.useSensor(core.KeyboardSensor, {
8717
8717
  coordinateGetter: sortable.sortableKeyboardCoordinates,
8718
8718
  }));
8719
+ // State - containerHeight -------------------------------------------------------------------------------------------
8720
+ var _b = React.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 = React.useState(), footerHeight = _b[0], setFooterHeight = _b[1];
8721
- var footerHeightResizeDetector = useResizeDetector({
8734
+ var _c = React.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 = React.useState(), finalColumns = _d[0], setFinalColumns = _d[1];
8736
- var _e = useAutoUpdateLayoutState(initItems), items = _e[0], setItems = _e[1];
8737
- var _f = React.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 = React.useState(), finalColumns = _e[0], setFinalColumns = _e[1];
8750
+ var _f = useAutoUpdateLayoutState(initItems), items = _f[0], setItems = _f[1];
8751
+ var _g = React.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 = React.useMemo(function () {
8741
8755
  var sx = {
@@ -8827,38 +8841,59 @@ var Table = React__default["default"].forwardRef(function (_a, ref) {
8827
8841
  }
8828
8842
  }, [onSortChange]);
8829
8843
  // Memo --------------------------------------------------------------------------------------------------------------
8830
- var style = React.useMemo(function () { return (__assign$1({ width: '100%' }, initStyle)); }, [initStyle]);
8844
+ var style = React.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 = React.useMemo(function () {
8853
+ if (fullHeight) {
8854
+ return {
8855
+ height: (containerHeight || 0) - (pagingHeight || 0) - 2,
8856
+ flex: 1,
8857
+ position: 'absolute',
8858
+ top: 1,
8859
+ left: 0,
8860
+ right: 0,
8861
+ marginBottom: pagingHeight || 0,
8862
+ };
8863
+ }
8864
+ else {
8865
+ return { height: height, minHeight: minHeight, maxHeight: maxHeight, marginBottom: -1 };
8866
+ }
8867
+ }, [containerHeight, fullHeight, height, maxHeight, minHeight, pagingHeight]);
8868
+ var pagingStyle = React.useMemo(function () {
8869
+ var style = { padding: '13px 0', borderTop: '1px solid rgba(224, 224, 224, 1)' };
8870
+ if (fullHeight) {
8871
+ return __assign$1({ position: 'sticky' }, style);
8872
+ }
8873
+ return style;
8874
+ }, [fullHeight]);
8831
8875
  // Render ----------------------------------------------------------------------------------------------------------
8832
- return finalColumns ? (React__default["default"].createElement(material.Paper, { className: classNames('Table', className), variant: 'outlined', style: style, sx: sx },
8833
- React__default["default"].createElement(SimpleBar, { style: { height: height, minHeight: minHeight, maxHeight: maxHeight } },
8876
+ return finalColumns ? (React__default["default"].createElement(material.Paper, { ref: fullHeight ? containerHeightDetector : undefined, className: classNames('Table', className), variant: 'outlined', style: style, sx: sx },
8877
+ React__default["default"].createElement(SimpleBar, { style: simpleBarStyle },
8834
8878
  React__default["default"].createElement(core.DndContext, { sensors: sensors, collisionDetection: core.closestCenter, onDragEnd: handleDragEnd },
8835
8879
  React__default["default"].createElement(material.Table, { stickyHeader: stickyHeader, sx: tableSx },
8836
8880
  React__default["default"].createElement(material.TableHead, null,
8837
8881
  React__default["default"].createElement(material.TableRow, null, finalColumns.map(function (column, idx) { return (React__default["default"].createElement(TableHeadCell, { key: idx, column: column, defaultAlign: defaultAlign })); }))),
8838
- React__default["default"].createElement(material.TableBody, { style: { paddingBottom: footerHeight || 65 } }, sortableItems ? (sortableItems.length > 0 ? (React__default["default"].createElement(sortable.SortableContext, { items: sortableItems, strategy: sortable.verticalListSortingStrategy }, sortableItems.map(function (item, idx) { return (React__default["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$1, columns: finalColumns, item: item, onClick: onClick })); }))) : (React__default["default"].createElement(StyledBodyRow$1, null,
8882
+ React__default["default"].createElement(material.TableBody, null, sortableItems ? (sortableItems.length > 0 ? (React__default["default"].createElement(sortable.SortableContext, { items: sortableItems, strategy: sortable.verticalListSortingStrategy }, sortableItems.map(function (item, idx) { return (React__default["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$1, columns: finalColumns, item: item, onClick: onClick })); }))) : (React__default["default"].createElement(StyledBodyRow$1, null,
8839
8883
  React__default["default"].createElement(material.TableCell, { colSpan: finalColumns.length }, noData ? (noData) : (React__default["default"].createElement(StyledNoDataDiv, null,
8840
8884
  React__default["default"].createElement("div", null,
8841
8885
  React__default["default"].createElement(material.Icon, null, "error")),
8842
8886
  React__default["default"].createElement("div", null, "\uAC80\uC0C9\uB41C \uC815\uBCF4\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4."))))))) : undefined),
8843
- paging && (React__default["default"].createElement(material.TableFooter, { ref: footerHeightResizeDetector, sx: {
8844
- left: 0,
8845
- bottom: 0,
8846
- zIndex: 2,
8847
- position: 'sticky',
8848
- backgroundColor: '#fff',
8849
- } },
8850
- React__default["default"].createElement(material.TableRow, null,
8851
- React__default["default"].createElement(material.TableCell, { colSpan: finalColumns.length, style: { borderBottom: 0, borderTop: '1px solid rgba(224, 224, 224, 1)' } },
8852
- React__default["default"].createElement(material.Stack, { alignItems: pagingAlign },
8853
- React__default["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["default"].createElement(material.TableFooter, null,
8855
- React__default["default"].createElement(material.TableRow, null, finalColumns.map(function (column, idx) { return (React__default["default"].createElement(TableFooterCell, { key: idx, column: column, defaultAlign: defaultAlign })); }))))))))) : null;
8888
+ React__default["default"].createElement(material.TableRow, null, finalColumns.map(function (column, idx) { return (React__default["default"].createElement(TableFooterCell, { key: idx, column: column, defaultAlign: defaultAlign })); }))))))),
8889
+ paging && (React__default["default"].createElement(material.Stack, { ref: fullHeight ? pagingHeightResizeDetector : undefined, alignItems: pagingAlign, style: pagingStyle },
8890
+ React__default["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["default"].forwardRef(function (_a, ref) {
8859
- var color = _a.color, hash = _a.hash, search = _a.search, table = _a.table, betweenSearchTableComponent = _a.betweenSearchTableComponent, onGetData = _a.onGetData, onRequestHashChange = _a.onRequestHashChange,
8894
+ var color = _a.color, hash = _a.hash, fullHeight = _a.fullHeight, search = _a.search, table = _a.table, betweenSearchTableComponent = _a.betweenSearchTableComponent, onGetData = _a.onGetData, onRequestHashChange = _a.onRequestHashChange,
8860
8895
  // ---------------------------------------------------------------------------------------------------------------
8861
- className = _a.className, style = _a.style, sx = _a.sx;
8896
+ className = _a.className, initStyle = _a.style, sx = _a.sx;
8862
8897
  var searchRef = React.useRef();
8863
8898
  var tableRef = React.useRef();
8864
8899
  //------------------------------------------------------------------------------------------------------------------
@@ -9139,6 +9174,20 @@ Table.defaultProps = TableDefaultProps;var SearchTableDefaultProps = {};var Sear
9139
9174
  }
9140
9175
  }
9141
9176
  }, [searchRef, hash, hashChange, getData, isFirstSearchSubmit]);
9177
+ // Memo --------------------------------------------------------------------------------------------------------------
9178
+ var style = React.useMemo(function () {
9179
+ if (fullHeight) {
9180
+ return __assign$1(__assign$1({}, initStyle), { flex: 1, display: 'flex' });
9181
+ }
9182
+ else {
9183
+ return initStyle;
9184
+ }
9185
+ }, [initStyle, fullHeight]);
9186
+ var tableContainerStyle = React.useMemo(function () {
9187
+ if (fullHeight) {
9188
+ return { flex: 1, display: 'flex', flexDirection: 'column' };
9189
+ }
9190
+ }, [fullHeight]);
9142
9191
  //------------------------------------------------------------------------------------------------------------------
9143
9192
  return (React__default["default"].createElement(material.Grid, { container: true, direction: 'column', spacing: 1, className: classNames('SearchTable', className), style: style, sx: sx },
9144
9193
  React__default["default"].createElement(material.Grid, { item: true, sx: { display: searchInfo.searchGroups ? undefined : 'none' } },
@@ -9157,8 +9206,8 @@ Table.defaultProps = TableDefaultProps;var SearchTableDefaultProps = {};var Sear
9157
9206
  React__default["default"].createElement(reactForm.FormHidden, { name: 'page', value: 1 })),
9158
9207
  searchInfo.searchGroups)),
9159
9208
  betweenSearchTableComponent && React__default["default"].createElement(material.Grid, { item: true }, betweenSearchTableComponent),
9160
- React__default["default"].createElement(material.Grid, { item: true },
9161
- React__default["default"].createElement(Table, __assign$1({}, tableInfo.props, { ref: function (commands) {
9209
+ React__default["default"].createElement(material.Grid, { item: true, style: tableContainerStyle },
9210
+ React__default["default"].createElement(Table, __assign$1({}, tableInfo.props, { fullHeight: fullHeight, ref: function (commands) {
9162
9211
  if (tableInfo.ref) {
9163
9212
  if (typeof tableInfo.ref === 'function') {
9164
9213
  tableInfo.ref(commands);