@bluemarble/bm-components 0.0.46 → 0.0.47

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/esm/index.js CHANGED
@@ -15094,12 +15094,11 @@ function createFilter(filters) {
15094
15094
  }
15095
15095
 
15096
15096
  function useGrid({ columns, filters = [], rowsPerPageOptions = [30, 60, 100], }) {
15097
- const [data, setData] = useState([]);
15097
+ const [defaultData, setDefaultData] = useState([]);
15098
15098
  const [sortedBy, setSortedBy] = useState("");
15099
15099
  const [sortedDirection, setSortedDirection] = useState("desc");
15100
15100
  const [currentPage, setCurrentPage] = useState(0);
15101
15101
  const [rowsPerPage, setRowsPerPage] = useState(rowsPerPageOptions[0]);
15102
- const defaultData = useRef([]);
15103
15102
  const toggleSortedDirection = () => {
15104
15103
  if (sortedDirection === "desc")
15105
15104
  setSortedDirection("asc");
@@ -15123,8 +15122,7 @@ function useGrid({ columns, filters = [], rowsPerPageOptions = [30, 60, 100], })
15123
15122
  }
15124
15123
  };
15125
15124
  const set = (data) => {
15126
- setData(data);
15127
- defaultData.current = data;
15125
+ setDefaultData(data);
15128
15126
  };
15129
15127
  const sortData = (data) => {
15130
15128
  if (sortedBy) {
@@ -15153,10 +15151,10 @@ function useGrid({ columns, filters = [], rowsPerPageOptions = [30, 60, 100], })
15153
15151
  setRowsPerPage(rows);
15154
15152
  };
15155
15153
  const filteredData = useMemo(() => {
15156
- const newData = defaultData.current.slice(0);
15154
+ const newData = defaultData.slice(0);
15157
15155
  const newFilter = createFilter(filters);
15158
15156
  return newData.filter(newFilter.apply);
15159
- }, [data, filters]);
15157
+ }, [defaultData, filters]);
15160
15158
  const displayData = useMemo(() => {
15161
15159
  const sortedData = sortData(filteredData);
15162
15160
  const startPage = currentPage * rowsPerPage;
@@ -15166,10 +15164,10 @@ function useGrid({ columns, filters = [], rowsPerPageOptions = [30, 60, 100], })
15166
15164
  const totalNumberOfPages = Math.round(filteredData.length / rowsPerPage) - 1;
15167
15165
  return {
15168
15166
  data: displayData,
15169
- defaultData: defaultData.current,
15170
15167
  set,
15171
15168
  onSortBy,
15172
15169
  sortedBy,
15170
+ defaultData,
15173
15171
  sortedDirection,
15174
15172
  columns,
15175
15173
  currentPage,