@pdg/react-table 1.0.6 → 1.0.8

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
@@ -8745,12 +8745,16 @@ var Table = React__default["default"].forwardRef(function (_a, ref) {
8745
8745
  '> .MuiTableFooter-root > .MuiTableRow-root > .MuiTableCell-root ': sx,
8746
8746
  };
8747
8747
  }, [cellPadding]))[0];
8748
- // Effect ----------------------------------------------------------------------------------------------------------
8749
- React.useEffect(function () {
8750
- setSortableItems(items === null || items === void 0 ? void 0 : items.map(function (_a, index) {
8748
+ // Function --------------------------------------------------------------------------------------------------------
8749
+ var makeSortableItems = React.useCallback(function (items) {
8750
+ return items === null || items === void 0 ? void 0 : items.map(function (_a, index) {
8751
8751
  var id = _a.id, item = __rest$1(_a, ["id"]);
8752
8752
  return __assign$1({ id: id == null ? index : id }, item);
8753
- }));
8753
+ });
8754
+ }, []);
8755
+ // Effect ----------------------------------------------------------------------------------------------------------
8756
+ React.useEffect(function () {
8757
+ setSortableItems(makeSortableItems(items));
8754
8758
  }, [items]);
8755
8759
  React.useEffect(function () {
8756
8760
  setFinalColumns(columns === null || columns === void 0 ? void 0 : columns.filter(columnFilter));
@@ -8775,6 +8779,9 @@ var Table = React__default["default"].forwardRef(function (_a, ref) {
8775
8779
  setItems(lastItems_1);
8776
8780
  setPaging(lastPaging_1);
8777
8781
  },
8782
+ resetSort: function () {
8783
+ setSortableItems(makeSortableItems(lastItems_1));
8784
+ },
8778
8785
  };
8779
8786
  if (typeof ref === 'function') {
8780
8787
  ref(commands);
@@ -8783,7 +8790,7 @@ var Table = React__default["default"].forwardRef(function (_a, ref) {
8783
8790
  ref.current = commands;
8784
8791
  }
8785
8792
  }
8786
- }, [ref, columns, items, paging]);
8793
+ }, [ref, columns, items, paging, makeSortableItems]);
8787
8794
  // Event Handler ---------------------------------------------------------------------------------------------------
8788
8795
  var handleDragEnd = React.useCallback(function (event) {
8789
8796
  var active = event.active, over = event.over;
@@ -9021,7 +9028,7 @@ Table.defaultProps = TableDefaultProps;var SearchTableDefaultProps = {};var Sear
9021
9028
  if (data)
9022
9029
  getData(data);
9023
9030
  }
9024
- }, [hash, window.location.hash, getData]);
9031
+ }, [window.location.hash]);
9025
9032
  //--------------------------------------------------------------------------------------------------------------------
9026
9033
  var hashChange = React.useCallback(function (params) {
9027
9034
  if (onRequestHashChange) {