@economic/taco 2.64.1-dataloader2-infinite-loop.0 → 2.64.1-stale-validator.0

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/taco.cjs CHANGED
@@ -38446,6 +38446,21 @@ function Cell$2(props) {
38446
38446
  }
38447
38447
  return /* @__PURE__ */ React.createElement(CellRenderer, { ...cellProps });
38448
38448
  }
38449
+ const useResizeObserver$1 = (ref, enabled = true) => {
38450
+ const [size2, setSize] = React.useState();
38451
+ React.useEffect(() => {
38452
+ if (!ref.current || !enabled) {
38453
+ return () => void 0;
38454
+ }
38455
+ const observer = new ResizeObserver((entries) => {
38456
+ const entry = entries[0];
38457
+ setSize({ height: entry.contentRect.height, width: entry.contentRect.width });
38458
+ });
38459
+ observer.observe(ref.current);
38460
+ return () => observer.disconnect();
38461
+ }, [enabled]);
38462
+ return size2;
38463
+ };
38449
38464
  const DisplayRow = React.memo(function DisplayRow2(props) {
38450
38465
  var _a, _b, _c;
38451
38466
  const { children, cellRenderer: CellRenderer, index: index2, measureRow, row, table, ...otherAttributes } = props;
@@ -38540,12 +38555,13 @@ const DisplayRow = React.memo(function DisplayRow2(props) {
38540
38555
  }
38541
38556
  const ref = React.useRef(null);
38542
38557
  const expansionRef = React.useRef(null);
38558
+ const expandedRowSize = useResizeObserver$1(expansionRef, !!expandedRow);
38543
38559
  React.useEffect(() => {
38544
38560
  var _a2, _b2;
38545
38561
  const rowHeight = ((_a2 = ref.current) == null ? void 0 : _a2.getBoundingClientRect().height) ?? 0;
38546
38562
  const expansionHeight = ((_b2 = expansionRef.current) == null ? void 0 : _b2.getBoundingClientRect().height) ?? 0;
38547
38563
  measureRow(rowHeight + expansionHeight);
38548
- }, [expansionRef.current]);
38564
+ }, [expansionRef.current, expandedRowSize == null ? void 0 : expandedRowSize.height]);
38549
38565
  const className = clsx("group/row", otherAttributes.className, {
38550
38566
  "hover:cursor-grab": tableMeta.rowDrag.isEnabled && typeof attributes.onClick !== "function",
38551
38567
  "hover:cursor-pointer": typeof attributes.onClick === "function"
@@ -53922,14 +53938,6 @@ function isTableScrolled(ref) {
53922
53938
  function useTableEditingListener(table, tableRef, scrollToIndex) {
53923
53939
  const tableMeta = table.options.meta;
53924
53940
  const localization = useLocalization();
53925
- useLazyEffect(() => {
53926
- return () => {
53927
- var _a;
53928
- if (tableMeta.editing.isEditing && tableMeta.rowActive.rowActiveIndex !== void 0) {
53929
- tableMeta.editing.saveChanges(table, (_a = table.getRowModel().rows[tableMeta.rowActive.rowActiveIndex]) == null ? void 0 : _a.id);
53930
- }
53931
- };
53932
- }, [tableMeta.rowActive.rowActiveIndex, tableMeta.editing.isEditing]);
53933
53941
  const hasChanges = tableMeta.editing.hasChanges();
53934
53942
  React.useEffect(() => {
53935
53943
  function showUnsavedChangesWarning(event) {
@@ -55274,7 +55282,7 @@ function usePendingChangesState(handleSave, handleChange, handleDiscard, rowIden
55274
55282
  var _a, _b, _c;
55275
55283
  return (_c = (_b = (_a = state.changes.errors) == null ? void 0 : _a[cell.row.id]) == null ? void 0 : _b.cells) == null ? void 0 : _c[cell.column.id];
55276
55284
  }
55277
- async function onCellChanged(cell, rowIndex, nextValue, shouldRunUpdaters = true) {
55285
+ async function onCellChanged(cell, rowIndex, nextValue, shouldRunUpdaters = true, shouldRunValidation = true) {
55278
55286
  var _a;
55279
55287
  const tableMeta = cell.getContext().table.options.meta;
55280
55288
  const state2 = tableMeta.editing.getState();
@@ -55304,7 +55312,7 @@ function usePendingChangesState(handleSave, handleChange, handleDiscard, rowIden
55304
55312
  const nextMoveReasons = { ...state2.changes.moveReasons[cell.row.id] };
55305
55313
  const nextCellErrors = { ...(_a = state2.changes.errors[cell.row.id]) == null ? void 0 : _a.cells };
55306
55314
  let validationErrors = {};
55307
- if (validator && Object.keys(nextChanges).length && original) {
55315
+ if (validator && Object.keys(nextChanges).length && original && shouldRunValidation) {
55308
55316
  const nextRowValue = { ...original, ...changes, ...updatesForOtherCells };
55309
55317
  validationErrors = await validator(nextRowValue) ?? {};
55310
55318
  }
@@ -55786,7 +55794,7 @@ function EditingControlCell(props) {
55786
55794
  if (hasChanged) {
55787
55795
  tableMeta.editing.setCellValue(cell, rowIndex, nextValue);
55788
55796
  if (hasNonTextControl) {
55789
- requestAnimationFrame(() => tableMeta.editing.onCellChanged(cell, rowIndex, nextValue));
55797
+ requestAnimationFrame(() => tableMeta.editing.onCellChanged(cell, rowIndex, nextValue, true, false));
55790
55798
  }
55791
55799
  }
55792
55800
  },
@@ -55799,7 +55807,7 @@ function EditingControlCell(props) {
55799
55807
  }
55800
55808
  requestAnimationFrame(() => {
55801
55809
  tableMeta.editing.toggleDetailedMode(false);
55802
- tableMeta.editing.onCellChanged(cell, rowIndex, void 0, !hasNonTextControl);
55810
+ tableMeta.editing.onCellChanged(cell, rowIndex, void 0, !hasNonTextControl, true);
55803
55811
  });
55804
55812
  },
55805
55813
  [hasNonTextControl, cell.row.id, JSON.stringify(rowChanges), rowIndex, cell.column.id, cell.row.original]
@@ -56095,6 +56103,11 @@ function Row(props) {
56095
56103
  }
56096
56104
  }
56097
56105
  }, [tableMeta.editing.isEditing, tableMeta.rowActive.rowActiveIndex, tableMeta.editing.lastFocusedCellIndex]);
56106
+ useLazyEffect(() => {
56107
+ if (tableMeta.editing.isEditing && !isActiveRow) {
56108
+ tableMeta.editing.saveChanges(table, row.id);
56109
+ }
56110
+ }, [isActiveRow]);
56098
56111
  const handleFocus = React.useCallback(
56099
56112
  (event) => {
56100
56113
  var _a;
@@ -88590,7 +88603,7 @@ function getDirection(pageIndex, currentPages) {
88590
88603
  return void 0;
88591
88604
  }
88592
88605
  function getPages(pageIndex, lastUsedPageIndex, currentPages, direction) {
88593
- if (currentPages.length && (pageIndex === lastUsedPageIndex || currentPages.includes(pageIndex) && !!direction)) {
88606
+ if (currentPages.length && (pageIndex === lastUsedPageIndex || currentPages.includes(pageIndex))) {
88594
88607
  return currentPages;
88595
88608
  }
88596
88609
  if (direction === "forward") {