@ackplus/react-tanstack-data-table 1.1.18 → 1.1.19
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":"use-data-table-engine.d.ts","sourceRoot":"","sources":["../../../src/lib/hooks/use-data-table-engine.ts"],"names":[],"mappings":"AAAA,OAAO,EAKH,aAAa,EACb,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,YAAY,EACjB,KAAK,OAAO,EACf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAEzD,OAAO,EAAiE,SAAS,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAGhH,OAAO,KAAK,EACR,iBAAiB,EACjB,aAAa,EACb,kBAAkB,EAClB,cAAc,EACd,WAAW,EACX,qBAAqB,EAGrB,UAAU,EACb,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,YAAY,EAA6B,MAAM,yBAAyB,CAAC;AAIvF,OAAO,EAAoB,cAAc,EAAE,MAAM,aAAa,CAAC;AAE/D,OAAO,EAKH,KAAK,aAAa,EACrB,MAAM,UAAU,CAAC;AAqBlB,KAAK,aAAa,GAAG;IACjB,OAAO,EAAE,YAAY,CAAC;IACtB,UAAU,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;IACpD,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,cAAc,CAAC;IAC/B,YAAY,EAAE,iBAAiB,CAAC;IAChC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,SAAS,EAAE,aAAa,CAAC;IACzB,WAAW,EAAE,gBAAgB,CAAC;IAC9B,aAAa,EAAE,kBAAkB,CAAC;IAClC,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAA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,CAAC,EAAE,SAAS,CAAC,EAAE,cAAc,EAAE,MAAM,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;KAC/G,CAAC;CACL;AAED,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC5D,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,GACzB,YAAY,CAAC,CAAC,CAAC,CA2xCjB"}
|
|
@@ -586,21 +586,175 @@ function useDataTableEngine(props) {
|
|
|
586
586
|
getGlobalFilter: () => tableRef.current.getState().globalFilter,
|
|
587
587
|
};
|
|
588
588
|
// --- data
|
|
589
|
+
const getBaseData = () => {
|
|
590
|
+
const sData = serverDataRef.current;
|
|
591
|
+
return sData !== null ? sData : dataRef.current;
|
|
592
|
+
};
|
|
593
|
+
const getRowIndexById = (arr, rowId) => arr.findIndex((row, i) => (0, utils_1.generateRowId)(row, i, idKey) === rowId);
|
|
589
594
|
api.data = {
|
|
590
595
|
refresh: (options) => void triggerRefresh(options, "refresh"),
|
|
591
596
|
reload: (options = {}) => { var _a; return void triggerRefresh({ ...options, reason: (_a = options.reason) !== null && _a !== void 0 ? _a : "reload" }, "reload"); },
|
|
592
597
|
resetAll: () => resetAllAndReload(),
|
|
593
|
-
getAllData: () =>
|
|
594
|
-
|
|
595
|
-
const
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
getDataCount: () => {
|
|
599
|
-
const sData = serverDataRef.current;
|
|
600
|
-
const base = sData !== null ? sData : dataRef.current;
|
|
601
|
-
return base.length;
|
|
598
|
+
getAllData: () => [...getBaseData()],
|
|
599
|
+
getRowData: (rowId) => {
|
|
600
|
+
const rows = tableRef.current.getRowModel().rows;
|
|
601
|
+
const row = rows.find((r) => r.id === rowId);
|
|
602
|
+
return row === null || row === void 0 ? void 0 : row.original;
|
|
602
603
|
},
|
|
604
|
+
getRowByIndex: (index) => { var _a; return (_a = tableRef.current.getRowModel().rows[index]) === null || _a === void 0 ? void 0 : _a.original; },
|
|
605
|
+
getDataCount: () => getBaseData().length,
|
|
603
606
|
getFilteredDataCount: () => tableRef.current.getFilteredRowModel().rows.length,
|
|
607
|
+
updateRow: (rowId, updates) => {
|
|
608
|
+
const base = getBaseData();
|
|
609
|
+
const idx = getRowIndexById(base, rowId);
|
|
610
|
+
if (idx === -1)
|
|
611
|
+
return;
|
|
612
|
+
const next = [...base];
|
|
613
|
+
next[idx] = { ...next[idx], ...updates };
|
|
614
|
+
setServerData(next);
|
|
615
|
+
setServerTotal(next.length);
|
|
616
|
+
},
|
|
617
|
+
updateRowByIndex: (index, updates) => {
|
|
618
|
+
const base = getBaseData();
|
|
619
|
+
if (index < 0 || index >= base.length)
|
|
620
|
+
return;
|
|
621
|
+
const next = [...base];
|
|
622
|
+
next[index] = { ...next[index], ...updates };
|
|
623
|
+
setServerData(next);
|
|
624
|
+
setServerTotal(next.length);
|
|
625
|
+
},
|
|
626
|
+
insertRow: (newRow, index) => {
|
|
627
|
+
const base = getBaseData();
|
|
628
|
+
const next = index == null ? [...base, newRow] : [...base.slice(0, index), newRow, ...base.slice(index)];
|
|
629
|
+
setServerData(next);
|
|
630
|
+
setServerTotal(next.length);
|
|
631
|
+
},
|
|
632
|
+
deleteRow: (rowId) => {
|
|
633
|
+
const base = getBaseData();
|
|
634
|
+
const idx = getRowIndexById(base, rowId);
|
|
635
|
+
if (idx === -1)
|
|
636
|
+
return;
|
|
637
|
+
const next = base.filter((_, i) => i !== idx);
|
|
638
|
+
setServerData(next);
|
|
639
|
+
setServerTotal(next.length);
|
|
640
|
+
},
|
|
641
|
+
deleteRowByIndex: (index) => {
|
|
642
|
+
const base = getBaseData();
|
|
643
|
+
if (index < 0 || index >= base.length)
|
|
644
|
+
return;
|
|
645
|
+
const next = base.filter((_, i) => i !== index);
|
|
646
|
+
setServerData(next);
|
|
647
|
+
setServerTotal(next.length);
|
|
648
|
+
},
|
|
649
|
+
deleteSelectedRows: () => {
|
|
650
|
+
var _a, _b, _c, _d;
|
|
651
|
+
const state = (_b = (_a = tableRef.current).getSelectionState) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
652
|
+
if (!state || state.type !== "include" || !state.ids.length)
|
|
653
|
+
return;
|
|
654
|
+
const base = getBaseData();
|
|
655
|
+
const ids = new Set(state.ids);
|
|
656
|
+
const next = base.filter((row, i) => !ids.has((0, utils_1.generateRowId)(row, i, idKey)));
|
|
657
|
+
setServerData(next);
|
|
658
|
+
setServerTotal(next.length);
|
|
659
|
+
(_d = (_c = tableRef.current).deselectAll) === null || _d === void 0 ? void 0 : _d.call(_c);
|
|
660
|
+
},
|
|
661
|
+
replaceAllData: (newData) => {
|
|
662
|
+
setServerData(newData);
|
|
663
|
+
setServerTotal(newData.length);
|
|
664
|
+
},
|
|
665
|
+
updateMultipleRows: (updates) => {
|
|
666
|
+
const base = getBaseData();
|
|
667
|
+
const next = [...base];
|
|
668
|
+
for (const { rowId, data: u } of updates) {
|
|
669
|
+
const idx = getRowIndexById(next, rowId);
|
|
670
|
+
if (idx !== -1)
|
|
671
|
+
next[idx] = { ...next[idx], ...u };
|
|
672
|
+
}
|
|
673
|
+
setServerData(next);
|
|
674
|
+
setServerTotal(next.length);
|
|
675
|
+
},
|
|
676
|
+
insertMultipleRows: (newRows, startIndex) => {
|
|
677
|
+
const base = getBaseData();
|
|
678
|
+
const idx = startIndex !== null && startIndex !== void 0 ? startIndex : base.length;
|
|
679
|
+
const next = [...base.slice(0, idx), ...newRows, ...base.slice(idx)];
|
|
680
|
+
setServerData(next);
|
|
681
|
+
setServerTotal(next.length);
|
|
682
|
+
},
|
|
683
|
+
deleteMultipleRows: (rowIds) => {
|
|
684
|
+
const ids = new Set(rowIds);
|
|
685
|
+
const base = getBaseData();
|
|
686
|
+
const next = base.filter((row, i) => !ids.has((0, utils_1.generateRowId)(row, i, idKey)));
|
|
687
|
+
setServerData(next);
|
|
688
|
+
setServerTotal(next.length);
|
|
689
|
+
},
|
|
690
|
+
updateField: (rowId, fieldName, value) => {
|
|
691
|
+
api.data.updateRow(rowId, { [fieldName]: value });
|
|
692
|
+
},
|
|
693
|
+
updateFieldByIndex: (index, fieldName, value) => {
|
|
694
|
+
api.data.updateRowByIndex(index, { [fieldName]: value });
|
|
695
|
+
},
|
|
696
|
+
findRows: (predicate) => getBaseData().filter(predicate),
|
|
697
|
+
findRowIndex: (predicate) => getBaseData().findIndex(predicate),
|
|
698
|
+
};
|
|
699
|
+
// --- layout (save/restore column visibility, order, sizing, pinning)
|
|
700
|
+
api.layout = {
|
|
701
|
+
saveLayout: () => {
|
|
702
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
703
|
+
const s = tableRef.current.getState();
|
|
704
|
+
return {
|
|
705
|
+
columnVisibility: (_a = s.columnVisibility) !== null && _a !== void 0 ? _a : {},
|
|
706
|
+
columnOrder: (_b = s.columnOrder) !== null && _b !== void 0 ? _b : [],
|
|
707
|
+
columnSizing: (_c = s.columnSizing) !== null && _c !== void 0 ? _c : {},
|
|
708
|
+
columnPinning: (_d = s.columnPinning) !== null && _d !== void 0 ? _d : { left: [], right: [] },
|
|
709
|
+
pagination: (_e = s.pagination) !== null && _e !== void 0 ? _e : { pageIndex: 0, pageSize: 10 },
|
|
710
|
+
globalFilter: (_f = s.globalFilter) !== null && _f !== void 0 ? _f : "",
|
|
711
|
+
columnFilter: (_g = s.columnFilter) !== null && _g !== void 0 ? _g : [],
|
|
712
|
+
};
|
|
713
|
+
},
|
|
714
|
+
restoreLayout: (layout) => {
|
|
715
|
+
var _a, _b, _c;
|
|
716
|
+
if (layout.columnVisibility)
|
|
717
|
+
dispatch({ type: "SET_COLUMN_VISIBILITY", payload: layout.columnVisibility });
|
|
718
|
+
if (layout.columnOrder) {
|
|
719
|
+
dispatch({ type: "SET_COLUMN_ORDER", payload: layout.columnOrder });
|
|
720
|
+
(_a = onColumnDragEndRef.current) === null || _a === void 0 ? void 0 : _a.call(onColumnDragEndRef, layout.columnOrder);
|
|
721
|
+
}
|
|
722
|
+
if (layout.columnSizing) {
|
|
723
|
+
dispatch({ type: "SET_COLUMN_SIZING", payload: layout.columnSizing });
|
|
724
|
+
(_b = onColumnSizingChangeRef.current) === null || _b === void 0 ? void 0 : _b.call(onColumnSizingChangeRef, layout.columnSizing);
|
|
725
|
+
}
|
|
726
|
+
if (layout.columnPinning) {
|
|
727
|
+
dispatch({ type: "SET_COLUMN_PINNING", payload: layout.columnPinning });
|
|
728
|
+
(_c = onColumnPinningChangeRef.current) === null || _c === void 0 ? void 0 : _c.call(onColumnPinningChangeRef, layout.columnPinning);
|
|
729
|
+
}
|
|
730
|
+
if (layout.pagination && enablePagination)
|
|
731
|
+
dispatch({ type: "SET_PAGINATION", payload: layout.pagination });
|
|
732
|
+
if (layout.globalFilter !== undefined)
|
|
733
|
+
dispatch({ type: "SET_GLOBAL_FILTER_RESET_PAGE", payload: layout.globalFilter });
|
|
734
|
+
if (layout.columnFilter)
|
|
735
|
+
dispatch({ type: "SET_COLUMN_FILTER", payload: layout.columnFilter });
|
|
736
|
+
},
|
|
737
|
+
resetLayout: () => {
|
|
738
|
+
var _a, _b, _c;
|
|
739
|
+
const vis = initialStateConfig.columnVisibility || {};
|
|
740
|
+
const order = initialStateConfig.columnOrder || [];
|
|
741
|
+
const sizing = initialStateConfig.columnSizing || {};
|
|
742
|
+
const pinning = initialStateConfig.columnPinning || { left: [], right: [] };
|
|
743
|
+
dispatch({ type: "SET_COLUMN_VISIBILITY", payload: vis });
|
|
744
|
+
dispatch({ type: "SET_COLUMN_ORDER", payload: order });
|
|
745
|
+
dispatch({ type: "SET_COLUMN_SIZING", payload: sizing });
|
|
746
|
+
dispatch({ type: "SET_COLUMN_PINNING", payload: pinning });
|
|
747
|
+
dispatch({ type: "SET_PAGINATION", payload: { pageIndex: 0, pageSize: 10 } });
|
|
748
|
+
dispatch({ type: "SET_GLOBAL_FILTER_RESET_PAGE", payload: "" });
|
|
749
|
+
dispatch({ type: "SET_COLUMN_FILTER", payload: [] });
|
|
750
|
+
(_a = onColumnDragEndRef.current) === null || _a === void 0 ? void 0 : _a.call(onColumnDragEndRef, order);
|
|
751
|
+
(_b = onColumnSizingChangeRef.current) === null || _b === void 0 ? void 0 : _b.call(onColumnSizingChangeRef, sizing);
|
|
752
|
+
(_c = onColumnPinningChangeRef.current) === null || _c === void 0 ? void 0 : _c.call(onColumnPinningChangeRef, pinning);
|
|
753
|
+
},
|
|
754
|
+
resetAll: () => {
|
|
755
|
+
api.layout.resetLayout();
|
|
756
|
+
resetAllAndReload();
|
|
757
|
+
},
|
|
604
758
|
};
|
|
605
759
|
// --- sorting/pagination/filtering - dispatch + callbacks + server fetch policies
|
|
606
760
|
api.sorting = {
|
|
@@ -611,6 +765,13 @@ function useDataTableEngine(props) {
|
|
|
611
765
|
nextFetchDelayRef.current = 0;
|
|
612
766
|
dispatch({ type: "SET_SORTING_RESET_PAGE", payload: cleaned });
|
|
613
767
|
},
|
|
768
|
+
sortColumn: (columnId, direction) => {
|
|
769
|
+
var _a;
|
|
770
|
+
const next = direction === false ? [] : [{ id: columnId, desc: direction === 'desc' }];
|
|
771
|
+
(_a = onSortingChangeRef.current) === null || _a === void 0 ? void 0 : _a.call(onSortingChangeRef, next);
|
|
772
|
+
nextFetchDelayRef.current = 0;
|
|
773
|
+
dispatch({ type: "SET_SORTING_RESET_PAGE", payload: next });
|
|
774
|
+
},
|
|
614
775
|
clearSorting: () => {
|
|
615
776
|
var _a;
|
|
616
777
|
(_a = onSortingChangeRef.current) === null || _a === void 0 ? void 0 : _a.call(onSortingChangeRef, []);
|
|
@@ -634,6 +795,14 @@ function useDataTableEngine(props) {
|
|
|
634
795
|
nextFetchDelayRef.current = 0;
|
|
635
796
|
dispatch({ type: "SET_PAGINATION", payload: next });
|
|
636
797
|
},
|
|
798
|
+
nextPage: () => {
|
|
799
|
+
const prev = uiRef.current.pagination;
|
|
800
|
+
api.pagination.goToPage(Math.min(prev.pageIndex + 1, Math.max(0, Math.ceil((tableTotalRow !== null && tableTotalRow !== void 0 ? tableTotalRow : 0) / prev.pageSize) - 1)));
|
|
801
|
+
},
|
|
802
|
+
previousPage: () => {
|
|
803
|
+
const prev = uiRef.current.pagination;
|
|
804
|
+
api.pagination.goToPage(Math.max(0, prev.pageIndex - 1));
|
|
805
|
+
},
|
|
637
806
|
setPageSize: (pageSize) => {
|
|
638
807
|
var _a;
|
|
639
808
|
const next = { pageIndex: 0, pageSize };
|
|
@@ -641,6 +810,11 @@ function useDataTableEngine(props) {
|
|
|
641
810
|
nextFetchDelayRef.current = 0;
|
|
642
811
|
dispatch({ type: "SET_PAGINATION", payload: next });
|
|
643
812
|
},
|
|
813
|
+
goToFirstPage: () => api.pagination.goToPage(0),
|
|
814
|
+
goToLastPage: () => {
|
|
815
|
+
const prev = uiRef.current.pagination;
|
|
816
|
+
api.pagination.goToPage(Math.max(0, Math.ceil((tableTotalRow !== null && tableTotalRow !== void 0 ? tableTotalRow : 0) / prev.pageSize) - 1));
|
|
817
|
+
},
|
|
644
818
|
resetPagination: () => {
|
|
645
819
|
var _a;
|
|
646
820
|
const next = (initialStateConfig.pagination || { pageIndex: 0, pageSize: 10 });
|
|
@@ -663,10 +837,24 @@ function useDataTableEngine(props) {
|
|
|
663
837
|
dispatch({ type: "SET_GLOBAL_FILTER_RESET_PAGE", payload: "" });
|
|
664
838
|
},
|
|
665
839
|
setColumnFilters: (filters, isApply = false) => handleColumnFilterChangeHandler(filters, isApply),
|
|
840
|
+
addColumnFilter: (columnId, operator, value) => { var _a, _b; return (_b = (_a = tableRef.current).addColumnFilter) === null || _b === void 0 ? void 0 : _b.call(_a, columnId, operator, value); },
|
|
841
|
+
removeColumnFilter: (filterId) => { var _a, _b; return (_b = (_a = tableRef.current).removeColumnFilter) === null || _b === void 0 ? void 0 : _b.call(_a, filterId); },
|
|
842
|
+
clearAllFilters: () => { var _a, _b; return (_b = (_a = tableRef.current).resetColumnFilter) === null || _b === void 0 ? void 0 : _b.call(_a); },
|
|
843
|
+
resetFilters: () => {
|
|
844
|
+
var _a;
|
|
845
|
+
const reset = ((_a = initialStateConfig.columnFilter) !== null && _a !== void 0 ? _a : DEFAULT_INITIAL_STATE.columnFilter);
|
|
846
|
+
handleColumnFilterChangeHandler(reset, true);
|
|
847
|
+
},
|
|
666
848
|
};
|
|
667
849
|
api.columnVisibility = {
|
|
668
850
|
showColumn: (id) => dispatch({ type: "SET_COLUMN_VISIBILITY", payload: { ...uiRef.current.columnVisibility, [id]: true } }),
|
|
669
851
|
hideColumn: (id) => dispatch({ type: "SET_COLUMN_VISIBILITY", payload: { ...uiRef.current.columnVisibility, [id]: false } }),
|
|
852
|
+
toggleColumn: (id) => dispatch({ type: "SET_COLUMN_VISIBILITY", payload: { ...uiRef.current.columnVisibility, [id]: !uiRef.current.columnVisibility[id] } }),
|
|
853
|
+
showAllColumns: () => dispatch({ type: "SET_COLUMN_VISIBILITY", payload: {} }),
|
|
854
|
+
hideAllColumns: () => {
|
|
855
|
+
const all = tableRef.current.getAllLeafColumns().reduce((acc, col) => ({ ...acc, [col.id]: false }), {});
|
|
856
|
+
dispatch({ type: "SET_COLUMN_VISIBILITY", payload: all });
|
|
857
|
+
},
|
|
670
858
|
resetColumnVisibility: () => dispatch({ type: "SET_COLUMN_VISIBILITY", payload: initialStateConfig.columnVisibility || {} }),
|
|
671
859
|
};
|
|
672
860
|
api.columnOrdering = {
|
|
@@ -675,9 +863,45 @@ function useDataTableEngine(props) {
|
|
|
675
863
|
dispatch({ type: "SET_COLUMN_ORDER", payload: next });
|
|
676
864
|
(_a = onColumnDragEndRef.current) === null || _a === void 0 ? void 0 : _a.call(onColumnDragEndRef, next);
|
|
677
865
|
},
|
|
866
|
+
moveColumn: (columnId, toIndex) => {
|
|
867
|
+
var _a;
|
|
868
|
+
const order = uiRef.current.columnOrder.length ? uiRef.current.columnOrder : tableRef.current.getAllLeafColumns().map((c) => c.id);
|
|
869
|
+
const from = order.indexOf(columnId);
|
|
870
|
+
if (from === -1 || toIndex < 0 || toIndex >= order.length)
|
|
871
|
+
return;
|
|
872
|
+
const next = [...order];
|
|
873
|
+
next.splice(from, 1);
|
|
874
|
+
next.splice(toIndex, 0, columnId);
|
|
875
|
+
dispatch({ type: "SET_COLUMN_ORDER", payload: next });
|
|
876
|
+
(_a = onColumnDragEndRef.current) === null || _a === void 0 ? void 0 : _a.call(onColumnDragEndRef, next);
|
|
877
|
+
},
|
|
678
878
|
resetColumnOrder: () => dispatch({ type: "SET_COLUMN_ORDER", payload: initialStateConfig.columnOrder || [] }),
|
|
679
879
|
};
|
|
680
880
|
api.columnPinning = {
|
|
881
|
+
pinColumnLeft: (columnId) => {
|
|
882
|
+
var _a;
|
|
883
|
+
const cur = uiRef.current.columnPinning;
|
|
884
|
+
const left = cur.left.includes(columnId) ? cur.left : [...cur.left.filter((id) => id !== columnId), columnId];
|
|
885
|
+
const right = cur.right.filter((id) => id !== columnId);
|
|
886
|
+
dispatch({ type: "SET_COLUMN_PINNING", payload: { left, right } });
|
|
887
|
+
(_a = onColumnPinningChangeRef.current) === null || _a === void 0 ? void 0 : _a.call(onColumnPinningChangeRef, { left, right });
|
|
888
|
+
},
|
|
889
|
+
pinColumnRight: (columnId) => {
|
|
890
|
+
var _a;
|
|
891
|
+
const cur = uiRef.current.columnPinning;
|
|
892
|
+
const left = cur.left.filter((id) => id !== columnId);
|
|
893
|
+
const right = cur.right.includes(columnId) ? cur.right : [...cur.right.filter((id) => id !== columnId), columnId];
|
|
894
|
+
dispatch({ type: "SET_COLUMN_PINNING", payload: { left, right } });
|
|
895
|
+
(_a = onColumnPinningChangeRef.current) === null || _a === void 0 ? void 0 : _a.call(onColumnPinningChangeRef, { left, right });
|
|
896
|
+
},
|
|
897
|
+
unpinColumn: (columnId) => {
|
|
898
|
+
var _a;
|
|
899
|
+
const cur = uiRef.current.columnPinning;
|
|
900
|
+
const left = cur.left.filter((id) => id !== columnId);
|
|
901
|
+
const right = cur.right.filter((id) => id !== columnId);
|
|
902
|
+
dispatch({ type: "SET_COLUMN_PINNING", payload: { left, right } });
|
|
903
|
+
(_a = onColumnPinningChangeRef.current) === null || _a === void 0 ? void 0 : _a.call(onColumnPinningChangeRef, { left, right });
|
|
904
|
+
},
|
|
681
905
|
setPinning: (next) => {
|
|
682
906
|
var _a;
|
|
683
907
|
dispatch({ type: "SET_COLUMN_PINNING", payload: next });
|
|
@@ -686,16 +910,27 @@ function useDataTableEngine(props) {
|
|
|
686
910
|
resetColumnPinning: () => dispatch({ type: "SET_COLUMN_PINNING", payload: initialStateConfig.columnPinning || { left: [], right: [] } }),
|
|
687
911
|
};
|
|
688
912
|
api.columnResizing = {
|
|
913
|
+
resizeColumn: (columnId, width) => {
|
|
914
|
+
var _a;
|
|
915
|
+
const cur = uiRef.current.columnSizing;
|
|
916
|
+
dispatch({ type: "SET_COLUMN_SIZING", payload: { ...cur, [columnId]: width } });
|
|
917
|
+
(_a = onColumnSizingChangeRef.current) === null || _a === void 0 ? void 0 : _a.call(onColumnSizingChangeRef, { ...cur, [columnId]: width });
|
|
918
|
+
},
|
|
919
|
+
autoSizeColumn: (columnId) => { void columnId; /* no-op: would require measure; use reset for default */ },
|
|
920
|
+
autoSizeAllColumns: () => { },
|
|
689
921
|
resetColumnSizing: () => dispatch({ type: "SET_COLUMN_SIZING", payload: initialStateConfig.columnSizing || {} }),
|
|
690
922
|
};
|
|
691
923
|
api.selection = {
|
|
924
|
+
selectRow: (rowId) => { var _a, _b; return (_b = (_a = tableRef.current).selectRow) === null || _b === void 0 ? void 0 : _b.call(_a, rowId); },
|
|
925
|
+
deselectRow: (rowId) => { var _a, _b; return (_b = (_a = tableRef.current).deselectRow) === null || _b === void 0 ? void 0 : _b.call(_a, rowId); },
|
|
926
|
+
toggleRowSelection: (rowId) => { var _a, _b; return (_b = (_a = tableRef.current).toggleRowSelected) === null || _b === void 0 ? void 0 : _b.call(_a, rowId); },
|
|
927
|
+
selectAll: () => { var _a, _b; return (_b = (_a = tableRef.current).selectAll) === null || _b === void 0 ? void 0 : _b.call(_a); },
|
|
928
|
+
deselectAll: () => { var _a, _b; return (_b = (_a = tableRef.current).deselectAll) === null || _b === void 0 ? void 0 : _b.call(_a); },
|
|
929
|
+
toggleSelectAll: () => { var _a, _b; return (_b = (_a = tableRef.current).toggleAllRowsSelected) === null || _b === void 0 ? void 0 : _b.call(_a); },
|
|
692
930
|
getSelectionState: () => { var _a, _b; return ((_b = (_a = tableRef.current).getSelectionState) === null || _b === void 0 ? void 0 : _b.call(_a)) || { ids: [], type: "include" }; },
|
|
693
931
|
getSelectedRows: () => tableRef.current.getSelectedRows(),
|
|
694
932
|
getSelectedCount: () => tableRef.current.getSelectedCount(),
|
|
695
933
|
isRowSelected: (rowId) => tableRef.current.getIsRowSelected(rowId) || false,
|
|
696
|
-
// keep using your table extension methods if you have them:
|
|
697
|
-
selectAll: () => { var _a, _b; return (_b = (_a = tableRef.current).selectAll) === null || _b === void 0 ? void 0 : _b.call(_a); },
|
|
698
|
-
deselectAll: () => { var _a, _b; return (_b = (_a = tableRef.current).deselectAll) === null || _b === void 0 ? void 0 : _b.call(_a); },
|
|
699
934
|
};
|
|
700
935
|
// --- export API (use your existing exportClientData/exportServerData)
|
|
701
936
|
api.export = {
|
|
@@ -799,10 +1034,36 @@ function useDataTableEngine(props) {
|
|
|
799
1034
|
},
|
|
800
1035
|
});
|
|
801
1036
|
},
|
|
1037
|
+
exportServerData: async (options) => {
|
|
1038
|
+
const { format, filename: fn = exportFilename, fetchData: customFetchData, chunkSize: cs = exportChunkSize, strictTotalCheck: st = exportStrictTotalCheck, sanitizeCSV: san = exportSanitizeCSV } = options;
|
|
1039
|
+
await runExportWithPolicy({
|
|
1040
|
+
format,
|
|
1041
|
+
filename: fn,
|
|
1042
|
+
mode: "server",
|
|
1043
|
+
execute: async (controller) => {
|
|
1044
|
+
var _a, _b;
|
|
1045
|
+
await (0, utils_1.exportServerData)(tableRef.current, {
|
|
1046
|
+
format,
|
|
1047
|
+
filename: fn,
|
|
1048
|
+
fetchData: customFetchData,
|
|
1049
|
+
currentFilters: { globalFilter: tableRef.current.getState().globalFilter, columnFilter: tableRef.current.getState().columnFilter, sorting: tableRef.current.getState().sorting, pagination: tableRef.current.getState().pagination },
|
|
1050
|
+
selection: (_b = (_a = tableRef.current).getSelectionState) === null || _b === void 0 ? void 0 : _b.call(_a),
|
|
1051
|
+
onProgress: handleExportProgressInternal,
|
|
1052
|
+
onComplete: onExportCompleteRef.current,
|
|
1053
|
+
onError: onExportErrorRef.current,
|
|
1054
|
+
onStateChange: (s) => handleExportStateChangeInternal({ ...s, mode: "server", format, filename: fn, queueLength: queuedExportCount }),
|
|
1055
|
+
signal: controller.signal,
|
|
1056
|
+
chunkSize: cs,
|
|
1057
|
+
strictTotalCheck: st,
|
|
1058
|
+
sanitizeCSV: san,
|
|
1059
|
+
});
|
|
1060
|
+
},
|
|
1061
|
+
});
|
|
1062
|
+
},
|
|
802
1063
|
isExporting: () => exportControllerRef.current != null,
|
|
803
1064
|
cancelExport: () => handleCancelExport(),
|
|
804
1065
|
};
|
|
805
|
-
}, [dataMode, exportChunkSize, exportFilename, exportSanitizeCSV, exportStrictTotalCheck, fetchData, handleCancelExport, handleColumnFilterChangeHandler, handleExportProgressInternal, handleExportStateChangeInternal, initialStateConfig, isServerMode, isServerPagination, isServerSorting, resetAllAndReload, resetPageToFirst, runExportWithPolicy, triggerRefresh, queuedExportCount, tableRef, uiRef, serverDataRef, dataRef, onSortingChangeRef, onPaginationChangeRef, onGlobalFilterChangeRef, onColumnDragEndRef, onColumnPinningChangeRef, onServerExportRef, onExportCompleteRef, onExportErrorRef]);
|
|
1066
|
+
}, [dataMode, exportChunkSize, exportFilename, exportSanitizeCSV, exportStrictTotalCheck, fetchData, handleCancelExport, handleColumnFilterChangeHandler, handleExportProgressInternal, handleExportStateChangeInternal, initialStateConfig, isServerMode, isServerPagination, isServerSorting, resetAllAndReload, resetPageToFirst, runExportWithPolicy, triggerRefresh, queuedExportCount, tableTotalRow, idKey, tableRef, uiRef, serverDataRef, dataRef, onSortingChangeRef, onPaginationChangeRef, onGlobalFilterChangeRef, onColumnDragEndRef, onColumnPinningChangeRef, onColumnSizingChangeRef, onServerExportRef, onExportCompleteRef, onExportErrorRef]);
|
|
806
1067
|
// --- imperative handlers (used by TanStack callbacks above or view)
|
|
807
1068
|
const handleSortingChange = (0, react_1.useCallback)((updaterOrValue) => {
|
|
808
1069
|
var _a;
|
package/package.json
CHANGED
|
@@ -865,22 +865,155 @@ export function useDataTableEngine<T extends Record<string, any>>(
|
|
|
865
865
|
};
|
|
866
866
|
|
|
867
867
|
// --- data
|
|
868
|
+
const getBaseData = () => {
|
|
869
|
+
const sData = serverDataRef.current;
|
|
870
|
+
return sData !== null ? sData : dataRef.current;
|
|
871
|
+
};
|
|
872
|
+
const getRowIndexById = (arr: T[], rowId: string) =>
|
|
873
|
+
arr.findIndex((row, i) => generateRowId(row, i, idKey) === rowId);
|
|
868
874
|
api.data = {
|
|
869
875
|
refresh: (options?: boolean | DataRefreshOptions) => void triggerRefresh(options, "refresh"),
|
|
870
876
|
reload: (options: DataRefreshOptions = {}) => void triggerRefresh({ ...options, reason: options.reason ?? "reload" }, "reload"),
|
|
871
877
|
resetAll: () => resetAllAndReload(),
|
|
878
|
+
getAllData: () => [...getBaseData()],
|
|
879
|
+
getRowData: (rowId: string) => {
|
|
880
|
+
const rows = tableRef.current.getRowModel().rows;
|
|
881
|
+
const row = rows.find((r: any) => r.id === rowId);
|
|
882
|
+
return row?.original as T | undefined;
|
|
883
|
+
},
|
|
884
|
+
getRowByIndex: (index: number) => tableRef.current.getRowModel().rows[index]?.original as T | undefined,
|
|
885
|
+
getDataCount: () => getBaseData().length,
|
|
886
|
+
getFilteredDataCount: () => tableRef.current.getFilteredRowModel().rows.length,
|
|
887
|
+
updateRow: (rowId: string, updates: Partial<T>) => {
|
|
888
|
+
const base = getBaseData();
|
|
889
|
+
const idx = getRowIndexById(base, rowId);
|
|
890
|
+
if (idx === -1) return;
|
|
891
|
+
const next = [...base];
|
|
892
|
+
next[idx] = { ...next[idx], ...updates } as T;
|
|
893
|
+
setServerData(next);
|
|
894
|
+
setServerTotal(next.length);
|
|
895
|
+
},
|
|
896
|
+
updateRowByIndex: (index: number, updates: Partial<T>) => {
|
|
897
|
+
const base = getBaseData();
|
|
898
|
+
if (index < 0 || index >= base.length) return;
|
|
899
|
+
const next = [...base];
|
|
900
|
+
next[index] = { ...next[index], ...updates } as T;
|
|
901
|
+
setServerData(next);
|
|
902
|
+
setServerTotal(next.length);
|
|
903
|
+
},
|
|
904
|
+
insertRow: (newRow: T, index?: number) => {
|
|
905
|
+
const base = getBaseData();
|
|
906
|
+
const next = index == null ? [...base, newRow] : [...base.slice(0, index), newRow, ...base.slice(index)];
|
|
907
|
+
setServerData(next);
|
|
908
|
+
setServerTotal(next.length);
|
|
909
|
+
},
|
|
910
|
+
deleteRow: (rowId: string) => {
|
|
911
|
+
const base = getBaseData();
|
|
912
|
+
const idx = getRowIndexById(base, rowId);
|
|
913
|
+
if (idx === -1) return;
|
|
914
|
+
const next = base.filter((_, i) => i !== idx);
|
|
915
|
+
setServerData(next);
|
|
916
|
+
setServerTotal(next.length);
|
|
917
|
+
},
|
|
918
|
+
deleteRowByIndex: (index: number) => {
|
|
919
|
+
const base = getBaseData();
|
|
920
|
+
if (index < 0 || index >= base.length) return;
|
|
921
|
+
const next = base.filter((_, i) => i !== index);
|
|
922
|
+
setServerData(next);
|
|
923
|
+
setServerTotal(next.length);
|
|
924
|
+
},
|
|
925
|
+
deleteSelectedRows: () => {
|
|
926
|
+
const state = tableRef.current.getSelectionState?.();
|
|
927
|
+
if (!state || state.type !== "include" || !state.ids.length) return;
|
|
928
|
+
const base = getBaseData();
|
|
929
|
+
const ids = new Set(state.ids);
|
|
930
|
+
const next = base.filter((row, i) => !ids.has(generateRowId(row, i, idKey)));
|
|
931
|
+
setServerData(next);
|
|
932
|
+
setServerTotal(next.length);
|
|
933
|
+
tableRef.current.deselectAll?.();
|
|
934
|
+
},
|
|
935
|
+
replaceAllData: (newData: T[]) => {
|
|
936
|
+
setServerData(newData);
|
|
937
|
+
setServerTotal(newData.length);
|
|
938
|
+
},
|
|
939
|
+
updateMultipleRows: (updates: Array<{ rowId: string; data: Partial<T> }>) => {
|
|
940
|
+
const base = getBaseData();
|
|
941
|
+
const next = [...base];
|
|
942
|
+
for (const { rowId, data: u } of updates) {
|
|
943
|
+
const idx = getRowIndexById(next, rowId);
|
|
944
|
+
if (idx !== -1) next[idx] = { ...next[idx], ...u } as T;
|
|
945
|
+
}
|
|
946
|
+
setServerData(next);
|
|
947
|
+
setServerTotal(next.length);
|
|
948
|
+
},
|
|
949
|
+
insertMultipleRows: (newRows: T[], startIndex?: number) => {
|
|
950
|
+
const base = getBaseData();
|
|
951
|
+
const idx = startIndex ?? base.length;
|
|
952
|
+
const next = [...base.slice(0, idx), ...newRows, ...base.slice(idx)];
|
|
953
|
+
setServerData(next);
|
|
954
|
+
setServerTotal(next.length);
|
|
955
|
+
},
|
|
956
|
+
deleteMultipleRows: (rowIds: string[]) => {
|
|
957
|
+
const ids = new Set(rowIds);
|
|
958
|
+
const base = getBaseData();
|
|
959
|
+
const next = base.filter((row, i) => !ids.has(generateRowId(row, i, idKey)));
|
|
960
|
+
setServerData(next);
|
|
961
|
+
setServerTotal(next.length);
|
|
962
|
+
},
|
|
963
|
+
updateField: (rowId: string, fieldName: keyof T, value: any) => {
|
|
964
|
+
api.data.updateRow(rowId, { [fieldName]: value } as Partial<T>);
|
|
965
|
+
},
|
|
966
|
+
updateFieldByIndex: (index: number, fieldName: keyof T, value: any) => {
|
|
967
|
+
api.data.updateRowByIndex(index, { [fieldName]: value } as Partial<T>);
|
|
968
|
+
},
|
|
969
|
+
findRows: (predicate: (row: T) => boolean) => getBaseData().filter(predicate),
|
|
970
|
+
findRowIndex: (predicate: (row: T) => boolean) => getBaseData().findIndex(predicate),
|
|
971
|
+
} as any;
|
|
872
972
|
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
973
|
+
// --- layout (save/restore column visibility, order, sizing, pinning)
|
|
974
|
+
api.layout = {
|
|
975
|
+
saveLayout: () => {
|
|
976
|
+
const s = tableRef.current.getState();
|
|
977
|
+
return {
|
|
978
|
+
columnVisibility: s.columnVisibility ?? {},
|
|
979
|
+
columnOrder: s.columnOrder ?? [],
|
|
980
|
+
columnSizing: s.columnSizing ?? {},
|
|
981
|
+
columnPinning: s.columnPinning ?? { left: [], right: [] },
|
|
982
|
+
pagination: s.pagination ?? { pageIndex: 0, pageSize: 10 },
|
|
983
|
+
globalFilter: s.globalFilter ?? "",
|
|
984
|
+
columnFilter: s.columnFilter ?? [],
|
|
985
|
+
};
|
|
877
986
|
},
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
987
|
+
restoreLayout: (layout: any) => {
|
|
988
|
+
|
|
989
|
+
if (layout.columnVisibility) dispatch({ type: "SET_COLUMN_VISIBILITY", payload: layout.columnVisibility });
|
|
990
|
+
if (layout.columnOrder) { dispatch({ type: "SET_COLUMN_ORDER", payload: layout.columnOrder }); onColumnDragEndRef.current?.(layout.columnOrder); }
|
|
991
|
+
if (layout.columnSizing) { dispatch({ type: "SET_COLUMN_SIZING", payload: layout.columnSizing }); onColumnSizingChangeRef.current?.(layout.columnSizing); }
|
|
992
|
+
if (layout.columnPinning) { dispatch({ type: "SET_COLUMN_PINNING", payload: layout.columnPinning }); onColumnPinningChangeRef.current?.(layout.columnPinning); }
|
|
993
|
+
if (layout.pagination && enablePagination) dispatch({ type: "SET_PAGINATION", payload: layout.pagination as any });
|
|
994
|
+
if (layout.globalFilter !== undefined) dispatch({ type: "SET_GLOBAL_FILTER_RESET_PAGE", payload: layout.globalFilter });
|
|
995
|
+
if (layout.columnFilter) dispatch({ type: "SET_COLUMN_FILTER", payload: layout.columnFilter as any });
|
|
996
|
+
},
|
|
997
|
+
resetLayout: () => {
|
|
998
|
+
const vis = initialStateConfig.columnVisibility || {};
|
|
999
|
+
const order = initialStateConfig.columnOrder || [];
|
|
1000
|
+
const sizing = initialStateConfig.columnSizing || {};
|
|
1001
|
+
const pinning = initialStateConfig.columnPinning || { left: [] as string[], right: [] as string[] };
|
|
1002
|
+
dispatch({ type: "SET_COLUMN_VISIBILITY", payload: vis });
|
|
1003
|
+
dispatch({ type: "SET_COLUMN_ORDER", payload: order });
|
|
1004
|
+
dispatch({ type: "SET_COLUMN_SIZING", payload: sizing });
|
|
1005
|
+
dispatch({ type: "SET_COLUMN_PINNING", payload: pinning });
|
|
1006
|
+
dispatch({ type: "SET_PAGINATION", payload: { pageIndex: 0, pageSize: 10 } });
|
|
1007
|
+
dispatch({ type: "SET_GLOBAL_FILTER_RESET_PAGE", payload: "" });
|
|
1008
|
+
dispatch({ type: "SET_COLUMN_FILTER", payload: [] });
|
|
1009
|
+
onColumnDragEndRef.current?.(order);
|
|
1010
|
+
onColumnSizingChangeRef.current?.(sizing);
|
|
1011
|
+
onColumnPinningChangeRef.current?.(pinning);
|
|
1012
|
+
},
|
|
1013
|
+
resetAll: () => {
|
|
1014
|
+
api.layout.resetLayout();
|
|
1015
|
+
resetAllAndReload();
|
|
882
1016
|
},
|
|
883
|
-
getFilteredDataCount: () => tableRef.current.getFilteredRowModel().rows.length,
|
|
884
1017
|
} as any;
|
|
885
1018
|
|
|
886
1019
|
// --- sorting/pagination/filtering - dispatch + callbacks + server fetch policies
|
|
@@ -891,6 +1024,12 @@ export function useDataTableEngine<T extends Record<string, any>>(
|
|
|
891
1024
|
nextFetchDelayRef.current = 0;
|
|
892
1025
|
dispatch({ type: "SET_SORTING_RESET_PAGE", payload: cleaned });
|
|
893
1026
|
},
|
|
1027
|
+
sortColumn: (columnId: string, direction: 'asc' | 'desc' | false) => {
|
|
1028
|
+
const next: SortingState = direction === false ? [] : [{ id: columnId, desc: direction === 'desc' }];
|
|
1029
|
+
onSortingChangeRef.current?.(next);
|
|
1030
|
+
nextFetchDelayRef.current = 0;
|
|
1031
|
+
dispatch({ type: "SET_SORTING_RESET_PAGE", payload: next });
|
|
1032
|
+
},
|
|
894
1033
|
clearSorting: () => {
|
|
895
1034
|
onSortingChangeRef.current?.([]);
|
|
896
1035
|
nextFetchDelayRef.current = 0;
|
|
@@ -912,12 +1051,25 @@ export function useDataTableEngine<T extends Record<string, any>>(
|
|
|
912
1051
|
nextFetchDelayRef.current = 0;
|
|
913
1052
|
dispatch({ type: "SET_PAGINATION", payload: next });
|
|
914
1053
|
},
|
|
1054
|
+
nextPage: () => {
|
|
1055
|
+
const prev = uiRef.current.pagination;
|
|
1056
|
+
api.pagination.goToPage(Math.min(prev.pageIndex + 1, Math.max(0, Math.ceil((tableTotalRow ?? 0) / prev.pageSize) - 1)));
|
|
1057
|
+
},
|
|
1058
|
+
previousPage: () => {
|
|
1059
|
+
const prev = uiRef.current.pagination;
|
|
1060
|
+
api.pagination.goToPage(Math.max(0, prev.pageIndex - 1));
|
|
1061
|
+
},
|
|
915
1062
|
setPageSize: (pageSize: number) => {
|
|
916
1063
|
const next = { pageIndex: 0, pageSize };
|
|
917
1064
|
onPaginationChangeRef.current?.(next);
|
|
918
1065
|
nextFetchDelayRef.current = 0;
|
|
919
1066
|
dispatch({ type: "SET_PAGINATION", payload: next });
|
|
920
1067
|
},
|
|
1068
|
+
goToFirstPage: () => api.pagination.goToPage(0),
|
|
1069
|
+
goToLastPage: () => {
|
|
1070
|
+
const prev = uiRef.current.pagination;
|
|
1071
|
+
api.pagination.goToPage(Math.max(0, Math.ceil((tableTotalRow ?? 0) / prev.pageSize) - 1));
|
|
1072
|
+
},
|
|
921
1073
|
resetPagination: () => {
|
|
922
1074
|
const next = (initialStateConfig.pagination || { pageIndex: 0, pageSize: 10 }) as any;
|
|
923
1075
|
onPaginationChangeRef.current?.(next);
|
|
@@ -938,11 +1090,24 @@ export function useDataTableEngine<T extends Record<string, any>>(
|
|
|
938
1090
|
dispatch({ type: "SET_GLOBAL_FILTER_RESET_PAGE", payload: "" });
|
|
939
1091
|
},
|
|
940
1092
|
setColumnFilters: (filters: ColumnFilterState, isApply = false) => handleColumnFilterChangeHandler(filters, isApply),
|
|
1093
|
+
addColumnFilter: (columnId: string, operator: string, value: any) => tableRef.current.addColumnFilter?.(columnId, operator, value),
|
|
1094
|
+
removeColumnFilter: (filterId: string) => tableRef.current.removeColumnFilter?.(filterId),
|
|
1095
|
+
clearAllFilters: () => tableRef.current.resetColumnFilter?.(),
|
|
1096
|
+
resetFilters: () => {
|
|
1097
|
+
const reset = (initialStateConfig.columnFilter ?? DEFAULT_INITIAL_STATE.columnFilter) as ColumnFilterState;
|
|
1098
|
+
handleColumnFilterChangeHandler(reset, true);
|
|
1099
|
+
},
|
|
941
1100
|
} as any;
|
|
942
1101
|
|
|
943
1102
|
api.columnVisibility = {
|
|
944
1103
|
showColumn: (id: string) => dispatch({ type: "SET_COLUMN_VISIBILITY", payload: { ...uiRef.current.columnVisibility, [id]: true } }),
|
|
945
1104
|
hideColumn: (id: string) => dispatch({ type: "SET_COLUMN_VISIBILITY", payload: { ...uiRef.current.columnVisibility, [id]: false } }),
|
|
1105
|
+
toggleColumn: (id: string) => dispatch({ type: "SET_COLUMN_VISIBILITY", payload: { ...uiRef.current.columnVisibility, [id]: !uiRef.current.columnVisibility[id] } }),
|
|
1106
|
+
showAllColumns: () => dispatch({ type: "SET_COLUMN_VISIBILITY", payload: {} }),
|
|
1107
|
+
hideAllColumns: () => {
|
|
1108
|
+
const all = tableRef.current.getAllLeafColumns().reduce((acc, col) => ({ ...acc, [col.id]: false }), {} as Record<string, boolean>);
|
|
1109
|
+
dispatch({ type: "SET_COLUMN_VISIBILITY", payload: all });
|
|
1110
|
+
},
|
|
946
1111
|
resetColumnVisibility: () => dispatch({ type: "SET_COLUMN_VISIBILITY", payload: initialStateConfig.columnVisibility || {} }),
|
|
947
1112
|
} as any;
|
|
948
1113
|
|
|
@@ -951,10 +1116,41 @@ export function useDataTableEngine<T extends Record<string, any>>(
|
|
|
951
1116
|
dispatch({ type: "SET_COLUMN_ORDER", payload: next });
|
|
952
1117
|
onColumnDragEndRef.current?.(next);
|
|
953
1118
|
},
|
|
1119
|
+
moveColumn: (columnId: string, toIndex: number) => {
|
|
1120
|
+
const order = uiRef.current.columnOrder.length ? uiRef.current.columnOrder : tableRef.current.getAllLeafColumns().map((c: any) => c.id);
|
|
1121
|
+
const from = order.indexOf(columnId);
|
|
1122
|
+
if (from === -1 || toIndex < 0 || toIndex >= order.length) return;
|
|
1123
|
+
const next = [...order];
|
|
1124
|
+
next.splice(from, 1);
|
|
1125
|
+
next.splice(toIndex, 0, columnId);
|
|
1126
|
+
dispatch({ type: "SET_COLUMN_ORDER", payload: next });
|
|
1127
|
+
onColumnDragEndRef.current?.(next);
|
|
1128
|
+
},
|
|
954
1129
|
resetColumnOrder: () => dispatch({ type: "SET_COLUMN_ORDER", payload: initialStateConfig.columnOrder || [] }),
|
|
955
1130
|
} as any;
|
|
956
1131
|
|
|
957
1132
|
api.columnPinning = {
|
|
1133
|
+
pinColumnLeft: (columnId: string) => {
|
|
1134
|
+
const cur = uiRef.current.columnPinning;
|
|
1135
|
+
const left = cur.left.includes(columnId) ? cur.left : [...cur.left.filter((id: string) => id !== columnId), columnId];
|
|
1136
|
+
const right = cur.right.filter((id: string) => id !== columnId);
|
|
1137
|
+
dispatch({ type: "SET_COLUMN_PINNING", payload: { left, right } });
|
|
1138
|
+
onColumnPinningChangeRef.current?.({ left, right });
|
|
1139
|
+
},
|
|
1140
|
+
pinColumnRight: (columnId: string) => {
|
|
1141
|
+
const cur = uiRef.current.columnPinning;
|
|
1142
|
+
const left = cur.left.filter((id: string) => id !== columnId);
|
|
1143
|
+
const right = cur.right.includes(columnId) ? cur.right : [...cur.right.filter((id: string) => id !== columnId), columnId];
|
|
1144
|
+
dispatch({ type: "SET_COLUMN_PINNING", payload: { left, right } });
|
|
1145
|
+
onColumnPinningChangeRef.current?.({ left, right });
|
|
1146
|
+
},
|
|
1147
|
+
unpinColumn: (columnId: string) => {
|
|
1148
|
+
const cur = uiRef.current.columnPinning;
|
|
1149
|
+
const left = cur.left.filter((id: string) => id !== columnId);
|
|
1150
|
+
const right = cur.right.filter((id: string) => id !== columnId);
|
|
1151
|
+
dispatch({ type: "SET_COLUMN_PINNING", payload: { left, right } });
|
|
1152
|
+
onColumnPinningChangeRef.current?.({ left, right });
|
|
1153
|
+
},
|
|
958
1154
|
setPinning: (next: ColumnPinningState) => {
|
|
959
1155
|
dispatch({ type: "SET_COLUMN_PINNING", payload: next });
|
|
960
1156
|
onColumnPinningChangeRef.current?.(next);
|
|
@@ -963,17 +1159,27 @@ export function useDataTableEngine<T extends Record<string, any>>(
|
|
|
963
1159
|
} as any;
|
|
964
1160
|
|
|
965
1161
|
api.columnResizing = {
|
|
1162
|
+
resizeColumn: (columnId: string, width: number) => {
|
|
1163
|
+
const cur = uiRef.current.columnSizing;
|
|
1164
|
+
dispatch({ type: "SET_COLUMN_SIZING", payload: { ...cur, [columnId]: width } });
|
|
1165
|
+
onColumnSizingChangeRef.current?.({ ...cur, [columnId]: width });
|
|
1166
|
+
},
|
|
1167
|
+
autoSizeColumn: (columnId: string) => { void columnId; /* no-op: would require measure; use reset for default */ },
|
|
1168
|
+
autoSizeAllColumns: () => { /* no-op */ },
|
|
966
1169
|
resetColumnSizing: () => dispatch({ type: "SET_COLUMN_SIZING", payload: initialStateConfig.columnSizing || {} }),
|
|
967
1170
|
} as any;
|
|
968
1171
|
|
|
969
1172
|
api.selection = {
|
|
1173
|
+
selectRow: (rowId: string) => tableRef.current.selectRow?.(rowId),
|
|
1174
|
+
deselectRow: (rowId: string) => tableRef.current.deselectRow?.(rowId),
|
|
1175
|
+
toggleRowSelection: (rowId: string) => tableRef.current.toggleRowSelected?.(rowId),
|
|
1176
|
+
selectAll: () => tableRef.current.selectAll?.(),
|
|
1177
|
+
deselectAll: () => tableRef.current.deselectAll?.(),
|
|
1178
|
+
toggleSelectAll: () => tableRef.current.toggleAllRowsSelected?.(),
|
|
970
1179
|
getSelectionState: () => tableRef.current.getSelectionState?.() || ({ ids: [], type: "include" } as const),
|
|
971
1180
|
getSelectedRows: () => tableRef.current.getSelectedRows(),
|
|
972
1181
|
getSelectedCount: () => tableRef.current.getSelectedCount(),
|
|
973
1182
|
isRowSelected: (rowId: string) => tableRef.current.getIsRowSelected(rowId) || false,
|
|
974
|
-
// keep using your table extension methods if you have them:
|
|
975
|
-
selectAll: () => tableRef.current.selectAll?.(),
|
|
976
|
-
deselectAll: () => tableRef.current.deselectAll?.(),
|
|
977
1183
|
} as any;
|
|
978
1184
|
|
|
979
1185
|
// --- export API (use your existing exportClientData/exportServerData)
|
|
@@ -1084,10 +1290,35 @@ export function useDataTableEngine<T extends Record<string, any>>(
|
|
|
1084
1290
|
});
|
|
1085
1291
|
},
|
|
1086
1292
|
|
|
1293
|
+
exportServerData: async (options: { format: 'csv' | 'excel'; filename?: string; fetchData: (filters?: Partial<any>, selection?: SelectionState, signal?: AbortSignal) => Promise<any>; pageSize?: number; includeHeaders?: boolean; chunkSize?: number; strictTotalCheck?: boolean; sanitizeCSV?: boolean }) => {
|
|
1294
|
+
const { format, filename: fn = exportFilename, fetchData: customFetchData, chunkSize: cs = exportChunkSize, strictTotalCheck: st = exportStrictTotalCheck, sanitizeCSV: san = exportSanitizeCSV } = options;
|
|
1295
|
+
await runExportWithPolicy({
|
|
1296
|
+
format,
|
|
1297
|
+
filename: fn,
|
|
1298
|
+
mode: "server",
|
|
1299
|
+
execute: async (controller) => {
|
|
1300
|
+
await exportServerData(tableRef.current, {
|
|
1301
|
+
format,
|
|
1302
|
+
filename: fn,
|
|
1303
|
+
fetchData: customFetchData,
|
|
1304
|
+
currentFilters: { globalFilter: tableRef.current.getState().globalFilter, columnFilter: tableRef.current.getState().columnFilter, sorting: tableRef.current.getState().sorting, pagination: tableRef.current.getState().pagination },
|
|
1305
|
+
selection: tableRef.current.getSelectionState?.(),
|
|
1306
|
+
onProgress: handleExportProgressInternal,
|
|
1307
|
+
onComplete: onExportCompleteRef.current,
|
|
1308
|
+
onError: onExportErrorRef.current,
|
|
1309
|
+
onStateChange: (s: any) => handleExportStateChangeInternal({ ...s, mode: "server", format, filename: fn, queueLength: queuedExportCount } as any),
|
|
1310
|
+
signal: controller.signal,
|
|
1311
|
+
chunkSize: cs,
|
|
1312
|
+
strictTotalCheck: st,
|
|
1313
|
+
sanitizeCSV: san,
|
|
1314
|
+
});
|
|
1315
|
+
},
|
|
1316
|
+
});
|
|
1317
|
+
},
|
|
1087
1318
|
isExporting: () => exportControllerRef.current != null,
|
|
1088
1319
|
cancelExport: () => handleCancelExport(),
|
|
1089
1320
|
} as any;
|
|
1090
|
-
}, [dataMode, exportChunkSize, exportFilename, exportSanitizeCSV, exportStrictTotalCheck, fetchData, handleCancelExport, handleColumnFilterChangeHandler, handleExportProgressInternal, handleExportStateChangeInternal, initialStateConfig, isServerMode, isServerPagination, isServerSorting, resetAllAndReload, resetPageToFirst, runExportWithPolicy, triggerRefresh, queuedExportCount, tableRef, uiRef, serverDataRef, dataRef, onSortingChangeRef, onPaginationChangeRef, onGlobalFilterChangeRef, onColumnDragEndRef, onColumnPinningChangeRef, onServerExportRef, onExportCompleteRef, onExportErrorRef]);
|
|
1321
|
+
}, [dataMode, exportChunkSize, exportFilename, exportSanitizeCSV, exportStrictTotalCheck, fetchData, handleCancelExport, handleColumnFilterChangeHandler, handleExportProgressInternal, handleExportStateChangeInternal, initialStateConfig, isServerMode, isServerPagination, isServerSorting, resetAllAndReload, resetPageToFirst, runExportWithPolicy, triggerRefresh, queuedExportCount, tableTotalRow, idKey, tableRef, uiRef, serverDataRef, dataRef, onSortingChangeRef, onPaginationChangeRef, onGlobalFilterChangeRef, onColumnDragEndRef, onColumnPinningChangeRef, onColumnSizingChangeRef, onServerExportRef, onExportCompleteRef, onExportErrorRef]);
|
|
1091
1322
|
|
|
1092
1323
|
// --- imperative handlers (used by TanStack callbacks above or view)
|
|
1093
1324
|
const handleSortingChange = useCallback(
|