pixelize-design-library 2.3.1-beta.8 → 2.3.1-beta.9

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.
@@ -145,12 +145,27 @@ function Table(_a) {
145
145
  // (search / filter / sort / page-size). Only used in grouped + groupLoadMore mode.
146
146
  var _36 = (0, react_1.useState)([]), accumulatedRows = _36[0], setAccumulatedRows = _36[1];
147
147
  var pendingLoadMoreRef = (0, react_1.useRef)(false);
148
+ // Pages loaded so far (1 = the initial page). The next page is derived from this
149
+ // counter — NOT from the deduped row count — so overlapping rows across pages
150
+ // (e.g. pinned rows that repeat on every page) don't stall the page index.
151
+ var loadedPagesRef = (0, react_1.useRef)(1);
148
152
  (0, react_1.useEffect)(function () {
149
153
  if (!groupLoadMore)
150
154
  return;
155
+ // eslint-disable-next-line no-console
156
+ console.log("[Table][loadMore] data change", {
157
+ incoming: tableData.length,
158
+ incomingIds: tableData.slice(0, 50).map(function (r) { return r.id; }),
159
+ accumulated: accumulatedRows.length,
160
+ newRows: tableData.filter(function (r) { return !new Set(accumulatedRows.map(function (a) { return a.id; })).has(r.id); }).length,
161
+ pending: pendingLoadMoreRef.current,
162
+ loadedPages: loadedPagesRef.current,
163
+ });
151
164
  setAccumulatedRows(function (prev) {
152
- if (prev.length === 0)
165
+ if (prev.length === 0) {
166
+ loadedPagesRef.current = 1;
153
167
  return tableData.slice();
168
+ }
154
169
  var accIds = new Set(prev.map(function (r) { return r.id; }));
155
170
  if (pendingLoadMoreRef.current) {
156
171
  // A "Load more" is in flight. The parent may re-emit the SAME page (new
@@ -166,7 +181,10 @@ function Table(_a) {
166
181
  // (the parent re-renders the current page often). Genuinely new rows
167
182
  // (search / filter / sort / page-size / reload) reset it.
168
183
  var allKnown = tableData.length > 0 && tableData.every(function (r) { return accIds.has(r.id); });
169
- return allKnown ? prev : tableData.slice();
184
+ if (allKnown)
185
+ return prev;
186
+ loadedPagesRef.current = 1; // fresh data set
187
+ return tableData.slice();
170
188
  });
171
189
  // eslint-disable-next-line react-hooks/exhaustive-deps
172
190
  }, [tableData, groupLoadMore]);
@@ -254,11 +272,19 @@ function Table(_a) {
254
272
  if (isLoadingMore || isTableLoading || !hasMoreEffective)
255
273
  return;
256
274
  var chunk = loadMoreChunkSize !== null && loadMoreChunkSize !== void 0 ? loadMoreChunkSize : rowsPerPage;
257
- // Next page is derived from how many rows we've already accumulated, so each
258
- // click advances (fixes "always fromIndex 2") and the parent can replace `data`.
259
- var nextPage = Math.floor(loadMoreBase.length / (chunk || 1)) + 1;
275
+ // Advance by page COUNT (not by deduped row count) so overlapping/pinned rows
276
+ // across pages don't keep us stuck on the same page.
277
+ var nextPage = loadedPagesRef.current + 1;
278
+ loadedPagesRef.current = nextPage;
260
279
  var lastRecord = loadMoreBase.length > 0 ? loadMoreBase[loadMoreBase.length - 1] : undefined;
261
280
  pendingLoadMoreRef.current = true;
281
+ // eslint-disable-next-line no-console
282
+ console.log("[Table][loadMore] click → request page", nextPage, {
283
+ chunk: chunk,
284
+ accumulated: loadMoreBase.length,
285
+ totalRecords: totalRecords,
286
+ hasMore: hasMoreEffective,
287
+ });
262
288
  (_a = onPaginationRef.current) === null || _a === void 0 ? void 0 : _a.call(onPaginationRef, nextPage, chunk, lastRecord, "next");
263
289
  };
264
290
  var groupLoadMoreCaption = totalRecords > 0 ? "Showing ".concat(loadMoreBase.length, " of ").concat(totalRecords) : undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pixelize-design-library",
3
- "version": "2.3.1-beta.8",
3
+ "version": "2.3.1-beta.9",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",