@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.d.ts
CHANGED
@@ -3362,6 +3362,7 @@ export declare type TableFeatureProps<TType = unknown> = {
|
|
3362
3362
|
enableRowGoto?: boolean;
|
3363
3363
|
enableRowHeight?: boolean;
|
3364
3364
|
enableSaveSettings?: boolean | Partial<TableEnableSettingsOptions>;
|
3365
|
+
enableSaveSettingsLocally?: boolean;
|
3365
3366
|
};
|
3366
3367
|
|
3367
3368
|
export declare type TableFilter = {
|
package/dist/taco.js
CHANGED
@@ -35677,7 +35677,8 @@ const DEFAULT_PRESET = {
|
|
35677
35677
|
enableRowDrop: false,
|
35678
35678
|
enableRowGoto: false,
|
35679
35679
|
enableRowHeight: false,
|
35680
|
-
enableSaveSettings: false
|
35680
|
+
enableSaveSettings: false,
|
35681
|
+
enableSaveSettingsLocally: true
|
35681
35682
|
};
|
35682
35683
|
const presets = {
|
35683
35684
|
// View/edit/create on page
|
@@ -35704,7 +35705,8 @@ const presets = {
|
|
35704
35705
|
enableRowDrop: true,
|
35705
35706
|
enableRowGoto: true,
|
35706
35707
|
enableRowHeight: true,
|
35707
|
-
enableSaveSettings: true
|
35708
|
+
enableSaveSettings: true,
|
35709
|
+
enableSaveSettingsLocally: true
|
35708
35710
|
},
|
35709
35711
|
// View/create in dialog
|
35710
35712
|
list: {
|
@@ -35730,7 +35732,8 @@ const presets = {
|
|
35730
35732
|
enableRowDrop: false,
|
35731
35733
|
enableRowGoto: false,
|
35732
35734
|
enableRowHeight: false,
|
35733
|
-
enableSaveSettings: true
|
35735
|
+
enableSaveSettings: true,
|
35736
|
+
enableSaveSettingsLocally: true
|
35734
35737
|
},
|
35735
35738
|
// View in card or dialog
|
35736
35739
|
simple: {
|
@@ -35756,7 +35759,8 @@ const presets = {
|
|
35756
35759
|
enableRowDrop: false,
|
35757
35760
|
enableRowGoto: false,
|
35758
35761
|
enableRowHeight: false,
|
35759
|
-
enableSaveSettings: true
|
35762
|
+
enableSaveSettings: true,
|
35763
|
+
enableSaveSettingsLocally: true
|
35760
35764
|
}
|
35761
35765
|
};
|
35762
35766
|
function getTableFeaturePreset(props) {
|
@@ -35795,7 +35799,8 @@ function getTableFeaturePreset(props) {
|
|
35795
35799
|
enableRowGoto: enableRowGoto && !!props.onRowGoto,
|
35796
35800
|
enableRowExpansionAll: enableRowExpansion && enableRowExpansionAll && !!props.rowExpansionRenderer,
|
35797
35801
|
enableRowHeight: props.enableRowHeight ?? presetOptions.enableRowHeight,
|
35798
|
-
enableSaveSettings: props.enableSaveSettings ?? presetOptions.enableSaveSettings
|
35802
|
+
enableSaveSettings: props.enableSaveSettings ?? presetOptions.enableSaveSettings,
|
35803
|
+
enableSaveSettingsLocally: props.enableSaveSettingsLocally ?? presetOptions.enableSaveSettingsLocally
|
35799
35804
|
};
|
35800
35805
|
}
|
35801
35806
|
function useTableColumnFreezing(isEnabled = false) {
|
@@ -36345,11 +36350,11 @@ function useEnabledSettings(isEnabled) {
|
|
36345
36350
|
return [options, Object.values(options).some((o2) => o2 === true)];
|
36346
36351
|
}, [isEnabled]);
|
36347
36352
|
}
|
36348
|
-
function useTableSettings(isEnabled = false, id2, defaultSettings = {}, onChangeSettings) {
|
36353
|
+
function useTableSettings(isEnabled = false, id2, defaultSettings = {}, onChangeSettings, enableSaveSettingsLocally = true) {
|
36349
36354
|
const uniqueId3 = useUniqueTableId(id2);
|
36350
36355
|
const [enabledSettings, hasSomeEnabledSettings] = useEnabledSettings(isEnabled);
|
36351
36356
|
const [persistedSettings, _setPersistedSettings] = useLocalStorage(
|
36352
|
-
hasSomeEnabledSettings ? uniqueId3 : void 0,
|
36357
|
+
hasSomeEnabledSettings && enableSaveSettingsLocally ? uniqueId3 : void 0,
|
36353
36358
|
removeDisabledSettings(defaultSettings, enabledSettings)
|
36354
36359
|
);
|
36355
36360
|
const setPersistedSettings = React__default.useCallback(
|
@@ -36358,17 +36363,20 @@ function useTableSettings(isEnabled = false, id2, defaultSettings = {}, onChange
|
|
36358
36363
|
return;
|
36359
36364
|
}
|
36360
36365
|
const sanitizedSettings = removeDisabledSettings(value, enabledSettings);
|
36361
|
-
|
36366
|
+
if (enableSaveSettingsLocally) {
|
36367
|
+
_setPersistedSettings(sanitizedSettings);
|
36368
|
+
}
|
36362
36369
|
if (typeof onChangeSettings === "function") {
|
36363
36370
|
onChangeSettings(sanitizedSettings);
|
36364
36371
|
}
|
36365
36372
|
},
|
36366
|
-
[hasSomeEnabledSettings, onChangeSettings, JSON.stringify(enabledSettings)]
|
36373
|
+
[hasSomeEnabledSettings, enableSaveSettingsLocally, onChangeSettings, JSON.stringify(enabledSettings)]
|
36367
36374
|
);
|
36368
36375
|
if (!hasSomeEnabledSettings) {
|
36369
36376
|
return [defaultSettings, () => void 0];
|
36370
36377
|
}
|
36371
|
-
|
36378
|
+
const currentSettings = enableSaveSettingsLocally ? persistedSettings : removeDisabledSettings(defaultSettings, enabledSettings);
|
36379
|
+
return [currentSettings, setPersistedSettings];
|
36372
36380
|
}
|
36373
36381
|
function removeDisabledSettings(settings, enabledSettings) {
|
36374
36382
|
const sanitizedSettings = { ...settings };
|
@@ -36477,7 +36485,7 @@ function useTableSearchListener(table) {
|
|
36477
36485
|
const meta = table.options.meta;
|
36478
36486
|
const localization = useLocalization();
|
36479
36487
|
const hiddenColumns = getHiddenColumns(table.getState().columnVisibility);
|
36480
|
-
const query =
|
36488
|
+
const query = table.getState().globalFilter;
|
36481
36489
|
useLazyEffect(() => {
|
36482
36490
|
if (meta.search.isEnabled) {
|
36483
36491
|
const currentFilter = query;
|
@@ -36655,7 +36663,8 @@ function useTableManager(props, ref, meta, internalColumns) {
|
|
36655
36663
|
options.enableSaveSettings,
|
36656
36664
|
safeId,
|
36657
36665
|
props.defaultSettings,
|
36658
|
-
props.onChangeSettings
|
36666
|
+
props.onChangeSettings,
|
36667
|
+
props.enableSaveSettingsLocally
|
36659
36668
|
);
|
36660
36669
|
const data = props.data ?? DEFAULT_EMPTY_ARRAY;
|
36661
36670
|
const length = props.length ?? data.length;
|
@@ -37706,12 +37715,15 @@ const RowContext = React__default.createContext({
|
|
37706
37715
|
isHovered: false,
|
37707
37716
|
rowIndex: -1
|
37708
37717
|
});
|
37718
|
+
const DELAY_BEFORE_LOAD_MS$1 = 250;
|
37709
37719
|
function Row$2(props) {
|
37710
37720
|
const {
|
37711
37721
|
renderer: RowRenderer,
|
37712
37722
|
cellRenderer: CellRenderer,
|
37713
37723
|
hideInternalColumns = false,
|
37714
37724
|
hideRowActions = false,
|
37725
|
+
scrollDirection,
|
37726
|
+
skipPageLoading = false,
|
37715
37727
|
...displayRowProps
|
37716
37728
|
} = props;
|
37717
37729
|
const tableMeta = props.table.options.meta;
|
@@ -37720,6 +37732,44 @@ function Row$2(props) {
|
|
37720
37732
|
() => ({ isHovered, rowIndex: props.index, hideInternalColumns, hideRowActions }),
|
37721
37733
|
[isHovered, props.index, hideInternalColumns, hideRowActions]
|
37722
37734
|
);
|
37735
|
+
React__default.useEffect(() => {
|
37736
|
+
let timeout;
|
37737
|
+
if (tableMeta.server.isEnabled && tableMeta.server._experimentalDataLoader2 && !skipPageLoading) {
|
37738
|
+
const pageIndex = Math.floor(props.index / tableMeta.server.pageSize) * tableMeta.server.pageSize / tableMeta.server.pageSize;
|
37739
|
+
const sorting = props.table.getState().sorting;
|
37740
|
+
const filters = props.table.getState().columnFilters;
|
37741
|
+
const search = props.table.getState().globalFilter;
|
37742
|
+
const hiddenColumns = getHiddenColumns(props.table.getState().columnVisibility);
|
37743
|
+
const pageIndexesToFetch = [];
|
37744
|
+
if (scrollDirection === "backward" || !scrollDirection) {
|
37745
|
+
const backIndex = pageIndex - 1;
|
37746
|
+
if (backIndex > -1) {
|
37747
|
+
pageIndexesToFetch.push(backIndex);
|
37748
|
+
}
|
37749
|
+
}
|
37750
|
+
if ((scrollDirection === "forward" || !scrollDirection) && pageIndex + 2 < tableMeta.server.pageCount) {
|
37751
|
+
pageIndexesToFetch.push(pageIndex + 1);
|
37752
|
+
}
|
37753
|
+
if (pageIndexesToFetch.length) {
|
37754
|
+
timeout = setTimeout(() => {
|
37755
|
+
pageIndexesToFetch.forEach((index2) => {
|
37756
|
+
var _a, _b;
|
37757
|
+
(_b = (_a = tableMeta.server).loadPage) == null ? void 0 : _b.call(
|
37758
|
+
_a,
|
37759
|
+
index2,
|
37760
|
+
sorting,
|
37761
|
+
filters,
|
37762
|
+
hiddenColumns,
|
37763
|
+
tableMeta.search.enableGlobalFilter ? search : void 0
|
37764
|
+
);
|
37765
|
+
});
|
37766
|
+
}, DELAY_BEFORE_LOAD_MS$1);
|
37767
|
+
}
|
37768
|
+
}
|
37769
|
+
return () => {
|
37770
|
+
clearTimeout(timeout);
|
37771
|
+
};
|
37772
|
+
}, [tableMeta.server.pages]);
|
37723
37773
|
return /* @__PURE__ */ React__default.createElement(RowContext.Provider, { value: contextValue }, /* @__PURE__ */ React__default.createElement(RowRenderer, { ...displayRowProps, cellRenderer: CellRenderer }));
|
37724
37774
|
}
|
37725
37775
|
const DELAY_BEFORE_LOAD_MS = 150;
|
@@ -37871,7 +37921,15 @@ function useTableRenderer(renderers, table, tableRef, length, defaultRowActiveIn
|
|
37871
37921
|
}
|
37872
37922
|
if (!(row == null ? void 0 : row.original)) {
|
37873
37923
|
const skeletonKey = `skeleton-${virtualRow.index}`;
|
37874
|
-
return /* @__PURE__ */ React__default.createElement(
|
37924
|
+
return /* @__PURE__ */ React__default.createElement(
|
37925
|
+
SkeletonRow,
|
37926
|
+
{
|
37927
|
+
key: skeletonKey,
|
37928
|
+
index: virtualRow.index,
|
37929
|
+
scrollDirection: virtualiser.scrollDirection ?? void 0,
|
37930
|
+
table
|
37931
|
+
}
|
37932
|
+
);
|
37875
37933
|
}
|
37876
37934
|
const measureRow = (rowHeight) => {
|
37877
37935
|
virtualiser.resizeItem(virtualRow, rowHeight);
|
@@ -37882,6 +37940,7 @@ function useTableRenderer(renderers, table, tableRef, length, defaultRowActiveIn
|
|
37882
37940
|
key: row.id,
|
37883
37941
|
row,
|
37884
37942
|
index: virtualRow.index,
|
37943
|
+
scrollDirection: virtualiser.scrollDirection ?? void 0,
|
37885
37944
|
table,
|
37886
37945
|
measureRow,
|
37887
37946
|
renderer: renderers.row,
|
@@ -39551,7 +39610,7 @@ function Search$1(props) {
|
|
39551
39610
|
(_c = (_b = (_a2 = tableMeta.search).handleSearch) == null ? void 0 : _b.call(_a2, query2, hiddenColumns)) == null ? void 0 : _c.then(() => {
|
39552
39611
|
setLoading(false);
|
39553
39612
|
});
|
39554
|
-
},
|
39613
|
+
}, 150);
|
39555
39614
|
}
|
39556
39615
|
};
|
39557
39616
|
const handleToggleExcludeUnmatchedResults = async (enabled) => {
|
@@ -56581,7 +56640,8 @@ function TemporaryRow(props) {
|
|
56581
56640
|
className,
|
56582
56641
|
onKeyDown: handleKeyDown,
|
56583
56642
|
hideInternalColumns: true,
|
56584
|
-
hideRowActions: !tableMeta.editing.isEditing
|
56643
|
+
hideRowActions: !tableMeta.editing.isEditing,
|
56644
|
+
skipPageLoading: true
|
56585
56645
|
}
|
56586
56646
|
);
|
56587
56647
|
}
|