@bluemarble/bm-components 0.0.35 → 0.0.37

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
@@ -15146,12 +15146,11 @@ function createFilter(filters) {
15146
15146
  }
15147
15147
 
15148
15148
  function useGrid({ columns, filters = [], rowsPerPageOptions = [30, 60, 100], }) {
15149
- const [data, setData] = useState([]);
15149
+ const [defaultData, setDefaultData] = useState([]);
15150
15150
  const [sortedBy, setSortedBy] = useState("");
15151
15151
  const [sortedDirection, setSortedDirection] = useState("desc");
15152
15152
  const [currentPage, setCurrentPage] = useState(0);
15153
15153
  const [rowsPerPage, setRowsPerPage] = useState(rowsPerPageOptions[0]);
15154
- const defaultData = useRef([]);
15155
15154
  const toggleSortedDirection = () => {
15156
15155
  if (sortedDirection === "desc")
15157
15156
  setSortedDirection("asc");
@@ -15175,8 +15174,7 @@ function useGrid({ columns, filters = [], rowsPerPageOptions = [30, 60, 100], })
15175
15174
  }
15176
15175
  };
15177
15176
  const set = (data) => {
15178
- setData(data);
15179
- defaultData.current = data;
15177
+ setDefaultData(data);
15180
15178
  };
15181
15179
  const sortData = (data) => {
15182
15180
  if (sortedBy) {
@@ -15204,10 +15202,10 @@ function useGrid({ columns, filters = [], rowsPerPageOptions = [30, 60, 100], })
15204
15202
  setRowsPerPage(rows);
15205
15203
  };
15206
15204
  const filteredData = useMemo(() => {
15207
- const newData = defaultData.current.slice(0);
15205
+ const newData = defaultData.slice(0);
15208
15206
  const newFilter = createFilter(filters);
15209
15207
  return newData.filter(newFilter.apply);
15210
- }, [data, filters]);
15208
+ }, [defaultData, filters]);
15211
15209
  const displayData = useMemo(() => {
15212
15210
  const sortedData = sortData(filteredData);
15213
15211
  const startPage = currentPage * rowsPerPage;
@@ -15217,10 +15215,10 @@ function useGrid({ columns, filters = [], rowsPerPageOptions = [30, 60, 100], })
15217
15215
  const totalNumberOfPages = Math.round(filteredData.length / rowsPerPage) - 1;
15218
15216
  return {
15219
15217
  data: displayData,
15220
- defaultData: defaultData.current,
15221
15218
  set,
15222
15219
  onSortBy,
15223
15220
  sortedBy,
15221
+ defaultData,
15224
15222
  sortedDirection,
15225
15223
  columns,
15226
15224
  currentPage,