@vueye-table/core 3.0.0-alpha.8 → 3.0.0-beta.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/index.d.ts +14 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +47 -18
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -287,6 +287,9 @@ interface GridKey {
|
|
|
287
287
|
}
|
|
288
288
|
/** What a key press asks a grid to do while no cell is being edited. */
|
|
289
289
|
type GridCommand = {
|
|
290
|
+
readonly type: "tree";
|
|
291
|
+
readonly action: "expand" | "collapse" | "child" | "parent" | "siblings";
|
|
292
|
+
} | {
|
|
290
293
|
readonly type: "move";
|
|
291
294
|
readonly direction: GridDirection;
|
|
292
295
|
readonly options: MoveOptions;
|
|
@@ -310,7 +313,12 @@ type GridCommand = {
|
|
|
310
313
|
* a printable character starts editing with that character, Delete and Backspace clear, Escape
|
|
311
314
|
* collapses the selection, and Ctrl or Cmd with A, Z, Y select all, undo, and redo.
|
|
312
315
|
*/
|
|
313
|
-
|
|
316
|
+
/** Hierarchy navigation is enabled only at the caller's designated tree column. */
|
|
317
|
+
interface GridTreeContext {
|
|
318
|
+
readonly canExpand: boolean;
|
|
319
|
+
readonly expanded: boolean;
|
|
320
|
+
}
|
|
321
|
+
declare function gridCommand(event: GridKey, tree?: GridTreeContext): GridCommand | undefined;
|
|
314
322
|
//#endregion
|
|
315
323
|
//#region src/undo-stack.d.ts
|
|
316
324
|
/**
|
|
@@ -567,6 +575,8 @@ interface SortInfo {
|
|
|
567
575
|
* frozen and replaced on each change, so comparing snapshots by identity detects a change.
|
|
568
576
|
*/
|
|
569
577
|
interface TableSnapshot<TRow> {
|
|
578
|
+
/** True when hierarchy options are configured, including an empty tree. */
|
|
579
|
+
readonly tree: boolean;
|
|
570
580
|
readonly loadState: LoadState;
|
|
571
581
|
readonly loadedRowCount: number;
|
|
572
582
|
readonly expectedRowCount: number | undefined;
|
|
@@ -694,6 +704,8 @@ interface DataTable<TRow> {
|
|
|
694
704
|
/** Replace the data. The undo stack is cleared unless the data is the table's own. */
|
|
695
705
|
setData(data: readonly TRow[]): void;
|
|
696
706
|
setColumns(columns: readonly ColumnDef<TRow>[]): void;
|
|
707
|
+
/** Change tree search context without replacing rows or clearing loaded children. */
|
|
708
|
+
setTreeFilter(mode: TreeFilter | undefined): void;
|
|
697
709
|
/** Update the total row count of a `manual` table. */
|
|
698
710
|
setRowCount(rowCount: number): void;
|
|
699
711
|
/** Cycle a column through ascending, descending, and unsorted. */
|
|
@@ -775,5 +787,5 @@ interface PendingChanges<TRow> {
|
|
|
775
787
|
*/
|
|
776
788
|
declare function inferColumns<TRow>(rows: readonly TRow[], sample?: number): readonly ColumnDef<TRow>[];
|
|
777
789
|
//#endregion
|
|
778
|
-
export { type AnyColumnDef, type CellChange, type CellEdit, type CellInputEdit, type CellPosition, type CellRange, type CellValueEdit, type ChildStatus, type ColumnAlign, type ColumnDef, type ColumnOptions, type ColumnType, type ComputedColumnDef, type CopyOptions, DEFAULT_PAGE_SIZE, type DataIngestionResult, type DataTable, type DeepKeys, type EditOptions, type EditResult, type EditStatus, type EditorSpec, type ExpandMode, type ExpandedState, type ExportOptions, type GridBounds, type GridCommand, type GridDirection, type GridKey, type GridSelection, type InsertPosition, type LoadState, type MoveOptions, type PageItem, type PaginationState, type ParseResult, type PasteLimit, type PathColumnDef, type PathValue, type PendingCell, type PendingChanges, type RangeFilter, type RowChange, type RowItemKind, type RowKey, type SelectScope, type SelectionCoverage, type SelectionMode, type SortDirection, type SortInfo, type SortRule, type StreamOptions, type StreamResult, type StreamSignal, type TableColumn, type TableIssue, type TableIssueCode, type TableOptions, type TableRenderItem, type TableRow, type TableSnapshot, type TableState, type TableStatePatch, type TreeFilter, type TreeLoadController, type TreeLoadSignal, type TreeOptions, type TreePagination, type UndoStack, type UpdatedRow, type ValidationResult, type Validator, type VirtualAlign, type VirtualItem, type VirtualWindow, type Virtualizer, type VirtualizerOptions, clampPage, clampPosition, columnLabel, compareValues, countPages, createTable, createUndoStack, createVirtualizer, defineColumns, filterRows, formatValue, fromA1, getPath, getRowItemKey, gridCommand, humanize, inferColumns, matchesFilter, moveSelection, paginateRows, paginationItems, parseAs, parseDelimited, rangeContains, resolveColumn, selectCell, selectionRange, setPath, sortRows, toA1, toDelimited, typeOf };
|
|
790
|
+
export { type AnyColumnDef, type CellChange, type CellEdit, type CellInputEdit, type CellPosition, type CellRange, type CellValueEdit, type ChildStatus, type ColumnAlign, type ColumnDef, type ColumnOptions, type ColumnType, type ComputedColumnDef, type CopyOptions, DEFAULT_PAGE_SIZE, type DataIngestionResult, type DataTable, type DeepKeys, type EditOptions, type EditResult, type EditStatus, type EditorSpec, type ExpandMode, type ExpandedState, type ExportOptions, type GridBounds, type GridCommand, type GridDirection, type GridKey, type GridSelection, type GridTreeContext, type InsertPosition, type LoadState, type MoveOptions, type PageItem, type PaginationState, type ParseResult, type PasteLimit, type PathColumnDef, type PathValue, type PendingCell, type PendingChanges, type RangeFilter, type RowChange, type RowItemKind, type RowKey, type SelectScope, type SelectionCoverage, type SelectionMode, type SortDirection, type SortInfo, type SortRule, type StreamOptions, type StreamResult, type StreamSignal, type TableColumn, type TableIssue, type TableIssueCode, type TableOptions, type TableRenderItem, type TableRow, type TableSnapshot, type TableState, type TableStatePatch, type TreeFilter, type TreeLoadController, type TreeLoadSignal, type TreeOptions, type TreePagination, type UndoStack, type UpdatedRow, type ValidationResult, type Validator, type VirtualAlign, type VirtualItem, type VirtualWindow, type Virtualizer, type VirtualizerOptions, clampPage, clampPosition, columnLabel, compareValues, countPages, createTable, createUndoStack, createVirtualizer, defineColumns, filterRows, formatValue, fromA1, getPath, getRowItemKey, gridCommand, humanize, inferColumns, matchesFilter, moveSelection, paginateRows, paginationItems, parseAs, parseDelimited, rangeContains, resolveColumn, selectCell, selectionRange, setPath, sortRows, toA1, toDelimited, typeOf };
|
|
779
791
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/state.ts","../src/issues.ts","../src/path.ts","../src/validation.ts","../src/column.ts","../src/delimited.ts","../src/grid.ts","../src/undo-stack.ts","../src/virtualizer.ts","../src/humanize.ts","../src/tree.ts","../src/row.ts","../src/pipeline.ts","../src/stream.ts","../src/table.ts","../src/pending-changes.ts","../src/infer.ts"],"mappings":";;KAGY;KACA,yBAAyB;KAEzB;;UAGK;WACN;WACA,WAAW;;;UAIL;WACN;WACA;;;;;;;;UASM;WACN,kBAAkB;;WAElB;;WAEA,SAAS,SAAS;WAClB,YAAY;WACZ,oBAAoB;;WAEpB,UAAU;WACV;;WAEA;;;KAIC,8BACA,WAAW,cAAc,WAAW;cAGnC;;;;KC3CD;;;;;UAiCK;WACN,MAAM;WACN;WACA;WACA,SAAS;WACT;;;;KChCN,wEAQD,iCAEK;KAEJ;;KAGO,SAAS,GAAG,8BAA8B,kCAElD,UAAU,kBAGL,WAAW,aACR,KACC,YAAY,EAAE,YAAY,kBAEpB,KAAK,SAAS,YAAY,EAAE,KAAK,MAAM,qBAC5C;;KAGF,UAAU,GAAG,wBAAwB,uBAAuB,eAAe,UACnF,oBAAoB,IAClB,UAAU,YAAY,EAAE,SAAS,4BAA4B,EAAE,0CAEjE,oBAAoB,IAClB,EAAE;;iBAiBQ,QAAQ,iBAAiB;;;;;;iBAmBzB,QAAQ,GACtB,QAAQ,GACR,cACA,gBACA,WAAW,SAAS,sBACnB;;;KChFS;WAA8C;WAA0B;;KACxE,UAAU,QAAQ,SAC5B,OAAO,QACP,KAAK,SACF,mBAAmB,QAAQ;UACf;WACN;WACA;WACA;WACA;WACA;WACA;;UAEM;WACN,QAAQ;WACR;WACA;;;;KCfC;;KAGA;;UAGK;WACN,wBAAwB;WACxB,wBAAwB;;;UAIlB,cAAc,MAAM;;WAE1B;WACA,QAAQ;;WAER;WACA;;WAEA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WACN,QAAQ;WACR,OAAO;;;UAID;WACN;WACA;;KAGC;UAEK;;WAEN;;WAEA;;iBAOK,cAAc,UAAU,cAAc,QAAQ,aAAa;;iBAK3D,WAAW,UAAU,eAAe;;iBAKpC,cACd,WAAW,eACX,WAAW,eACX,QAAQ,YACR,UAAS,cACR;;iBAkCa,eAAe,WAAW,gBAAgB;iBAS1C,cAAc,OAAO,WAAW,UAAU;;iBAU1C,YAAY;;iBAYZ,KAAK,UAAU;;iBAKf,OAAO,oBAAoB;;UAa1B;WACN;WACA;WACA;WACA;WACA;;;KAIC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/state.ts","../src/issues.ts","../src/path.ts","../src/validation.ts","../src/column.ts","../src/delimited.ts","../src/grid.ts","../src/undo-stack.ts","../src/virtualizer.ts","../src/humanize.ts","../src/tree.ts","../src/row.ts","../src/pipeline.ts","../src/stream.ts","../src/table.ts","../src/pending-changes.ts","../src/infer.ts"],"mappings":";;KAGY;KACA,yBAAyB;KAEzB;;UAGK;WACN;WACA,WAAW;;;UAIL;WACN;WACA;;;;;;;;UASM;WACN,kBAAkB;;WAElB;;WAEA,SAAS,SAAS;WAClB,YAAY;WACZ,oBAAoB;;WAEpB,UAAU;WACV;;WAEA;;;KAIC,8BACA,WAAW,cAAc,WAAW;cAGnC;;;;KC3CD;;;;;UAiCK;WACN,MAAM;WACN;WACA;WACA,SAAS;WACT;;;;KChCN,wEAQD,iCAEK;KAEJ;;KAGO,SAAS,GAAG,8BAA8B,kCAElD,UAAU,kBAGL,WAAW,aACR,KACC,YAAY,EAAE,YAAY,kBAEpB,KAAK,SAAS,YAAY,EAAE,KAAK,MAAM,qBAC5C;;KAGF,UAAU,GAAG,wBAAwB,uBAAuB,eAAe,UACnF,oBAAoB,IAClB,UAAU,YAAY,EAAE,SAAS,4BAA4B,EAAE,0CAEjE,oBAAoB,IAClB,EAAE;;iBAiBQ,QAAQ,iBAAiB;;;;;;iBAmBzB,QAAQ,GACtB,QAA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,iBAAiB,gBACjE,SAAS,aAAa,MAAM,WAC3B,UAAU;;;UCvZI;WACN,SAAS;WACT,SAAS;;UAEH,UAAU;WAChB;WACA,QAAQ;WACR,KAAK;WACL,UAAU;;UAEJ,WAAW;WACjB,QAAQ;WACR,KAAK;WACL,UAAU;WACV,kBAAkB,WAAW;;UAEvB,eAAe;WACrB,mBAAmB,UAAU;WAC7B,kBAAkB,WAAW;WAC7B,kBAAkB,UAAU;;;;;;;;iBCMvB,aAAa,MAAM,eAAe,QAAQ,2BAAuB,UAAU"}
|
package/dist/index.js
CHANGED
|
@@ -465,15 +465,23 @@ const ARROWS = {
|
|
|
465
465
|
ArrowLeft: "left",
|
|
466
466
|
ArrowRight: "right"
|
|
467
467
|
};
|
|
468
|
-
|
|
469
|
-
* Map a key press to a grid command, spreadsheet style: arrows move (Shift extends, Ctrl or Cmd
|
|
470
|
-
* jumps to the edge), Tab moves across, Home and End reach the row's ends, Enter or F2 edit,
|
|
471
|
-
* a printable character starts editing with that character, Delete and Backspace clear, Escape
|
|
472
|
-
* collapses the selection, and Ctrl or Cmd with A, Z, Y select all, undo, and redo.
|
|
473
|
-
*/
|
|
474
|
-
function gridCommand(event) {
|
|
468
|
+
function gridCommand(event, tree) {
|
|
475
469
|
const mod = event.ctrlKey === true || event.metaKey === true;
|
|
476
470
|
const shift = event.shiftKey === true;
|
|
471
|
+
if (tree && !mod && !event.altKey) {
|
|
472
|
+
if (event.key === "*") return {
|
|
473
|
+
type: "tree",
|
|
474
|
+
action: "siblings"
|
|
475
|
+
};
|
|
476
|
+
if (!shift && event.key === "ArrowRight" && tree.canExpand) return {
|
|
477
|
+
type: "tree",
|
|
478
|
+
action: tree.expanded ? "child" : "expand"
|
|
479
|
+
};
|
|
480
|
+
if (!shift && event.key === "ArrowLeft") return {
|
|
481
|
+
type: "tree",
|
|
482
|
+
action: tree.canExpand && tree.expanded ? "collapse" : "parent"
|
|
483
|
+
};
|
|
484
|
+
}
|
|
477
485
|
const direction = ARROWS[event.key];
|
|
478
486
|
if (direction) return {
|
|
479
487
|
type: "move",
|
|
@@ -1802,8 +1810,16 @@ function createTable(options) {
|
|
|
1802
1810
|
const selectionMode = options.selectionMode ?? "multiple";
|
|
1803
1811
|
const selectScope = options.selectScope ?? "all";
|
|
1804
1812
|
const manual = options.manual ?? false;
|
|
1813
|
+
let treeFilter = options.treeFilter ?? "ancestors";
|
|
1805
1814
|
const treeEnabled = Boolean(options.getChildren || options.getParentKey || options.hasChildren || options.loadChildren);
|
|
1806
1815
|
const rootPagination = treeEnabled && (manual || (options.paginateBy ?? "root") === "root");
|
|
1816
|
+
const projectedRows = /* @__PURE__ */ new WeakMap();
|
|
1817
|
+
function shareRow(base, next) {
|
|
1818
|
+
const previous = projectedRows.get(base);
|
|
1819
|
+
if (previous && Object.keys(next).every((key) => previous[key] === next[key])) return previous;
|
|
1820
|
+
projectedRows.set(base, next);
|
|
1821
|
+
return next;
|
|
1822
|
+
}
|
|
1807
1823
|
let lazyVersion = 0;
|
|
1808
1824
|
const lazyChildren = /* @__PURE__ */ new Map();
|
|
1809
1825
|
const childStatuses = /* @__PURE__ */ new Map();
|
|
@@ -1897,6 +1913,7 @@ function createTable(options) {
|
|
|
1897
1913
|
};
|
|
1898
1914
|
});
|
|
1899
1915
|
let primedIndex;
|
|
1916
|
+
let reusableRows;
|
|
1900
1917
|
const indexRows = memo((rows, byId) => {
|
|
1901
1918
|
if (primedIndex?.data === rows && primedIndex.columns === byId) return primedIndex.result;
|
|
1902
1919
|
const byKey = /* @__PURE__ */ new Map();
|
|
@@ -1907,11 +1924,16 @@ function createTable(options) {
|
|
|
1907
1924
|
issues.push(issue("duplicate_row_key", `Row ${index} repeats the key "${String(key)}"; it is keyed "${String(key)}#${index}" instead.`, { rowKey: key }));
|
|
1908
1925
|
key = `${String(key)}#${index}`;
|
|
1909
1926
|
}
|
|
1910
|
-
const
|
|
1927
|
+
const previous = reusableRows?.columns === byId ? reusableRows.rows.get(key) : void 0;
|
|
1928
|
+
const row = previous?.original === original && previous.index === index ? previous : createRow(original, key, index, byId, options.getRowCanExpand?.(original) ?? false);
|
|
1911
1929
|
byKey.set(key, row);
|
|
1912
1930
|
return row;
|
|
1913
1931
|
});
|
|
1914
1932
|
stableSource.set(rows, stableRows(rows));
|
|
1933
|
+
reusableRows = {
|
|
1934
|
+
columns: byId,
|
|
1935
|
+
rows: byKey
|
|
1936
|
+
};
|
|
1915
1937
|
return {
|
|
1916
1938
|
rows: indexed,
|
|
1917
1939
|
byKey,
|
|
@@ -1936,12 +1958,12 @@ function createTable(options) {
|
|
|
1936
1958
|
for (const node of model.nodes) index(node.children, node.row.key);
|
|
1937
1959
|
return result;
|
|
1938
1960
|
});
|
|
1939
|
-
const processedTreeStage = memo((model, columns, search, filters, sorting) => processTree(model, columns, {
|
|
1961
|
+
const processedTreeStage = memo((model, columns, search, filters, sorting, mode) => processTree(model, columns, {
|
|
1940
1962
|
...state,
|
|
1941
1963
|
search,
|
|
1942
1964
|
filters,
|
|
1943
1965
|
sorting
|
|
1944
|
-
},
|
|
1966
|
+
}, mode, manual));
|
|
1945
1967
|
const flattenTree = createTreeFlattener();
|
|
1946
1968
|
const emptyAncestors = /* @__PURE__ */ new Set();
|
|
1947
1969
|
const singleTreePath = memo((model, expanded) => {
|
|
@@ -2022,11 +2044,11 @@ function createTable(options) {
|
|
|
2022
2044
|
const selected = new Set(selection);
|
|
2023
2045
|
const rows = mapList(indexed.rows, (row) => {
|
|
2024
2046
|
const isExpanded = row.canExpand && (expanded === true || (keys?.has(row.key) ?? false));
|
|
2025
|
-
return isExpanded || selected.has(row.key) ? Object.freeze({
|
|
2047
|
+
return isExpanded || selected.has(row.key) ? shareRow(row, Object.freeze({
|
|
2026
2048
|
...row,
|
|
2027
2049
|
isExpanded,
|
|
2028
2050
|
selection: selected.has(row.key) ? "all" : "none"
|
|
2029
|
-
}) : row;
|
|
2051
|
+
})) : row;
|
|
2030
2052
|
});
|
|
2031
2053
|
return {
|
|
2032
2054
|
rows,
|
|
@@ -2054,11 +2076,11 @@ function createTable(options) {
|
|
|
2054
2076
|
function computeSnapshot() {
|
|
2055
2077
|
const cellProblems = validation.problems();
|
|
2056
2078
|
const dirty = new Set(pendingChanges.entries.keys());
|
|
2057
|
-
const metadata = (row) => dirty.has(row.key) || cellProblems.has(row.key) ? Object.freeze({
|
|
2079
|
+
const metadata = (row) => dirty.has(row.key) || cellProblems.has(row.key) ? shareRow(row, Object.freeze({
|
|
2058
2080
|
...row,
|
|
2059
2081
|
isDirty: dirty.has(row.key),
|
|
2060
2082
|
cellIssues: cellProblems.get(row.key)
|
|
2061
|
-
}) : row;
|
|
2083
|
+
})) : row;
|
|
2062
2084
|
const { columns, byId, issues: columnIssues } = resolveColumns(definitions);
|
|
2063
2085
|
const model = treeEnabled ? treeStage(data, byId, lazyVersion) : void 0;
|
|
2064
2086
|
const indexed = model ? {
|
|
@@ -2088,7 +2110,7 @@ function createTable(options) {
|
|
|
2088
2110
|
let treeRow;
|
|
2089
2111
|
let totalCount = indexed.rows.length;
|
|
2090
2112
|
if (model) {
|
|
2091
|
-
const processed = processedTreeStage(model, columns, state.search, state.filters, state.sorting);
|
|
2113
|
+
const processed = processedTreeStage(model, columns, state.search, state.filters, state.sorting, treeFilter);
|
|
2092
2114
|
const ancestors = expandMode === "single" ? singleTreePath(model, state.expanded) : emptyAncestors;
|
|
2093
2115
|
const visible = flattenTree(processed, state.expanded, ancestors);
|
|
2094
2116
|
const expandedState = state.expanded;
|
|
@@ -2104,7 +2126,7 @@ function createTable(options) {
|
|
|
2104
2126
|
const status = statuses.get(key) ?? (node.children.length || !node.unloaded ? "loaded" : "idle");
|
|
2105
2127
|
const count = selected.get(node);
|
|
2106
2128
|
const canExpand = node.children.length > 0 || status !== "loaded" || (options.getRowCanExpand?.(node.row.original) ?? false);
|
|
2107
|
-
const result = Object.freeze({
|
|
2129
|
+
const result = shareRow(node.row, Object.freeze({
|
|
2108
2130
|
...node.row,
|
|
2109
2131
|
isDirty: dirty.has(key),
|
|
2110
2132
|
cellIssues: cellProblems.get(key),
|
|
@@ -2115,7 +2137,7 @@ function createTable(options) {
|
|
|
2115
2137
|
canExpand,
|
|
2116
2138
|
isExpanded: canExpand && (expandedState === true || (keys?.has(key) ?? false) || ancestors.has(key) || processed.autoExpanded.has(key)),
|
|
2117
2139
|
selection: coverage(count.selected, count.total)
|
|
2118
|
-
});
|
|
2140
|
+
}));
|
|
2119
2141
|
projected.set(key, result);
|
|
2120
2142
|
return result;
|
|
2121
2143
|
};
|
|
@@ -2188,6 +2210,7 @@ function createTable(options) {
|
|
|
2188
2210
|
priority
|
|
2189
2211
|
}]));
|
|
2190
2212
|
return Object.freeze({
|
|
2213
|
+
tree: treeEnabled,
|
|
2191
2214
|
loadState,
|
|
2192
2215
|
loadedRowCount: indexed.rows.length,
|
|
2193
2216
|
expectedRowCount,
|
|
@@ -2364,7 +2387,7 @@ function createTable(options) {
|
|
|
2364
2387
|
const { columns, byId } = resolveColumns(definitions);
|
|
2365
2388
|
if (treeEnabled) {
|
|
2366
2389
|
const model = treeStage(data, byId, lazyVersion);
|
|
2367
|
-
const first = processedTreeStage(model, columns, candidate.search, candidate.filters, candidate.sorting).roots.find((node) => node.children.length > 0 || (options.hasChildren?.(node.row.original) ?? false) || (options.getRowCanExpand?.(node.row.original) ?? false));
|
|
2390
|
+
const first = processedTreeStage(model, columns, candidate.search, candidate.filters, candidate.sorting, treeFilter).roots.find((node) => node.children.length > 0 || (options.hasChildren?.(node.row.original) ?? false) || (options.getRowCanExpand?.(node.row.original) ?? false));
|
|
2368
2391
|
return first ? [first.row.key] : [];
|
|
2369
2392
|
}
|
|
2370
2393
|
const indexed = indexRows(data, byId);
|
|
@@ -3355,6 +3378,12 @@ function createTable(options) {
|
|
|
3355
3378
|
rowCount = next;
|
|
3356
3379
|
notify();
|
|
3357
3380
|
},
|
|
3381
|
+
setTreeFilter(next) {
|
|
3382
|
+
const mode = next ?? "ancestors";
|
|
3383
|
+
if (mode === treeFilter) return;
|
|
3384
|
+
treeFilter = mode;
|
|
3385
|
+
notify();
|
|
3386
|
+
},
|
|
3358
3387
|
toggleSort(columnId, { multi = false } = {}) {
|
|
3359
3388
|
const current = state.sorting.find((rule) => rule.column === columnId)?.direction;
|
|
3360
3389
|
setSort(columnId, current === void 0 ? "asc" : current === "asc" ? "desc" : void 0, multi);
|