@economic/taco 2.69.2-search-racecondition-v2.0 → 2.70.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 +75 -15
- package/dist/taco.cjs.map +1 -1
- package/dist/taco.d.ts +1 -0
- package/dist/taco.js +75 -15
- package/dist/taco.js.map +1 -1
- package/package.json +2 -2
package/dist/taco.cjs
CHANGED
@@ -35695,7 +35695,8 @@ const DEFAULT_PRESET = {
|
|
35695
35695
|
enableRowDrop: false,
|
35696
35696
|
enableRowGoto: false,
|
35697
35697
|
enableRowHeight: false,
|
35698
|
-
enableSaveSettings: false
|
35698
|
+
enableSaveSettings: false,
|
35699
|
+
enableSaveSettingsLocally: true
|
35699
35700
|
};
|
35700
35701
|
const presets = {
|
35701
35702
|
// View/edit/create on page
|
@@ -35722,7 +35723,8 @@ const presets = {
|
|
35722
35723
|
enableRowDrop: true,
|
35723
35724
|
enableRowGoto: true,
|
35724
35725
|
enableRowHeight: true,
|
35725
|
-
enableSaveSettings: true
|
35726
|
+
enableSaveSettings: true,
|
35727
|
+
enableSaveSettingsLocally: true
|
35726
35728
|
},
|
35727
35729
|
// View/create in dialog
|
35728
35730
|
list: {
|
@@ -35748,7 +35750,8 @@ const presets = {
|
|
35748
35750
|
enableRowDrop: false,
|
35749
35751
|
enableRowGoto: false,
|
35750
35752
|
enableRowHeight: false,
|
35751
|
-
enableSaveSettings: true
|
35753
|
+
enableSaveSettings: true,
|
35754
|
+
enableSaveSettingsLocally: true
|
35752
35755
|
},
|
35753
35756
|
// View in card or dialog
|
35754
35757
|
simple: {
|
@@ -35774,7 +35777,8 @@ const presets = {
|
|
35774
35777
|
enableRowDrop: false,
|
35775
35778
|
enableRowGoto: false,
|
35776
35779
|
enableRowHeight: false,
|
35777
|
-
enableSaveSettings: true
|
35780
|
+
enableSaveSettings: true,
|
35781
|
+
enableSaveSettingsLocally: true
|
35778
35782
|
}
|
35779
35783
|
};
|
35780
35784
|
function getTableFeaturePreset(props) {
|
@@ -35813,7 +35817,8 @@ function getTableFeaturePreset(props) {
|
|
35813
35817
|
enableRowGoto: enableRowGoto && !!props.onRowGoto,
|
35814
35818
|
enableRowExpansionAll: enableRowExpansion && enableRowExpansionAll && !!props.rowExpansionRenderer,
|
35815
35819
|
enableRowHeight: props.enableRowHeight ?? presetOptions.enableRowHeight,
|
35816
|
-
enableSaveSettings: props.enableSaveSettings ?? presetOptions.enableSaveSettings
|
35820
|
+
enableSaveSettings: props.enableSaveSettings ?? presetOptions.enableSaveSettings,
|
35821
|
+
enableSaveSettingsLocally: props.enableSaveSettingsLocally ?? presetOptions.enableSaveSettingsLocally
|
35817
35822
|
};
|
35818
35823
|
}
|
35819
35824
|
function useTableColumnFreezing(isEnabled = false) {
|
@@ -36363,11 +36368,11 @@ function useEnabledSettings(isEnabled) {
|
|
36363
36368
|
return [options, Object.values(options).some((o2) => o2 === true)];
|
36364
36369
|
}, [isEnabled]);
|
36365
36370
|
}
|
36366
|
-
function useTableSettings(isEnabled = false, id2, defaultSettings = {}, onChangeSettings) {
|
36371
|
+
function useTableSettings(isEnabled = false, id2, defaultSettings = {}, onChangeSettings, enableSaveSettingsLocally = true) {
|
36367
36372
|
const uniqueId3 = useUniqueTableId(id2);
|
36368
36373
|
const [enabledSettings, hasSomeEnabledSettings] = useEnabledSettings(isEnabled);
|
36369
36374
|
const [persistedSettings, _setPersistedSettings] = useLocalStorage(
|
36370
|
-
hasSomeEnabledSettings ? uniqueId3 : void 0,
|
36375
|
+
hasSomeEnabledSettings && enableSaveSettingsLocally ? uniqueId3 : void 0,
|
36371
36376
|
removeDisabledSettings(defaultSettings, enabledSettings)
|
36372
36377
|
);
|
36373
36378
|
const setPersistedSettings = React.useCallback(
|
@@ -36376,17 +36381,20 @@ function useTableSettings(isEnabled = false, id2, defaultSettings = {}, onChange
|
|
36376
36381
|
return;
|
36377
36382
|
}
|
36378
36383
|
const sanitizedSettings = removeDisabledSettings(value, enabledSettings);
|
36379
|
-
|
36384
|
+
if (enableSaveSettingsLocally) {
|
36385
|
+
_setPersistedSettings(sanitizedSettings);
|
36386
|
+
}
|
36380
36387
|
if (typeof onChangeSettings === "function") {
|
36381
36388
|
onChangeSettings(sanitizedSettings);
|
36382
36389
|
}
|
36383
36390
|
},
|
36384
|
-
[hasSomeEnabledSettings, onChangeSettings, JSON.stringify(enabledSettings)]
|
36391
|
+
[hasSomeEnabledSettings, enableSaveSettingsLocally, onChangeSettings, JSON.stringify(enabledSettings)]
|
36385
36392
|
);
|
36386
36393
|
if (!hasSomeEnabledSettings) {
|
36387
36394
|
return [defaultSettings, () => void 0];
|
36388
36395
|
}
|
36389
|
-
|
36396
|
+
const currentSettings = enableSaveSettingsLocally ? persistedSettings : removeDisabledSettings(defaultSettings, enabledSettings);
|
36397
|
+
return [currentSettings, setPersistedSettings];
|
36390
36398
|
}
|
36391
36399
|
function removeDisabledSettings(settings, enabledSettings) {
|
36392
36400
|
const sanitizedSettings = { ...settings };
|
@@ -36495,7 +36503,7 @@ function useTableSearchListener(table) {
|
|
36495
36503
|
const meta = table.options.meta;
|
36496
36504
|
const localization = useLocalization();
|
36497
36505
|
const hiddenColumns = getHiddenColumns(table.getState().columnVisibility);
|
36498
|
-
const query =
|
36506
|
+
const query = table.getState().globalFilter;
|
36499
36507
|
useLazyEffect(() => {
|
36500
36508
|
if (meta.search.isEnabled) {
|
36501
36509
|
const currentFilter = query;
|
@@ -36673,7 +36681,8 @@ function useTableManager(props, ref, meta, internalColumns) {
|
|
36673
36681
|
options.enableSaveSettings,
|
36674
36682
|
safeId,
|
36675
36683
|
props.defaultSettings,
|
36676
|
-
props.onChangeSettings
|
36684
|
+
props.onChangeSettings,
|
36685
|
+
props.enableSaveSettingsLocally
|
36677
36686
|
);
|
36678
36687
|
const data = props.data ?? DEFAULT_EMPTY_ARRAY;
|
36679
36688
|
const length = props.length ?? data.length;
|
@@ -37724,12 +37733,15 @@ const RowContext = React.createContext({
|
|
37724
37733
|
isHovered: false,
|
37725
37734
|
rowIndex: -1
|
37726
37735
|
});
|
37736
|
+
const DELAY_BEFORE_LOAD_MS$1 = 250;
|
37727
37737
|
function Row$2(props) {
|
37728
37738
|
const {
|
37729
37739
|
renderer: RowRenderer,
|
37730
37740
|
cellRenderer: CellRenderer,
|
37731
37741
|
hideInternalColumns = false,
|
37732
37742
|
hideRowActions = false,
|
37743
|
+
scrollDirection,
|
37744
|
+
skipPageLoading = false,
|
37733
37745
|
...displayRowProps
|
37734
37746
|
} = props;
|
37735
37747
|
const tableMeta = props.table.options.meta;
|
@@ -37738,6 +37750,44 @@ function Row$2(props) {
|
|
37738
37750
|
() => ({ isHovered, rowIndex: props.index, hideInternalColumns, hideRowActions }),
|
37739
37751
|
[isHovered, props.index, hideInternalColumns, hideRowActions]
|
37740
37752
|
);
|
37753
|
+
React.useEffect(() => {
|
37754
|
+
let timeout;
|
37755
|
+
if (tableMeta.server.isEnabled && tableMeta.server._experimentalDataLoader2 && !skipPageLoading) {
|
37756
|
+
const pageIndex = Math.floor(props.index / tableMeta.server.pageSize) * tableMeta.server.pageSize / tableMeta.server.pageSize;
|
37757
|
+
const sorting = props.table.getState().sorting;
|
37758
|
+
const filters = props.table.getState().columnFilters;
|
37759
|
+
const search = props.table.getState().globalFilter;
|
37760
|
+
const hiddenColumns = getHiddenColumns(props.table.getState().columnVisibility);
|
37761
|
+
const pageIndexesToFetch = [];
|
37762
|
+
if (scrollDirection === "backward" || !scrollDirection) {
|
37763
|
+
const backIndex = pageIndex - 1;
|
37764
|
+
if (backIndex > -1) {
|
37765
|
+
pageIndexesToFetch.push(backIndex);
|
37766
|
+
}
|
37767
|
+
}
|
37768
|
+
if ((scrollDirection === "forward" || !scrollDirection) && pageIndex + 2 < tableMeta.server.pageCount) {
|
37769
|
+
pageIndexesToFetch.push(pageIndex + 1);
|
37770
|
+
}
|
37771
|
+
if (pageIndexesToFetch.length) {
|
37772
|
+
timeout = setTimeout(() => {
|
37773
|
+
pageIndexesToFetch.forEach((index2) => {
|
37774
|
+
var _a, _b;
|
37775
|
+
(_b = (_a = tableMeta.server).loadPage) == null ? void 0 : _b.call(
|
37776
|
+
_a,
|
37777
|
+
index2,
|
37778
|
+
sorting,
|
37779
|
+
filters,
|
37780
|
+
hiddenColumns,
|
37781
|
+
tableMeta.search.enableGlobalFilter ? search : void 0
|
37782
|
+
);
|
37783
|
+
});
|
37784
|
+
}, DELAY_BEFORE_LOAD_MS$1);
|
37785
|
+
}
|
37786
|
+
}
|
37787
|
+
return () => {
|
37788
|
+
clearTimeout(timeout);
|
37789
|
+
};
|
37790
|
+
}, [tableMeta.server.pages]);
|
37741
37791
|
return /* @__PURE__ */ React.createElement(RowContext.Provider, { value: contextValue }, /* @__PURE__ */ React.createElement(RowRenderer, { ...displayRowProps, cellRenderer: CellRenderer }));
|
37742
37792
|
}
|
37743
37793
|
const DELAY_BEFORE_LOAD_MS = 150;
|
@@ -37889,7 +37939,15 @@ function useTableRenderer(renderers, table, tableRef, length, defaultRowActiveIn
|
|
37889
37939
|
}
|
37890
37940
|
if (!(row == null ? void 0 : row.original)) {
|
37891
37941
|
const skeletonKey = `skeleton-${virtualRow.index}`;
|
37892
|
-
return /* @__PURE__ */ React.createElement(
|
37942
|
+
return /* @__PURE__ */ React.createElement(
|
37943
|
+
SkeletonRow,
|
37944
|
+
{
|
37945
|
+
key: skeletonKey,
|
37946
|
+
index: virtualRow.index,
|
37947
|
+
scrollDirection: virtualiser.scrollDirection ?? void 0,
|
37948
|
+
table
|
37949
|
+
}
|
37950
|
+
);
|
37893
37951
|
}
|
37894
37952
|
const measureRow = (rowHeight) => {
|
37895
37953
|
virtualiser.resizeItem(virtualRow, rowHeight);
|
@@ -37900,6 +37958,7 @@ function useTableRenderer(renderers, table, tableRef, length, defaultRowActiveIn
|
|
37900
37958
|
key: row.id,
|
37901
37959
|
row,
|
37902
37960
|
index: virtualRow.index,
|
37961
|
+
scrollDirection: virtualiser.scrollDirection ?? void 0,
|
37903
37962
|
table,
|
37904
37963
|
measureRow,
|
37905
37964
|
renderer: renderers.row,
|
@@ -39569,7 +39628,7 @@ function Search$1(props) {
|
|
39569
39628
|
(_c = (_b = (_a2 = tableMeta.search).handleSearch) == null ? void 0 : _b.call(_a2, query2, hiddenColumns)) == null ? void 0 : _c.then(() => {
|
39570
39629
|
setLoading(false);
|
39571
39630
|
});
|
39572
|
-
},
|
39631
|
+
}, 150);
|
39573
39632
|
}
|
39574
39633
|
};
|
39575
39634
|
const handleToggleExcludeUnmatchedResults = async (enabled) => {
|
@@ -56599,7 +56658,8 @@ function TemporaryRow(props) {
|
|
56599
56658
|
className,
|
56600
56659
|
onKeyDown: handleKeyDown,
|
56601
56660
|
hideInternalColumns: true,
|
56602
|
-
hideRowActions: !tableMeta.editing.isEditing
|
56661
|
+
hideRowActions: !tableMeta.editing.isEditing,
|
56662
|
+
skipPageLoading: true
|
56603
56663
|
}
|
56604
56664
|
);
|
56605
56665
|
}
|