blixify-ui-web 1.3.2 → 1.3.3

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/data/dataTemplate/index.tsx"],"names":[],"mappings":"AAqCA,OAAO,KASN,MAAM,OAAO,CAAC;AAmHf,OAAO,EACL,iBAAiB,EAIlB,MAAM,kBAAkB,CAAC;AAuI1B,eAAO,MAAM,qBAAqB,OAAO,CAAC;AA6C1C,eAAO,MAAM,yBAAyB,UAAW,GAAG,YAYnD,CAAC;AAEF,eAAO,MAAM,YAAY,mFA05gBvB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/data/dataTemplate/index.tsx"],"names":[],"mappings":"AAqCA,OAAO,KASN,MAAM,OAAO,CAAC;AAmHf,OAAO,EACL,iBAAiB,EAIlB,MAAM,kBAAkB,CAAC;AAwI1B,eAAO,MAAM,qBAAqB,OAAO,CAAC;AA6C1C,eAAO,MAAM,yBAAyB,UAAW,GAAG,YAYnD,CAAC;AAEF,eAAO,MAAM,YAAY,mFAmghBvB,CAAC"}
@@ -726,9 +726,31 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (rawProps, ref) {
726
726
  var scrollCaptureRef = (0, react_1.useRef)({
727
727
  scrollAnchorId: persistedState === null || persistedState === void 0 ? void 0 : persistedState.scrollAnchorId,
728
728
  scrollOffset: persistedState === null || persistedState === void 0 ? void 0 : persistedState.scrollOffset,
729
+ scrollPageIndex: persistedState === null || persistedState === void 0 ? void 0 : persistedState.scrollPageIndex,
729
730
  });
730
731
  // INFO: one restore per mount — polling and SSE refetches must not scroll the user back
731
732
  var scrollRestoredRef = (0, react_1.useRef)(false);
733
+ // INFO: a scroll list reloads from page 1, so a row opened from a later page is not
734
+ // there to restore to. On a return to the list the record was opened from, the first
735
+ // read asks for every page up to the saved one in one request (see
736
+ // handleApplyScrollCatchUp); null once that read is done with or dropped. Set before
737
+ // the first render, since the list's first request goes out as it mounts.
738
+ // INFO: a lazy initialiser, so handleIsLastDrill reads storage once and not on
739
+ // every render
740
+ var initialScrollCatchUp = (0, react_1.useState)(function () {
741
+ var _a, _b;
742
+ return isPersistEnabled &&
743
+ ((_a = persistedState === null || persistedState === void 0 ? void 0 : persistedState.scrollPageIndex) !== null && _a !== void 0 ? _a : 0) > 0 &&
744
+ !!(persistedState === null || persistedState === void 0 ? void 0 : persistedState.scrollAnchorId) &&
745
+ (0, viewStatePersistence_1.handleIsLastDrill)(props.collectionId, (_b = props.organise) === null || _b === void 0 ? void 0 : _b.persistKey)
746
+ ? {
747
+ scrollPageIndex: persistedState.scrollPageIndex,
748
+ loaded: false,
749
+ isOwnPageChange: false,
750
+ }
751
+ : null;
752
+ })[0];
753
+ var scrollCatchUpRef = (0, react_1.useRef)(initialScrollCatchUp);
732
754
  // INFO: tells a mount apart from a tab switch on a mounted instance
733
755
  var scrollIdentityRef = (0, react_1.useRef)(null);
734
756
  var scrollScopeStartRef = (0, react_1.useRef)(null);
@@ -2202,24 +2224,47 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (rawProps, ref) {
2202
2224
  setActiveSavedViewId(null);
2203
2225
  setDeletingSavedViewId(null);
2204
2226
  };
2227
+ // INFO: the scroll page holding the opened row, not the last page loaded — after a
2228
+ // catch-up the list sits one page past the row, and a user may scroll down and come
2229
+ // back up, so saving pageIndex would read more pages on every return. File-view
2230
+ // rows carry `${id}#n` as id and the record id in recordId. A row not in tableData
2231
+ // (a Group_Paging band) falls back to the last page loaded.
2232
+ var handleResolveScrollPageIndex = function (recordId) {
2233
+ var rowIndex = recordId
2234
+ ? tableData.findIndex(function (row) { return (row === null || row === void 0 ? void 0 : row.id) === recordId || (row === null || row === void 0 ? void 0 : row.recordId) === recordId; })
2235
+ : -1;
2236
+ return rowIndex >= 0 && limit > 0 ? Math.floor(rowIndex / limit) : pageIndex;
2237
+ };
2205
2238
  // INFO: called in the row click, while the list is still mounted and scrolled
2206
2239
  var handleCaptureListScroll = function (recordId) {
2207
2240
  var _a, _b;
2208
2241
  if (!isPersistEnabled)
2209
2242
  return;
2210
- scrollCaptureRef.current = (0, viewStatePersistence_1.handleCaptureScrollPosition)(recordId, handleResolveScrollAxis(), handleResolveScrollScope());
2243
+ scrollCaptureRef.current = __assign(__assign({}, (0, viewStatePersistence_1.handleCaptureScrollPosition)(recordId, handleResolveScrollAxis(), handleResolveScrollScope())), {
2244
+ // INFO: page mode saves pageIndex itself
2245
+ scrollPageIndex: renderCheckScrollMode()
2246
+ ? handleResolveScrollPageIndex(recordId)
2247
+ : undefined });
2211
2248
  handleSaveView(handleBuildViewSnapshot());
2212
2249
  (0, viewStatePersistence_1.handleMarkLastDrill)((_a = props.organise) === null || _a === void 0 ? void 0 : _a.persistViewState, props.collectionId, (_b = props.organise) === null || _b === void 0 ? void 0 : _b.persistKey);
2213
2250
  };
2214
2251
  // INFO: a filter, sort or page change shows different rows, so the old position is dropped
2215
2252
  var scrollCaptureResetInitialised = (0, react_1.useRef)(false);
2216
2253
  (0, react_1.useEffect)(function () {
2254
+ var _a;
2217
2255
  if (!isPersistEnabled)
2218
2256
  return;
2219
2257
  if (!scrollCaptureResetInitialised.current) {
2220
2258
  scrollCaptureResetInitialised.current = true;
2221
2259
  return;
2222
2260
  }
2261
+ // INFO: the catch-up read moving pageIndex to its last page is not a user page
2262
+ // change — the position it saved is the one being restored
2263
+ if ((_a = scrollCatchUpRef.current) === null || _a === void 0 ? void 0 : _a.isOwnPageChange) {
2264
+ scrollCatchUpRef.current.isOwnPageChange = false;
2265
+ return;
2266
+ }
2267
+ scrollCatchUpRef.current = null;
2223
2268
  scrollCaptureRef.current = {};
2224
2269
  /* eslint-disable */
2225
2270
  }, [
@@ -2337,9 +2382,13 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (rawProps, ref) {
2337
2382
  scrollCaptureRef.current = {
2338
2383
  scrollAnchorId: persistedState === null || persistedState === void 0 ? void 0 : persistedState.scrollAnchorId,
2339
2384
  scrollOffset: persistedState === null || persistedState === void 0 ? void 0 : persistedState.scrollOffset,
2385
+ scrollPageIndex: persistedState === null || persistedState === void 0 ? void 0 : persistedState.scrollPageIndex,
2340
2386
  };
2341
2387
  var isOtherListReturn = !(0, viewStatePersistence_1.handleIsLastDrill)(props.collectionId, (_c = props.organise) === null || _c === void 0 ? void 0 : _c.persistKey);
2342
2388
  scrollRestoredRef.current = isSwitch || isOtherListReturn;
2389
+ // INFO: a list that will not restore has no rows to catch up to
2390
+ if (scrollRestoredRef.current)
2391
+ scrollCatchUpRef.current = null;
2343
2392
  /* eslint-disable */
2344
2393
  }, [props.collectionId, (_95 = props.organise) === null || _95 === void 0 ? void 0 : _95.persistKey]);
2345
2394
  /* eslint-enable */
@@ -3574,8 +3623,42 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (rawProps, ref) {
3574
3623
  if (!cond.sort)
3575
3624
  cond.sort = { sortId: serverId, type: "asc" };
3576
3625
  }
3626
+ handleApplyScrollCatchUp(cond);
3577
3627
  return cond;
3578
3628
  };
3629
+ // INFO: the catch-up read is the first page with a limit covering every page up to
3630
+ // the saved one. Once it lands pageIndex moves to the last page it covers and the
3631
+ // cond stays the same, so ReadQueryHoc (which refetches on a changed cond) does not
3632
+ // read that page again; the next scroll page then asks for the rows after it.
3633
+ // Only the plain scroll pager takes it: Firebase pages by cursor, a union by skip,
3634
+ // a formula view and a full-set view read their own way, and Group_Paging bands
3635
+ // page themselves.
3636
+ var handleGetScrollCatchUpPages = function () {
3637
+ var _a, _b;
3638
+ var catchUp = scrollCatchUpRef.current;
3639
+ if (!catchUp)
3640
+ return 0;
3641
+ if (!renderCheckScrollMode() ||
3642
+ isFirebase ||
3643
+ isFormulaView ||
3644
+ handleCheckFullSetView() ||
3645
+ renderCheckGroupPaging() ||
3646
+ !!((_b = (_a = props.organise) === null || _a === void 0 ? void 0 : _a.unionCollections) === null || _b === void 0 ? void 0 : _b.length))
3647
+ return 0;
3648
+ return (0, viewStatePersistence_1.handleGetScrollRestorePages)(catchUp.scrollPageIndex, limit);
3649
+ };
3650
+ var handleApplyScrollCatchUp = function (cond) {
3651
+ var _a;
3652
+ var pages = handleGetScrollCatchUpPages();
3653
+ if (!pages)
3654
+ return;
3655
+ var catchUpPageIndex = ((_a = scrollCatchUpRef.current) === null || _a === void 0 ? void 0 : _a.loaded) ? pages - 1 : 0;
3656
+ if (pageIndex !== catchUpPageIndex)
3657
+ return;
3658
+ cond.cursor = undefined;
3659
+ cond.skip = 0;
3660
+ cond.limit = pages * limit;
3661
+ };
3579
3662
  // INFO: views that draw every row at once rather than a page of them — the
3580
3663
  // same views handleReadQueryHocCond reads in full
3581
3664
  var handleCheckFullSetView = function () {
@@ -3925,7 +4008,7 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (rawProps, ref) {
3925
4008
  }
3926
4009
  };
3927
4010
  var handleGetListData = function (responseData, type, rowId, requestCond) { return __awaiter(void 0, void 0, void 0, function () {
3928
- var dataList, prettierDataList, clonedTableData, clonedSpaceTableData, dummyPrettierDataList_1, resolvedData, selectedIndex_1, cachedFormulaRows, cachedIndex, capKey, isScrollMode, newTableData, newPrettierTableData, isFirstPage, listedIds_1, newIndexes, isExists, cursorResp, lastDataId, err_1;
4011
+ var dataList, prettierDataList, clonedTableData, clonedSpaceTableData, dummyPrettierDataList_1, resolvedData, selectedIndex_1, cachedFormulaRows, cachedIndex, capKey, isScrollMode, newTableData, newPrettierTableData, isFirstPage, catchUpPages, listedIds_1, newIndexes, isExists, cursorResp, lastDataId, err_1;
3929
4012
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
3930
4013
  return __generator(this, function (_p) {
3931
4014
  switch (_p.label) {
@@ -4065,6 +4148,17 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (rawProps, ref) {
4065
4148
  newPrettierTableData = [];
4066
4149
  if (!isFirebase && requestCond) {
4067
4150
  isFirstPage = !requestCond.cursor && !requestCond.skip;
4151
+ catchUpPages = handleGetScrollCatchUpPages();
4152
+ if (isFirstPage &&
4153
+ catchUpPages &&
4154
+ scrollCatchUpRef.current &&
4155
+ !scrollCatchUpRef.current.loaded &&
4156
+ requestCond.limit === catchUpPages * limit) {
4157
+ // INFO: the catch-up rows are in; the next scroll page follows them
4158
+ scrollCatchUpRef.current.loaded = true;
4159
+ scrollCatchUpRef.current.isOwnPageChange = true;
4160
+ setPageIndex(catchUpPages - 1);
4161
+ }
4068
4162
  if (isFirstPage) {
4069
4163
  // INFO: per-group cursors and "exhausted" flags describe the old
4070
4164
  // list; keeping them would skip rows or stop a group early