@economic/taco 2.69.2-search-racecondition-v2.0 → 2.70.1

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
@@ -16980,7 +16980,8 @@ const Navbar = React__namespace.memo(({ onMonthChange, value = /* @__PURE__ */ n
16980
16980
  icon: "chevron-left",
16981
16981
  "aria-label": actions.previousMonth,
16982
16982
  onClick: onPreviousClick,
16983
- rounded: true
16983
+ rounded: true,
16984
+ "data-action": "prev-month"
16984
16985
  }
16985
16986
  )), /* @__PURE__ */ React__namespace.createElement(Tooltip$3, { title: actions.nextMonth }, /* @__PURE__ */ React__namespace.createElement(
16986
16987
  IconButton,
@@ -16989,7 +16990,8 @@ const Navbar = React__namespace.memo(({ onMonthChange, value = /* @__PURE__ */ n
16989
16990
  icon: "chevron-right",
16990
16991
  "aria-label": actions.nextMonth,
16991
16992
  onClick: onNextClick,
16992
- rounded: true
16993
+ rounded: true,
16994
+ "data-action": "next-month"
16993
16995
  }
16994
16996
  ))));
16995
16997
  });
@@ -17006,7 +17008,8 @@ const TodayButton = ({ handleChange }) => {
17006
17008
  Button$3,
17007
17009
  {
17008
17010
  className: "cursor-pointer border-none bg-transparent text-xs text-blue-500 hover:text-blue-300",
17009
- onClick: handleCalendarClickToday
17011
+ onClick: handleCalendarClickToday,
17012
+ "data-action": "today"
17010
17013
  },
17011
17014
  texts.calendar.actions.today
17012
17015
  );
@@ -35695,7 +35698,8 @@ const DEFAULT_PRESET = {
35695
35698
  enableRowDrop: false,
35696
35699
  enableRowGoto: false,
35697
35700
  enableRowHeight: false,
35698
- enableSaveSettings: false
35701
+ enableSaveSettings: false,
35702
+ enableSaveSettingsLocally: true
35699
35703
  };
35700
35704
  const presets = {
35701
35705
  // View/edit/create on page
@@ -35722,7 +35726,8 @@ const presets = {
35722
35726
  enableRowDrop: true,
35723
35727
  enableRowGoto: true,
35724
35728
  enableRowHeight: true,
35725
- enableSaveSettings: true
35729
+ enableSaveSettings: true,
35730
+ enableSaveSettingsLocally: true
35726
35731
  },
35727
35732
  // View/create in dialog
35728
35733
  list: {
@@ -35748,7 +35753,8 @@ const presets = {
35748
35753
  enableRowDrop: false,
35749
35754
  enableRowGoto: false,
35750
35755
  enableRowHeight: false,
35751
- enableSaveSettings: true
35756
+ enableSaveSettings: true,
35757
+ enableSaveSettingsLocally: true
35752
35758
  },
35753
35759
  // View in card or dialog
35754
35760
  simple: {
@@ -35774,7 +35780,8 @@ const presets = {
35774
35780
  enableRowDrop: false,
35775
35781
  enableRowGoto: false,
35776
35782
  enableRowHeight: false,
35777
- enableSaveSettings: true
35783
+ enableSaveSettings: true,
35784
+ enableSaveSettingsLocally: true
35778
35785
  }
35779
35786
  };
35780
35787
  function getTableFeaturePreset(props) {
@@ -35813,7 +35820,8 @@ function getTableFeaturePreset(props) {
35813
35820
  enableRowGoto: enableRowGoto && !!props.onRowGoto,
35814
35821
  enableRowExpansionAll: enableRowExpansion && enableRowExpansionAll && !!props.rowExpansionRenderer,
35815
35822
  enableRowHeight: props.enableRowHeight ?? presetOptions.enableRowHeight,
35816
- enableSaveSettings: props.enableSaveSettings ?? presetOptions.enableSaveSettings
35823
+ enableSaveSettings: props.enableSaveSettings ?? presetOptions.enableSaveSettings,
35824
+ enableSaveSettingsLocally: props.enableSaveSettingsLocally ?? presetOptions.enableSaveSettingsLocally
35817
35825
  };
35818
35826
  }
35819
35827
  function useTableColumnFreezing(isEnabled = false) {
@@ -36363,11 +36371,11 @@ function useEnabledSettings(isEnabled) {
36363
36371
  return [options, Object.values(options).some((o2) => o2 === true)];
36364
36372
  }, [isEnabled]);
36365
36373
  }
36366
- function useTableSettings(isEnabled = false, id2, defaultSettings = {}, onChangeSettings) {
36374
+ function useTableSettings(isEnabled = false, id2, defaultSettings = {}, onChangeSettings, enableSaveSettingsLocally = true) {
36367
36375
  const uniqueId3 = useUniqueTableId(id2);
36368
36376
  const [enabledSettings, hasSomeEnabledSettings] = useEnabledSettings(isEnabled);
36369
36377
  const [persistedSettings, _setPersistedSettings] = useLocalStorage(
36370
- hasSomeEnabledSettings ? uniqueId3 : void 0,
36378
+ hasSomeEnabledSettings && enableSaveSettingsLocally ? uniqueId3 : void 0,
36371
36379
  removeDisabledSettings(defaultSettings, enabledSettings)
36372
36380
  );
36373
36381
  const setPersistedSettings = React.useCallback(
@@ -36376,17 +36384,20 @@ function useTableSettings(isEnabled = false, id2, defaultSettings = {}, onChange
36376
36384
  return;
36377
36385
  }
36378
36386
  const sanitizedSettings = removeDisabledSettings(value, enabledSettings);
36379
- _setPersistedSettings(sanitizedSettings);
36387
+ if (enableSaveSettingsLocally) {
36388
+ _setPersistedSettings(sanitizedSettings);
36389
+ }
36380
36390
  if (typeof onChangeSettings === "function") {
36381
36391
  onChangeSettings(sanitizedSettings);
36382
36392
  }
36383
36393
  },
36384
- [hasSomeEnabledSettings, onChangeSettings, JSON.stringify(enabledSettings)]
36394
+ [hasSomeEnabledSettings, enableSaveSettingsLocally, onChangeSettings, JSON.stringify(enabledSettings)]
36385
36395
  );
36386
36396
  if (!hasSomeEnabledSettings) {
36387
36397
  return [defaultSettings, () => void 0];
36388
36398
  }
36389
- return [persistedSettings, setPersistedSettings];
36399
+ const currentSettings = enableSaveSettingsLocally ? persistedSettings : removeDisabledSettings(defaultSettings, enabledSettings);
36400
+ return [currentSettings, setPersistedSettings];
36390
36401
  }
36391
36402
  function removeDisabledSettings(settings, enabledSettings) {
36392
36403
  const sanitizedSettings = { ...settings };
@@ -36495,7 +36506,7 @@ function useTableSearchListener(table) {
36495
36506
  const meta = table.options.meta;
36496
36507
  const localization = useLocalization();
36497
36508
  const hiddenColumns = getHiddenColumns(table.getState().columnVisibility);
36498
- const query = React.useDeferredValue(table.getState().globalFilter);
36509
+ const query = table.getState().globalFilter;
36499
36510
  useLazyEffect(() => {
36500
36511
  if (meta.search.isEnabled) {
36501
36512
  const currentFilter = query;
@@ -36673,7 +36684,8 @@ function useTableManager(props, ref, meta, internalColumns) {
36673
36684
  options.enableSaveSettings,
36674
36685
  safeId,
36675
36686
  props.defaultSettings,
36676
- props.onChangeSettings
36687
+ props.onChangeSettings,
36688
+ props.enableSaveSettingsLocally
36677
36689
  );
36678
36690
  const data = props.data ?? DEFAULT_EMPTY_ARRAY;
36679
36691
  const length = props.length ?? data.length;
@@ -37724,12 +37736,15 @@ const RowContext = React.createContext({
37724
37736
  isHovered: false,
37725
37737
  rowIndex: -1
37726
37738
  });
37739
+ const DELAY_BEFORE_LOAD_MS$1 = 250;
37727
37740
  function Row$2(props) {
37728
37741
  const {
37729
37742
  renderer: RowRenderer,
37730
37743
  cellRenderer: CellRenderer,
37731
37744
  hideInternalColumns = false,
37732
37745
  hideRowActions = false,
37746
+ scrollDirection,
37747
+ skipPageLoading = false,
37733
37748
  ...displayRowProps
37734
37749
  } = props;
37735
37750
  const tableMeta = props.table.options.meta;
@@ -37738,6 +37753,44 @@ function Row$2(props) {
37738
37753
  () => ({ isHovered, rowIndex: props.index, hideInternalColumns, hideRowActions }),
37739
37754
  [isHovered, props.index, hideInternalColumns, hideRowActions]
37740
37755
  );
37756
+ React.useEffect(() => {
37757
+ let timeout;
37758
+ if (tableMeta.server.isEnabled && tableMeta.server._experimentalDataLoader2 && !skipPageLoading) {
37759
+ const pageIndex = Math.floor(props.index / tableMeta.server.pageSize) * tableMeta.server.pageSize / tableMeta.server.pageSize;
37760
+ const sorting = props.table.getState().sorting;
37761
+ const filters = props.table.getState().columnFilters;
37762
+ const search = props.table.getState().globalFilter;
37763
+ const hiddenColumns = getHiddenColumns(props.table.getState().columnVisibility);
37764
+ const pageIndexesToFetch = [];
37765
+ if (scrollDirection === "backward" || !scrollDirection) {
37766
+ const backIndex = pageIndex - 1;
37767
+ if (backIndex > -1) {
37768
+ pageIndexesToFetch.push(backIndex);
37769
+ }
37770
+ }
37771
+ if ((scrollDirection === "forward" || !scrollDirection) && pageIndex + 2 < tableMeta.server.pageCount) {
37772
+ pageIndexesToFetch.push(pageIndex + 1);
37773
+ }
37774
+ if (pageIndexesToFetch.length) {
37775
+ timeout = setTimeout(() => {
37776
+ pageIndexesToFetch.forEach((index2) => {
37777
+ var _a, _b;
37778
+ (_b = (_a = tableMeta.server).loadPage) == null ? void 0 : _b.call(
37779
+ _a,
37780
+ index2,
37781
+ sorting,
37782
+ filters,
37783
+ hiddenColumns,
37784
+ tableMeta.search.enableGlobalFilter ? search : void 0
37785
+ );
37786
+ });
37787
+ }, DELAY_BEFORE_LOAD_MS$1);
37788
+ }
37789
+ }
37790
+ return () => {
37791
+ clearTimeout(timeout);
37792
+ };
37793
+ }, [tableMeta.server.pages]);
37741
37794
  return /* @__PURE__ */ React.createElement(RowContext.Provider, { value: contextValue }, /* @__PURE__ */ React.createElement(RowRenderer, { ...displayRowProps, cellRenderer: CellRenderer }));
37742
37795
  }
37743
37796
  const DELAY_BEFORE_LOAD_MS = 150;
@@ -37889,7 +37942,15 @@ function useTableRenderer(renderers, table, tableRef, length, defaultRowActiveIn
37889
37942
  }
37890
37943
  if (!(row == null ? void 0 : row.original)) {
37891
37944
  const skeletonKey = `skeleton-${virtualRow.index}`;
37892
- return /* @__PURE__ */ React.createElement(SkeletonRow, { key: skeletonKey, index: virtualRow.index, table });
37945
+ return /* @__PURE__ */ React.createElement(
37946
+ SkeletonRow,
37947
+ {
37948
+ key: skeletonKey,
37949
+ index: virtualRow.index,
37950
+ scrollDirection: virtualiser.scrollDirection ?? void 0,
37951
+ table
37952
+ }
37953
+ );
37893
37954
  }
37894
37955
  const measureRow = (rowHeight) => {
37895
37956
  virtualiser.resizeItem(virtualRow, rowHeight);
@@ -37900,6 +37961,7 @@ function useTableRenderer(renderers, table, tableRef, length, defaultRowActiveIn
37900
37961
  key: row.id,
37901
37962
  row,
37902
37963
  index: virtualRow.index,
37964
+ scrollDirection: virtualiser.scrollDirection ?? void 0,
37903
37965
  table,
37904
37966
  measureRow,
37905
37967
  renderer: renderers.row,
@@ -39569,7 +39631,7 @@ function Search$1(props) {
39569
39631
  (_c = (_b = (_a2 = tableMeta.search).handleSearch) == null ? void 0 : _b.call(_a2, query2, hiddenColumns)) == null ? void 0 : _c.then(() => {
39570
39632
  setLoading(false);
39571
39633
  });
39572
- }, 350);
39634
+ }, 150);
39573
39635
  }
39574
39636
  };
39575
39637
  const handleToggleExcludeUnmatchedResults = async (enabled) => {
@@ -56181,7 +56243,7 @@ function SaveStatus(props) {
56181
56243
  const className = clsx(
56182
56244
  "col-span-full sticky ml-auto right-0 top-0 -mb-[100%] z-10 h-8 bg-[inherit] flex items-center px-1.5 shadow-[-6px_0px_6px_var(--table-row-actions-shadow)]",
56183
56245
  {
56184
- "mt-0.5": tableMeta.rowHeight.height === "short",
56246
+ "mt-0": tableMeta.rowHeight.height === "short",
56185
56247
  "mt-1": tableMeta.rowHeight.height === "medium",
56186
56248
  "mt-1.5": tableMeta.rowHeight.height === "tall",
56187
56249
  "mt-2": tableMeta.rowHeight.height === "extra-tall"
@@ -56599,7 +56661,8 @@ function TemporaryRow(props) {
56599
56661
  className,
56600
56662
  onKeyDown: handleKeyDown,
56601
56663
  hideInternalColumns: true,
56602
- hideRowActions: !tableMeta.editing.isEditing
56664
+ hideRowActions: !tableMeta.editing.isEditing,
56665
+ skipPageLoading: true
56603
56666
  }
56604
56667
  );
56605
56668
  }