@tanstack/table-core 8.16.0 → 9.0.0-alpha.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/cjs/aggregationFns.cjs +98 -0
- package/dist/cjs/aggregationFns.cjs.map +1 -0
- package/dist/cjs/aggregationFns.d.cts +14 -0
- package/dist/cjs/columnHelper.cjs +19 -0
- package/dist/cjs/columnHelper.cjs.map +1 -0
- package/dist/cjs/columnHelper.d.cts +9 -0
- package/dist/cjs/core/cell.cjs +38 -0
- package/dist/cjs/core/cell.cjs.map +1 -0
- package/dist/cjs/core/cell.d.cts +50 -0
- package/dist/cjs/core/column.cjs +81 -0
- package/dist/cjs/core/column.cjs.map +1 -0
- package/dist/cjs/core/column.d.cts +56 -0
- package/dist/cjs/core/headers.cjs +310 -0
- package/dist/cjs/core/headers.cjs.map +1 -0
- package/dist/cjs/core/headers.d.cts +195 -0
- package/dist/cjs/core/row.cjs +93 -0
- package/dist/cjs/core/row.cjs.map +1 -0
- package/dist/cjs/core/row.d.cts +92 -0
- package/dist/cjs/core/table.cjs +228 -0
- package/dist/cjs/core/table.cjs.map +1 -0
- package/dist/cjs/core/table.d.cts +221 -0
- package/dist/cjs/features/ColumnFaceting.cjs +29 -0
- package/dist/cjs/features/ColumnFaceting.cjs.map +1 -0
- package/dist/cjs/features/ColumnFaceting.d.cts +35 -0
- package/dist/cjs/features/ColumnFiltering.cjs +137 -0
- package/dist/cjs/features/ColumnFiltering.cjs.map +1 -0
- package/dist/cjs/features/ColumnFiltering.d.cts +195 -0
- package/dist/cjs/features/ColumnGrouping.cjs +134 -0
- package/dist/cjs/features/ColumnGrouping.cjs.map +1 -0
- package/dist/cjs/features/ColumnGrouping.d.cts +202 -0
- package/dist/cjs/features/ColumnOrdering.cjs +76 -0
- package/dist/cjs/features/ColumnOrdering.cjs.map +1 -0
- package/dist/cjs/features/ColumnOrdering.d.cts +54 -0
- package/dist/cjs/features/ColumnPinning.cjs +145 -0
- package/dist/cjs/features/ColumnPinning.cjs.map +1 -0
- package/dist/cjs/features/ColumnPinning.d.cts +127 -0
- package/dist/cjs/features/ColumnSizing.cjs +308 -0
- package/dist/cjs/features/ColumnSizing.cjs.map +1 -0
- package/dist/cjs/features/ColumnSizing.d.cts +194 -0
- package/dist/cjs/features/ColumnVisibility.cjs +144 -0
- package/dist/cjs/features/ColumnVisibility.cjs.map +1 -0
- package/dist/cjs/features/ColumnVisibility.d.cts +130 -0
- package/dist/cjs/features/GlobalFaceting.cjs +29 -0
- package/dist/cjs/features/GlobalFaceting.cjs.map +1 -0
- package/dist/cjs/features/GlobalFaceting.d.cts +27 -0
- package/dist/cjs/features/GlobalFiltering.cjs +50 -0
- package/dist/cjs/features/GlobalFiltering.cjs.map +1 -0
- package/dist/cjs/features/GlobalFiltering.d.cts +80 -0
- package/dist/cjs/features/RowExpanding.cjs +154 -0
- package/dist/cjs/features/RowExpanding.cjs.map +1 -0
- package/dist/cjs/features/RowExpanding.d.cts +155 -0
- package/dist/cjs/features/RowPagination.cjs +162 -0
- package/dist/cjs/features/RowPagination.cjs.map +1 -0
- package/dist/cjs/features/RowPagination.d.cts +166 -0
- package/dist/cjs/features/RowPinning.cjs +133 -0
- package/dist/cjs/features/RowPinning.cjs.map +1 -0
- package/dist/cjs/features/RowPinning.d.cts +99 -0
- package/dist/cjs/features/RowSelection.cjs +298 -0
- package/dist/cjs/features/RowSelection.cjs.map +1 -0
- package/dist/cjs/features/RowSelection.d.cts +177 -0
- package/dist/cjs/features/RowSorting.cjs +201 -0
- package/dist/cjs/features/RowSorting.cjs.map +1 -0
- package/dist/cjs/features/RowSorting.d.cts +238 -0
- package/dist/cjs/filterFns.cjs +88 -0
- package/dist/cjs/filterFns.cjs.map +1 -0
- package/dist/cjs/filterFns.d.cts +14 -0
- package/{build/lib/index.js → dist/cjs/index.cjs} +36 -49
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/cjs/index.d.cts +34 -0
- package/{build/lib/sortingFns.js → dist/cjs/sortingFns.cjs} +23 -52
- package/dist/cjs/sortingFns.cjs.map +1 -0
- package/dist/cjs/sortingFns.d.cts +12 -0
- package/dist/cjs/types.d.cts +120 -0
- package/{build/lib/utils/filterRowsUtils.js → dist/cjs/utils/filterRowsUtils.cjs} +34 -46
- package/dist/cjs/utils/filterRowsUtils.cjs.map +1 -0
- package/dist/cjs/utils/filterRowsUtils.d.cts +3 -0
- package/dist/cjs/utils/getCoreRowModel.cjs +54 -0
- package/dist/cjs/utils/getCoreRowModel.cjs.map +1 -0
- package/dist/cjs/utils/getCoreRowModel.d.cts +3 -0
- package/dist/cjs/utils/getExpandedRowModel.cjs +41 -0
- package/dist/cjs/utils/getExpandedRowModel.cjs.map +1 -0
- package/dist/cjs/utils/getExpandedRowModel.d.cts +8 -0
- package/dist/cjs/utils/getFacetedMinMaxValues.cjs +36 -0
- package/dist/cjs/utils/getFacetedMinMaxValues.cjs.map +1 -0
- package/dist/cjs/utils/getFacetedMinMaxValues.d.cts +3 -0
- package/dist/cjs/utils/getFacetedRowModel.cjs +35 -0
- package/dist/cjs/utils/getFacetedRowModel.cjs.map +1 -0
- package/dist/cjs/utils/getFacetedRowModel.d.cts +3 -0
- package/dist/cjs/utils/getFacetedUniqueValues.cjs +38 -0
- package/dist/cjs/utils/getFacetedUniqueValues.cjs.map +1 -0
- package/dist/cjs/utils/getFacetedUniqueValues.d.cts +3 -0
- package/dist/cjs/utils/getFilteredRowModel.cjs +116 -0
- package/dist/cjs/utils/getFilteredRowModel.cjs.map +1 -0
- package/dist/cjs/utils/getFilteredRowModel.d.cts +3 -0
- package/dist/cjs/utils/getGroupedRowModel.cjs +118 -0
- package/dist/cjs/utils/getGroupedRowModel.cjs.map +1 -0
- package/dist/cjs/utils/getGroupedRowModel.d.cts +3 -0
- package/dist/cjs/utils/getPaginationRowModel.cjs +49 -0
- package/dist/cjs/utils/getPaginationRowModel.cjs.map +1 -0
- package/dist/cjs/utils/getPaginationRowModel.d.cts +5 -0
- package/dist/cjs/utils/getSortedRowModel.cjs +91 -0
- package/dist/cjs/utils/getSortedRowModel.cjs.map +1 -0
- package/dist/cjs/utils/getSortedRowModel.d.cts +3 -0
- package/{build/lib/utils.js → dist/cjs/utils.cjs} +30 -41
- package/dist/cjs/utils.cjs.map +1 -0
- package/dist/cjs/utils.d.cts +39 -0
- package/{build/lib → dist/esm}/aggregationFns.d.ts +2 -1
- package/dist/esm/aggregationFns.js +98 -0
- package/dist/esm/aggregationFns.js.map +1 -0
- package/{build/lib → dist/esm}/columnHelper.d.ts +3 -2
- package/dist/esm/columnHelper.js +19 -0
- package/{build/lib → dist/esm}/columnHelper.js.map +1 -1
- package/{build/lib → dist/esm}/core/cell.d.ts +1 -0
- package/dist/esm/core/cell.js +38 -0
- package/{build/lib → dist/esm}/core/cell.js.map +1 -1
- package/{build/lib → dist/esm}/core/column.d.ts +1 -0
- package/dist/esm/core/column.js +81 -0
- package/{build/lib → dist/esm}/core/column.js.map +1 -1
- package/{build/lib → dist/esm}/core/headers.d.ts +1 -0
- package/dist/esm/core/headers.js +310 -0
- package/{build/lib → dist/esm}/core/headers.js.map +1 -1
- package/{build/lib → dist/esm}/core/row.d.ts +1 -0
- package/dist/esm/core/row.js +93 -0
- package/{build/lib → dist/esm}/core/row.js.map +1 -1
- package/{build/lib → dist/esm}/core/table.d.ts +1 -0
- package/dist/esm/core/table.js +228 -0
- package/{build/lib → dist/esm}/core/table.js.map +1 -1
- package/{build/lib → dist/esm}/features/ColumnFaceting.d.ts +1 -0
- package/{build/lib → dist/esm}/features/ColumnFaceting.js +5 -18
- package/{build/lib → dist/esm}/features/ColumnFaceting.js.map +1 -1
- package/{build/lib → dist/esm}/features/ColumnFiltering.d.ts +1 -0
- package/dist/esm/features/ColumnFiltering.js +137 -0
- package/{build/lib → dist/esm}/features/ColumnFiltering.js.map +1 -1
- package/{build/lib → dist/esm}/features/ColumnGrouping.d.ts +1 -0
- package/dist/esm/features/ColumnGrouping.js +134 -0
- package/{build/lib → dist/esm}/features/ColumnGrouping.js.map +1 -1
- package/{build/lib → dist/esm}/features/ColumnOrdering.d.ts +1 -0
- package/dist/esm/features/ColumnOrdering.js +76 -0
- package/{build/lib → dist/esm}/features/ColumnOrdering.js.map +1 -1
- package/{build/lib → dist/esm}/features/ColumnPinning.d.ts +1 -0
- package/dist/esm/features/ColumnPinning.js +145 -0
- package/{build/lib → dist/esm}/features/ColumnPinning.js.map +1 -1
- package/{build/lib → dist/esm}/features/ColumnSizing.d.ts +2 -1
- package/dist/esm/features/ColumnSizing.js +308 -0
- package/{build/lib → dist/esm}/features/ColumnSizing.js.map +1 -1
- package/{build/lib → dist/esm}/features/ColumnVisibility.d.ts +1 -0
- package/dist/esm/features/ColumnVisibility.js +144 -0
- package/{build/lib → dist/esm}/features/ColumnVisibility.js.map +1 -1
- package/{build/lib → dist/esm}/features/GlobalFaceting.d.ts +1 -0
- package/{build/lib → dist/esm}/features/GlobalFaceting.js +8 -21
- package/{build/lib → dist/esm}/features/GlobalFaceting.js.map +1 -1
- package/{build/lib → dist/esm}/features/GlobalFiltering.d.ts +1 -0
- package/dist/esm/features/GlobalFiltering.js +50 -0
- package/{build/lib → dist/esm}/features/GlobalFiltering.js.map +1 -1
- package/{build/lib → dist/esm}/features/RowExpanding.d.ts +1 -0
- package/{build/lib → dist/esm}/features/RowExpanding.js +40 -59
- package/{build/lib → dist/esm}/features/RowExpanding.js.map +1 -1
- package/{build/lib → dist/esm}/features/RowPagination.d.ts +1 -0
- package/dist/esm/features/RowPagination.js +162 -0
- package/{build/lib → dist/esm}/features/RowPagination.js.map +1 -1
- package/{build/lib → dist/esm}/features/RowPinning.d.ts +1 -0
- package/dist/esm/features/RowPinning.js +133 -0
- package/{build/lib → dist/esm}/features/RowPinning.js.map +1 -1
- package/{build/lib → dist/esm}/features/RowSelection.d.ts +1 -0
- package/dist/esm/features/RowSelection.js +298 -0
- package/{build/lib → dist/esm}/features/RowSelection.js.map +1 -1
- package/{build/lib → dist/esm}/features/RowSorting.d.ts +1 -0
- package/dist/esm/features/RowSorting.js +201 -0
- package/{build/lib → dist/esm}/features/RowSorting.js.map +1 -1
- package/{build/lib → dist/esm}/filterFns.d.ts +2 -1
- package/dist/esm/filterFns.js +88 -0
- package/dist/esm/filterFns.js.map +1 -0
- package/dist/esm/index.d.ts +34 -0
- package/dist/esm/index.js +87 -0
- package/dist/esm/index.js.map +1 -0
- package/{build/lib → dist/esm}/sortingFns.d.ts +2 -1
- package/dist/esm/sortingFns.js +91 -0
- package/dist/esm/sortingFns.js.map +1 -0
- package/{build/lib → dist/esm}/types.d.ts +21 -20
- package/{build/lib → dist/esm}/utils/filterRowsUtils.d.ts +1 -0
- package/dist/esm/utils/filterRowsUtils.js +99 -0
- package/dist/esm/utils/filterRowsUtils.js.map +1 -0
- package/{build/lib → dist/esm}/utils/getCoreRowModel.d.ts +1 -0
- package/dist/esm/utils/getCoreRowModel.js +54 -0
- package/{build/lib → dist/esm}/utils/getCoreRowModel.js.map +1 -1
- package/{build/lib → dist/esm}/utils/getExpandedRowModel.d.ts +1 -0
- package/dist/esm/utils/getExpandedRowModel.js +41 -0
- package/dist/esm/utils/getExpandedRowModel.js.map +1 -0
- package/{build/lib → dist/esm}/utils/getFacetedMinMaxValues.d.ts +1 -0
- package/dist/esm/utils/getFacetedMinMaxValues.js +36 -0
- package/dist/esm/utils/getFacetedMinMaxValues.js.map +1 -0
- package/{build/lib → dist/esm}/utils/getFacetedRowModel.d.ts +1 -0
- package/dist/esm/utils/getFacetedRowModel.js +35 -0
- package/{build/lib → dist/esm}/utils/getFacetedRowModel.js.map +1 -1
- package/{build/lib → dist/esm}/utils/getFacetedUniqueValues.d.ts +1 -0
- package/dist/esm/utils/getFacetedUniqueValues.js +38 -0
- package/dist/esm/utils/getFacetedUniqueValues.js.map +1 -0
- package/{build/lib → dist/esm}/utils/getFilteredRowModel.d.ts +1 -0
- package/dist/esm/utils/getFilteredRowModel.js +116 -0
- package/dist/esm/utils/getFilteredRowModel.js.map +1 -0
- package/{build/lib → dist/esm}/utils/getGroupedRowModel.d.ts +1 -0
- package/dist/esm/utils/getGroupedRowModel.js +118 -0
- package/{build/lib → dist/esm}/utils/getGroupedRowModel.js.map +1 -1
- package/{build/lib → dist/esm}/utils/getPaginationRowModel.d.ts +1 -0
- package/dist/esm/utils/getPaginationRowModel.js +49 -0
- package/dist/esm/utils/getPaginationRowModel.js.map +1 -0
- package/{build/lib → dist/esm}/utils/getSortedRowModel.d.ts +1 -0
- package/dist/esm/utils/getSortedRowModel.js +91 -0
- package/{build/lib → dist/esm}/utils/getSortedRowModel.js.map +1 -1
- package/{build/lib → dist/esm}/utils.d.ts +2 -1
- package/dist/esm/utils.js +100 -0
- package/{build/lib → dist/esm}/utils.js.map +1 -1
- package/package.json +15 -19
- package/src/utils/getFilteredRowModel.ts +1 -1
- package/build/lib/aggregationFns.js +0 -108
- package/build/lib/aggregationFns.js.map +0 -1
- package/build/lib/columnHelper.js +0 -71
- package/build/lib/core/cell.js +0 -42
- package/build/lib/core/column.js +0 -80
- package/build/lib/core/headers.js +0 -270
- package/build/lib/core/row.js +0 -89
- package/build/lib/core/table.js +0 -212
- package/build/lib/features/ColumnFiltering.js +0 -151
- package/build/lib/features/ColumnGrouping.js +0 -142
- package/build/lib/features/ColumnOrdering.js +0 -84
- package/build/lib/features/ColumnPinning.js +0 -130
- package/build/lib/features/ColumnSizing.js +0 -270
- package/build/lib/features/ColumnVisibility.js +0 -99
- package/build/lib/features/GlobalFiltering.js +0 -63
- package/build/lib/features/RowPagination.js +0 -169
- package/build/lib/features/RowPinning.js +0 -145
- package/build/lib/features/RowSelection.js +0 -391
- package/build/lib/features/RowSorting.js +0 -226
- package/build/lib/filterFns.js +0 -96
- package/build/lib/filterFns.js.map +0 -1
- package/build/lib/index.d.ts +0 -34
- package/build/lib/index.esm.js +0 -3522
- package/build/lib/index.esm.js.map +0 -1
- package/build/lib/index.js.map +0 -1
- package/build/lib/index.mjs +0 -3522
- package/build/lib/index.mjs.map +0 -1
- package/build/lib/sortingFns.js.map +0 -1
- package/build/lib/utils/filterRowsUtils.js.map +0 -1
- package/build/lib/utils/getCoreRowModel.js +0 -65
- package/build/lib/utils/getExpandedRowModel.js +0 -46
- package/build/lib/utils/getExpandedRowModel.js.map +0 -1
- package/build/lib/utils/getFacetedMinMaxValues.js +0 -43
- package/build/lib/utils/getFacetedMinMaxValues.js.map +0 -1
- package/build/lib/utils/getFacetedRowModel.js +0 -36
- package/build/lib/utils/getFacetedUniqueValues.js +0 -39
- package/build/lib/utils/getFacetedUniqueValues.js.map +0 -1
- package/build/lib/utils/getFilteredRowModel.js +0 -111
- package/build/lib/utils/getFilteredRowModel.js.map +0 -1
- package/build/lib/utils/getGroupedRowModel.js +0 -150
- package/build/lib/utils/getPaginationRowModel.js +0 -60
- package/build/lib/utils/getPaginationRowModel.js.map +0 -1
- package/build/lib/utils/getSortedRowModel.js +0 -102
- package/build/umd/index.development.js +0 -3578
- package/build/umd/index.development.js.map +0 -1
- package/build/umd/index.production.js +0 -12
- package/build/umd/index.production.js.map +0 -1
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { OnChangeFn, Updater, TableFeature } from '../types';
|
|
2
|
+
import { ColumnPinningPosition } from './ColumnPinning.cjs';
|
|
3
|
+
|
|
4
|
+
export interface ColumnSizingTableState {
|
|
5
|
+
columnSizing: ColumnSizingState;
|
|
6
|
+
columnSizingInfo: ColumnSizingInfoState;
|
|
7
|
+
}
|
|
8
|
+
export type ColumnSizingState = Record<string, number>;
|
|
9
|
+
export interface ColumnSizingInfoState {
|
|
10
|
+
columnSizingStart: [string, number][];
|
|
11
|
+
deltaOffset: null | number;
|
|
12
|
+
deltaPercentage: null | number;
|
|
13
|
+
isResizingColumn: false | string;
|
|
14
|
+
startOffset: null | number;
|
|
15
|
+
startSize: null | number;
|
|
16
|
+
}
|
|
17
|
+
export type ColumnResizeMode = 'onChange' | 'onEnd';
|
|
18
|
+
export type ColumnResizeDirection = 'ltr' | 'rtl';
|
|
19
|
+
export interface ColumnSizingOptions {
|
|
20
|
+
/**
|
|
21
|
+
* Determines when the columnSizing state is updated. `onChange` updates the state when the user is dragging the resize handle. `onEnd` updates the state when the user releases the resize handle.
|
|
22
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-sizing#columnresizemode)
|
|
23
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-sizing)
|
|
24
|
+
*/
|
|
25
|
+
columnResizeMode?: ColumnResizeMode;
|
|
26
|
+
/**
|
|
27
|
+
* Enables or disables column resizing for the column.
|
|
28
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-sizing#enablecolumnresizing)
|
|
29
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-sizing)
|
|
30
|
+
*/
|
|
31
|
+
enableColumnResizing?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Enables or disables right-to-left support for resizing the column. defaults to 'ltr'.
|
|
34
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-sizing#columnResizeDirection)
|
|
35
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-sizing)
|
|
36
|
+
*/
|
|
37
|
+
columnResizeDirection?: ColumnResizeDirection;
|
|
38
|
+
/**
|
|
39
|
+
* If provided, this function will be called with an `updaterFn` when `state.columnSizing` changes. This overrides the default internal state management, so you will also need to supply `state.columnSizing` from your own managed state.
|
|
40
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-sizing#oncolumnsizingchange)
|
|
41
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-sizing)
|
|
42
|
+
*/
|
|
43
|
+
onColumnSizingChange?: OnChangeFn<ColumnSizingState>;
|
|
44
|
+
/**
|
|
45
|
+
* If provided, this function will be called with an `updaterFn` when `state.columnSizingInfo` changes. This overrides the default internal state management, so you will also need to supply `state.columnSizingInfo` from your own managed state.
|
|
46
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-sizing#oncolumnsizinginfochange)
|
|
47
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-sizing)
|
|
48
|
+
*/
|
|
49
|
+
onColumnSizingInfoChange?: OnChangeFn<ColumnSizingInfoState>;
|
|
50
|
+
}
|
|
51
|
+
export type ColumnSizingDefaultOptions = Pick<ColumnSizingOptions, 'columnResizeMode' | 'onColumnSizingChange' | 'onColumnSizingInfoChange' | 'columnResizeDirection'>;
|
|
52
|
+
export interface ColumnSizingInstance {
|
|
53
|
+
/**
|
|
54
|
+
* If pinning, returns the total size of the center portion of the table by calculating the sum of the sizes of all unpinned/center leaf-columns.
|
|
55
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-sizing#getcentertotalsize)
|
|
56
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-sizing)
|
|
57
|
+
*/
|
|
58
|
+
getCenterTotalSize: () => number;
|
|
59
|
+
/**
|
|
60
|
+
* Returns the total size of the left portion of the table by calculating the sum of the sizes of all left leaf-columns.
|
|
61
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-sizing#getlefttotalsize)
|
|
62
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-sizing)
|
|
63
|
+
*/
|
|
64
|
+
getLeftTotalSize: () => number;
|
|
65
|
+
/**
|
|
66
|
+
* Returns the total size of the right portion of the table by calculating the sum of the sizes of all right leaf-columns.
|
|
67
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-sizing#getrighttotalsize)
|
|
68
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-sizing)
|
|
69
|
+
*/
|
|
70
|
+
getRightTotalSize: () => number;
|
|
71
|
+
/**
|
|
72
|
+
* Returns the total size of the table by calculating the sum of the sizes of all leaf-columns.
|
|
73
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-sizing#gettotalsize)
|
|
74
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-sizing)
|
|
75
|
+
*/
|
|
76
|
+
getTotalSize: () => number;
|
|
77
|
+
/**
|
|
78
|
+
* Resets column sizing to its initial state. If `defaultState` is `true`, the default state for the table will be used instead of the initialValue provided to the table.
|
|
79
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-sizing#resetcolumnsizing)
|
|
80
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-sizing)
|
|
81
|
+
*/
|
|
82
|
+
resetColumnSizing: (defaultState?: boolean) => void;
|
|
83
|
+
/**
|
|
84
|
+
* Resets column sizing info to its initial state. If `defaultState` is `true`, the default state for the table will be used instead of the initialValue provided to the table.
|
|
85
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-sizing#resetheadersizeinfo)
|
|
86
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-sizing)
|
|
87
|
+
*/
|
|
88
|
+
resetHeaderSizeInfo: (defaultState?: boolean) => void;
|
|
89
|
+
/**
|
|
90
|
+
* Sets the column sizing state using an updater function or a value. This will trigger the underlying `onColumnSizingChange` function if one is passed to the table options, otherwise the state will be managed automatically by the table.
|
|
91
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-sizing#setcolumnsizing)
|
|
92
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-sizing)
|
|
93
|
+
*/
|
|
94
|
+
setColumnSizing: (updater: Updater<ColumnSizingState>) => void;
|
|
95
|
+
/**
|
|
96
|
+
* Sets the column sizing info state using an updater function or a value. This will trigger the underlying `onColumnSizingInfoChange` function if one is passed to the table options, otherwise the state will be managed automatically by the table.
|
|
97
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-sizing#setcolumnsizinginfo)
|
|
98
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-sizing)
|
|
99
|
+
*/
|
|
100
|
+
setColumnSizingInfo: (updater: Updater<ColumnSizingInfoState>) => void;
|
|
101
|
+
}
|
|
102
|
+
export interface ColumnSizingColumnDef {
|
|
103
|
+
/**
|
|
104
|
+
* Enables or disables column resizing for the column.
|
|
105
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-sizing#enableresizing)
|
|
106
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-sizing)
|
|
107
|
+
*/
|
|
108
|
+
enableResizing?: boolean;
|
|
109
|
+
/**
|
|
110
|
+
* The maximum allowed size for the column
|
|
111
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-sizing#maxsize)
|
|
112
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-sizing)
|
|
113
|
+
*/
|
|
114
|
+
maxSize?: number;
|
|
115
|
+
/**
|
|
116
|
+
* The minimum allowed size for the column
|
|
117
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-sizing#minsize)
|
|
118
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-sizing)
|
|
119
|
+
*/
|
|
120
|
+
minSize?: number;
|
|
121
|
+
/**
|
|
122
|
+
* The desired size for the column
|
|
123
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-sizing#size)
|
|
124
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-sizing)
|
|
125
|
+
*/
|
|
126
|
+
size?: number;
|
|
127
|
+
}
|
|
128
|
+
export interface ColumnSizingColumn {
|
|
129
|
+
/**
|
|
130
|
+
* Returns `true` if the column can be resized.
|
|
131
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-sizing#getcanresize)
|
|
132
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-sizing)
|
|
133
|
+
*/
|
|
134
|
+
getCanResize: () => boolean;
|
|
135
|
+
/**
|
|
136
|
+
* Returns `true` if the column is currently being resized.
|
|
137
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-sizing#getisresizing)
|
|
138
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-sizing)
|
|
139
|
+
*/
|
|
140
|
+
getIsResizing: () => boolean;
|
|
141
|
+
/**
|
|
142
|
+
* Returns the current size of the column.
|
|
143
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-sizing#getsize)
|
|
144
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-sizing)
|
|
145
|
+
*/
|
|
146
|
+
getSize: () => number;
|
|
147
|
+
/**
|
|
148
|
+
* Returns the offset measurement along the row-axis (usually the x-axis for standard tables) for the header. This is effectively a sum of the offset measurements of all preceding (left) headers in relation to the current column.
|
|
149
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-sizing#getstart)
|
|
150
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-sizing)
|
|
151
|
+
*/
|
|
152
|
+
getStart: (position?: ColumnPinningPosition | 'center') => number;
|
|
153
|
+
/**
|
|
154
|
+
* Returns the offset measurement along the row-axis (usually the x-axis for standard tables) for the header. This is effectively a sum of the offset measurements of all succeeding (right) headers in relation to the current column.
|
|
155
|
+
*/
|
|
156
|
+
getAfter: (position?: ColumnPinningPosition | 'center') => number;
|
|
157
|
+
/**
|
|
158
|
+
* Resets the column to its initial size.
|
|
159
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-sizing#resetsize)
|
|
160
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-sizing)
|
|
161
|
+
*/
|
|
162
|
+
resetSize: () => void;
|
|
163
|
+
}
|
|
164
|
+
export interface ColumnSizingHeader {
|
|
165
|
+
/**
|
|
166
|
+
* Returns an event handler function that can be used to resize the header. It can be used as an:
|
|
167
|
+
* - `onMouseDown` handler
|
|
168
|
+
* - `onTouchStart` handler
|
|
169
|
+
*
|
|
170
|
+
* The dragging and release events are automatically handled for you.
|
|
171
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-sizing#getresizehandler)
|
|
172
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-sizing)
|
|
173
|
+
*/
|
|
174
|
+
getResizeHandler: (context?: Document) => (event: unknown) => void;
|
|
175
|
+
/**
|
|
176
|
+
* Returns the current size of the header.
|
|
177
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-sizing#getsize)
|
|
178
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-sizing)
|
|
179
|
+
*/
|
|
180
|
+
getSize: () => number;
|
|
181
|
+
/**
|
|
182
|
+
* Returns the offset measurement along the row-axis (usually the x-axis for standard tables) for the header. This is effectively a sum of the offset measurements of all preceding headers.
|
|
183
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-sizing#getstart)
|
|
184
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-sizing)
|
|
185
|
+
*/
|
|
186
|
+
getStart: (position?: ColumnPinningPosition) => number;
|
|
187
|
+
}
|
|
188
|
+
export declare const defaultColumnSizing: {
|
|
189
|
+
size: number;
|
|
190
|
+
minSize: number;
|
|
191
|
+
maxSize: number;
|
|
192
|
+
};
|
|
193
|
+
export declare const ColumnSizing: TableFeature;
|
|
194
|
+
export declare function passiveEventSupported(): boolean;
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const utils = require("../utils.cjs");
|
|
4
|
+
const ColumnVisibility = {
|
|
5
|
+
getInitialState: (state) => {
|
|
6
|
+
return {
|
|
7
|
+
columnVisibility: {},
|
|
8
|
+
...state
|
|
9
|
+
};
|
|
10
|
+
},
|
|
11
|
+
getDefaultOptions: (table) => {
|
|
12
|
+
return {
|
|
13
|
+
onColumnVisibilityChange: utils.makeStateUpdater("columnVisibility", table)
|
|
14
|
+
};
|
|
15
|
+
},
|
|
16
|
+
createColumn: (column, table) => {
|
|
17
|
+
column.toggleVisibility = (value) => {
|
|
18
|
+
if (column.getCanHide()) {
|
|
19
|
+
table.setColumnVisibility((old) => ({
|
|
20
|
+
...old,
|
|
21
|
+
[column.id]: value ?? !column.getIsVisible()
|
|
22
|
+
}));
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
column.getIsVisible = () => {
|
|
26
|
+
var _a;
|
|
27
|
+
const childColumns = column.columns;
|
|
28
|
+
return (childColumns.length ? childColumns.some((c) => c.getIsVisible()) : (_a = table.getState().columnVisibility) == null ? void 0 : _a[column.id]) ?? true;
|
|
29
|
+
};
|
|
30
|
+
column.getCanHide = () => {
|
|
31
|
+
return (column.columnDef.enableHiding ?? true) && (table.options.enableHiding ?? true);
|
|
32
|
+
};
|
|
33
|
+
column.getToggleVisibilityHandler = () => {
|
|
34
|
+
return (e) => {
|
|
35
|
+
var _a;
|
|
36
|
+
(_a = column.toggleVisibility) == null ? void 0 : _a.call(
|
|
37
|
+
column,
|
|
38
|
+
e.target.checked
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
},
|
|
43
|
+
createRow: (row, table) => {
|
|
44
|
+
row._getAllVisibleCells = utils.memo(
|
|
45
|
+
() => [row.getAllCells(), table.getState().columnVisibility],
|
|
46
|
+
(cells) => {
|
|
47
|
+
return cells.filter((cell) => cell.column.getIsVisible());
|
|
48
|
+
},
|
|
49
|
+
utils.getMemoOptions(table.options, "debugRows", "_getAllVisibleCells")
|
|
50
|
+
);
|
|
51
|
+
row.getVisibleCells = utils.memo(
|
|
52
|
+
() => [
|
|
53
|
+
row.getLeftVisibleCells(),
|
|
54
|
+
row.getCenterVisibleCells(),
|
|
55
|
+
row.getRightVisibleCells()
|
|
56
|
+
],
|
|
57
|
+
(left, center, right) => [...left, ...center, ...right],
|
|
58
|
+
utils.getMemoOptions(table.options, "debugRows", "getVisibleCells")
|
|
59
|
+
);
|
|
60
|
+
},
|
|
61
|
+
createTable: (table) => {
|
|
62
|
+
const makeVisibleColumnsMethod = (key, getColumns) => {
|
|
63
|
+
return utils.memo(
|
|
64
|
+
() => [
|
|
65
|
+
getColumns(),
|
|
66
|
+
getColumns().filter((d) => d.getIsVisible()).map((d) => d.id).join("_")
|
|
67
|
+
],
|
|
68
|
+
(columns) => {
|
|
69
|
+
return columns.filter((d) => {
|
|
70
|
+
var _a;
|
|
71
|
+
return (_a = d.getIsVisible) == null ? void 0 : _a.call(d);
|
|
72
|
+
});
|
|
73
|
+
},
|
|
74
|
+
utils.getMemoOptions(table.options, "debugColumns", key)
|
|
75
|
+
);
|
|
76
|
+
};
|
|
77
|
+
table.getVisibleFlatColumns = makeVisibleColumnsMethod(
|
|
78
|
+
"getVisibleFlatColumns",
|
|
79
|
+
() => table.getAllFlatColumns()
|
|
80
|
+
);
|
|
81
|
+
table.getVisibleLeafColumns = makeVisibleColumnsMethod(
|
|
82
|
+
"getVisibleLeafColumns",
|
|
83
|
+
() => table.getAllLeafColumns()
|
|
84
|
+
);
|
|
85
|
+
table.getLeftVisibleLeafColumns = makeVisibleColumnsMethod(
|
|
86
|
+
"getLeftVisibleLeafColumns",
|
|
87
|
+
() => table.getLeftLeafColumns()
|
|
88
|
+
);
|
|
89
|
+
table.getRightVisibleLeafColumns = makeVisibleColumnsMethod(
|
|
90
|
+
"getRightVisibleLeafColumns",
|
|
91
|
+
() => table.getRightLeafColumns()
|
|
92
|
+
);
|
|
93
|
+
table.getCenterVisibleLeafColumns = makeVisibleColumnsMethod(
|
|
94
|
+
"getCenterVisibleLeafColumns",
|
|
95
|
+
() => table.getCenterLeafColumns()
|
|
96
|
+
);
|
|
97
|
+
table.setColumnVisibility = (updater) => {
|
|
98
|
+
var _a, _b;
|
|
99
|
+
return (_b = (_a = table.options).onColumnVisibilityChange) == null ? void 0 : _b.call(_a, updater);
|
|
100
|
+
};
|
|
101
|
+
table.resetColumnVisibility = (defaultState) => {
|
|
102
|
+
table.setColumnVisibility(
|
|
103
|
+
defaultState ? {} : table.initialState.columnVisibility ?? {}
|
|
104
|
+
);
|
|
105
|
+
};
|
|
106
|
+
table.toggleAllColumnsVisible = (value) => {
|
|
107
|
+
value = value ?? !table.getIsAllColumnsVisible();
|
|
108
|
+
table.setColumnVisibility(
|
|
109
|
+
table.getAllLeafColumns().reduce(
|
|
110
|
+
(obj, column) => {
|
|
111
|
+
var _a;
|
|
112
|
+
return {
|
|
113
|
+
...obj,
|
|
114
|
+
[column.id]: !value ? !((_a = column.getCanHide) == null ? void 0 : _a.call(column)) : value
|
|
115
|
+
};
|
|
116
|
+
},
|
|
117
|
+
{}
|
|
118
|
+
)
|
|
119
|
+
);
|
|
120
|
+
};
|
|
121
|
+
table.getIsAllColumnsVisible = () => !table.getAllLeafColumns().some((column) => {
|
|
122
|
+
var _a;
|
|
123
|
+
return !((_a = column.getIsVisible) == null ? void 0 : _a.call(column));
|
|
124
|
+
});
|
|
125
|
+
table.getIsSomeColumnsVisible = () => table.getAllLeafColumns().some((column) => {
|
|
126
|
+
var _a;
|
|
127
|
+
return (_a = column.getIsVisible) == null ? void 0 : _a.call(column);
|
|
128
|
+
});
|
|
129
|
+
table.getToggleAllColumnsVisibilityHandler = () => {
|
|
130
|
+
return (e) => {
|
|
131
|
+
var _a;
|
|
132
|
+
table.toggleAllColumnsVisible(
|
|
133
|
+
(_a = e.target) == null ? void 0 : _a.checked
|
|
134
|
+
);
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
function _getVisibleLeafColumns(table, position) {
|
|
140
|
+
return !position ? table.getVisibleLeafColumns() : position === "center" ? table.getCenterVisibleLeafColumns() : position === "left" ? table.getLeftVisibleLeafColumns() : table.getRightVisibleLeafColumns();
|
|
141
|
+
}
|
|
142
|
+
exports.ColumnVisibility = ColumnVisibility;
|
|
143
|
+
exports._getVisibleLeafColumns = _getVisibleLeafColumns;
|
|
144
|
+
//# sourceMappingURL=ColumnVisibility.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColumnVisibility.cjs","sources":["../../../src/features/ColumnVisibility.ts"],"sourcesContent":["import { ColumnPinningPosition } from '..'\nimport {\n Cell,\n Column,\n OnChangeFn,\n Table,\n Updater,\n Row,\n RowData,\n TableFeature,\n} from '../types'\nimport { getMemoOptions, makeStateUpdater, memo } from '../utils'\n\nexport type VisibilityState = Record<string, boolean>\n\nexport interface VisibilityTableState {\n columnVisibility: VisibilityState\n}\n\nexport interface VisibilityOptions {\n /**\n * Whether to enable column hiding. Defaults to `true`.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-visibility#enablehiding)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-visibility)\n */\n enableHiding?: boolean\n /**\n * If provided, this function will be called with an `updaterFn` when `state.columnVisibility` changes. This overrides the default internal state management, so you will need to persist the state change either fully or partially outside of the table.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-visibility#oncolumnvisibilitychange)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-visibility)\n */\n onColumnVisibilityChange?: OnChangeFn<VisibilityState>\n}\n\nexport type VisibilityDefaultOptions = Pick<\n VisibilityOptions,\n 'onColumnVisibilityChange'\n>\n\nexport interface VisibilityInstance<TData extends RowData> {\n /**\n * If column pinning, returns a flat array of leaf-node columns that are visible in the unpinned/center portion of the table.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-visibility#getcentervisibleleafcolumns)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-visibility)\n */\n getCenterVisibleLeafColumns: () => Column<TData, unknown>[]\n /**\n * Returns whether all columns are visible\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-visibility#getisallcolumnsvisible)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-visibility)\n */\n getIsAllColumnsVisible: () => boolean\n /**\n * Returns whether any columns are visible\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-visibility#getissomecolumnsvisible)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-visibility)\n */\n getIsSomeColumnsVisible: () => boolean\n /**\n * If column pinning, returns a flat array of leaf-node columns that are visible in the left portion of the table.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-visibility#getleftvisibleleafcolumns)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-visibility)\n */\n getLeftVisibleLeafColumns: () => Column<TData, unknown>[]\n /**\n * If column pinning, returns a flat array of leaf-node columns that are visible in the right portion of the table.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-visibility#getrightvisibleleafcolumns)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-visibility)\n */\n getRightVisibleLeafColumns: () => Column<TData, unknown>[]\n /**\n * Returns a handler for toggling the visibility of all columns, meant to be bound to a `input[type=checkbox]` element.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-visibility#gettoggleallcolumnsvisibilityhandler)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-visibility)\n */\n getToggleAllColumnsVisibilityHandler: () => (event: unknown) => void\n /**\n * Returns a flat array of columns that are visible, including parent columns.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-visibility#getvisibleflatcolumns)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-visibility)\n */\n getVisibleFlatColumns: () => Column<TData, unknown>[]\n /**\n * Returns a flat array of leaf-node columns that are visible.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-visibility#getvisibleleafcolumns)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-visibility)\n */\n getVisibleLeafColumns: () => Column<TData, unknown>[]\n /**\n * Resets the column visibility state to the initial state. If `defaultState` is provided, the state will be reset to `{}`\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-visibility#resetcolumnvisibility)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-visibility)\n */\n resetColumnVisibility: (defaultState?: boolean) => void\n /**\n * Sets or updates the `state.columnVisibility` state.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-visibility#setcolumnvisibility)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-visibility)\n */\n setColumnVisibility: (updater: Updater<VisibilityState>) => void\n /**\n * Toggles the visibility of all columns.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-visibility#toggleallcolumnsvisible)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-visibility)\n */\n toggleAllColumnsVisible: (value?: boolean) => void\n}\n\nexport interface VisibilityColumnDef {\n enableHiding?: boolean\n}\n\nexport interface VisibilityRow<TData extends RowData> {\n _getAllVisibleCells: () => Cell<TData, unknown>[]\n /**\n * Returns an array of cells that account for column visibility for the row.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-visibility#getvisiblecells)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-visibility)\n */\n getVisibleCells: () => Cell<TData, unknown>[]\n}\n\nexport interface VisibilityColumn {\n /**\n * Returns whether the column can be hidden\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-visibility#getcanhide)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-visibility)\n */\n getCanHide: () => boolean\n /**\n * Returns whether the column is visible\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-visibility#getisvisible)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-visibility)\n */\n getIsVisible: () => boolean\n /**\n * Returns a function that can be used to toggle the column visibility. This function can be used to bind to an event handler to a checkbox.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-visibility#gettogglevisibilityhandler)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-visibility)\n */\n getToggleVisibilityHandler: () => (event: unknown) => void\n /**\n * Toggles the visibility of the column.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-visibility#togglevisibility)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-visibility)\n */\n toggleVisibility: (value?: boolean) => void\n}\n\n//\n\nexport const ColumnVisibility: TableFeature = {\n getInitialState: (state): VisibilityTableState => {\n return {\n columnVisibility: {},\n ...state,\n }\n },\n\n getDefaultOptions: <TData extends RowData>(\n table: Table<TData>\n ): VisibilityDefaultOptions => {\n return {\n onColumnVisibilityChange: makeStateUpdater('columnVisibility', table),\n }\n },\n\n createColumn: <TData extends RowData, TValue>(\n column: Column<TData, TValue>,\n table: Table<TData>\n ): void => {\n column.toggleVisibility = value => {\n if (column.getCanHide()) {\n table.setColumnVisibility(old => ({\n ...old,\n [column.id]: value ?? !column.getIsVisible(),\n }))\n }\n }\n column.getIsVisible = () => {\n const childColumns = column.columns\n return (\n (childColumns.length\n ? childColumns.some(c => c.getIsVisible())\n : table.getState().columnVisibility?.[column.id]) ?? true\n )\n }\n\n column.getCanHide = () => {\n return (\n (column.columnDef.enableHiding ?? true) &&\n (table.options.enableHiding ?? true)\n )\n }\n column.getToggleVisibilityHandler = () => {\n return (e: unknown) => {\n column.toggleVisibility?.(\n ((e as MouseEvent).target as HTMLInputElement).checked\n )\n }\n }\n },\n\n createRow: <TData extends RowData>(\n row: Row<TData>,\n table: Table<TData>\n ): void => {\n row._getAllVisibleCells = memo(\n () => [row.getAllCells(), table.getState().columnVisibility],\n cells => {\n return cells.filter(cell => cell.column.getIsVisible())\n },\n getMemoOptions(table.options, 'debugRows', '_getAllVisibleCells')\n )\n row.getVisibleCells = memo(\n () => [\n row.getLeftVisibleCells(),\n row.getCenterVisibleCells(),\n row.getRightVisibleCells(),\n ],\n (left, center, right) => [...left, ...center, ...right],\n getMemoOptions(table.options, 'debugRows', 'getVisibleCells')\n )\n },\n\n createTable: <TData extends RowData>(table: Table<TData>): void => {\n const makeVisibleColumnsMethod = (\n key: string,\n getColumns: () => Column<TData, unknown>[]\n ): (() => Column<TData, unknown>[]) => {\n return memo(\n () => [\n getColumns(),\n getColumns()\n .filter(d => d.getIsVisible())\n .map(d => d.id)\n .join('_'),\n ],\n columns => {\n return columns.filter(d => d.getIsVisible?.())\n },\n getMemoOptions(table.options, 'debugColumns', key)\n )\n }\n\n table.getVisibleFlatColumns = makeVisibleColumnsMethod(\n 'getVisibleFlatColumns',\n () => table.getAllFlatColumns()\n )\n table.getVisibleLeafColumns = makeVisibleColumnsMethod(\n 'getVisibleLeafColumns',\n () => table.getAllLeafColumns()\n )\n table.getLeftVisibleLeafColumns = makeVisibleColumnsMethod(\n 'getLeftVisibleLeafColumns',\n () => table.getLeftLeafColumns()\n )\n table.getRightVisibleLeafColumns = makeVisibleColumnsMethod(\n 'getRightVisibleLeafColumns',\n () => table.getRightLeafColumns()\n )\n table.getCenterVisibleLeafColumns = makeVisibleColumnsMethod(\n 'getCenterVisibleLeafColumns',\n () => table.getCenterLeafColumns()\n )\n\n table.setColumnVisibility = updater =>\n table.options.onColumnVisibilityChange?.(updater)\n\n table.resetColumnVisibility = defaultState => {\n table.setColumnVisibility(\n defaultState ? {} : table.initialState.columnVisibility ?? {}\n )\n }\n\n table.toggleAllColumnsVisible = value => {\n value = value ?? !table.getIsAllColumnsVisible()\n\n table.setColumnVisibility(\n table.getAllLeafColumns().reduce(\n (obj, column) => ({\n ...obj,\n [column.id]: !value ? !column.getCanHide?.() : value,\n }),\n {}\n )\n )\n }\n\n table.getIsAllColumnsVisible = () =>\n !table.getAllLeafColumns().some(column => !column.getIsVisible?.())\n\n table.getIsSomeColumnsVisible = () =>\n table.getAllLeafColumns().some(column => column.getIsVisible?.())\n\n table.getToggleAllColumnsVisibilityHandler = () => {\n return (e: unknown) => {\n table.toggleAllColumnsVisible(\n ((e as MouseEvent).target as HTMLInputElement)?.checked\n )\n }\n }\n },\n}\n\nexport function _getVisibleLeafColumns<TData extends RowData>(\n table: Table<TData>,\n position?: ColumnPinningPosition | 'center'\n) {\n return !position\n ? table.getVisibleLeafColumns()\n : position === 'center'\n ? table.getCenterVisibleLeafColumns()\n : position === 'left'\n ? table.getLeftVisibleLeafColumns()\n : table.getRightVisibleLeafColumns()\n}\n"],"names":["makeStateUpdater","memo","getMemoOptions"],"mappings":";;;AAuJO,MAAM,mBAAiC;AAAA,EAC5C,iBAAiB,CAAC,UAAgC;AACzC,WAAA;AAAA,MACL,kBAAkB,CAAC;AAAA,MACnB,GAAG;AAAA,IAAA;AAAA,EAEP;AAAA,EAEA,mBAAmB,CACjB,UAC6B;AACtB,WAAA;AAAA,MACL,0BAA0BA,MAAAA,iBAAiB,oBAAoB,KAAK;AAAA,IAAA;AAAA,EAExE;AAAA,EAEA,cAAc,CACZ,QACA,UACS;AACT,WAAO,mBAAmB,CAAS,UAAA;AAC7B,UAAA,OAAO,cAAc;AACvB,cAAM,oBAAoB,CAAQ,SAAA;AAAA,UAChC,GAAG;AAAA,UACH,CAAC,OAAO,EAAE,GAAG,SAAS,CAAC,OAAO,aAAa;AAAA,QAC3C,EAAA;AAAA,MACJ;AAAA,IAAA;AAEF,WAAO,eAAe,MAAM;;AAC1B,YAAM,eAAe,OAAO;AAC5B,cACG,aAAa,SACV,aAAa,KAAK,OAAK,EAAE,aAAc,CAAA,KACvC,WAAM,WAAW,qBAAjB,mBAAoC,OAAO,QAAQ;AAAA,IAAA;AAI3D,WAAO,aAAa,MAAM;AACxB,cACG,OAAO,UAAU,gBAAgB,UACjC,MAAM,QAAQ,gBAAgB;AAAA,IAAA;AAGnC,WAAO,6BAA6B,MAAM;AACxC,aAAO,CAAC,MAAe;;AACd,qBAAA,qBAAA;AAAA;AAAA,UACH,EAAiB,OAA4B;AAAA;AAAA,MACjD;AAAA,IACF;AAAA,EAEJ;AAAA,EAEA,WAAW,CACT,KACA,UACS;AACT,QAAI,sBAAsBC,MAAA;AAAA,MACxB,MAAM,CAAC,IAAI,YAAA,GAAe,MAAM,WAAW,gBAAgB;AAAA,MAC3D,CAAS,UAAA;AACP,eAAO,MAAM,OAAO,CAAA,SAAQ,KAAK,OAAO,cAAc;AAAA,MACxD;AAAA,MACAC,MAAAA,eAAe,MAAM,SAAS,aAAa,qBAAqB;AAAA,IAAA;AAElE,QAAI,kBAAkBD,MAAA;AAAA,MACpB,MAAM;AAAA,QACJ,IAAI,oBAAoB;AAAA,QACxB,IAAI,sBAAsB;AAAA,QAC1B,IAAI,qBAAqB;AAAA,MAC3B;AAAA,MACA,CAAC,MAAM,QAAQ,UAAU,CAAC,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK;AAAA,MACtDC,MAAAA,eAAe,MAAM,SAAS,aAAa,iBAAiB;AAAA,IAAA;AAAA,EAEhE;AAAA,EAEA,aAAa,CAAwB,UAA8B;AAC3D,UAAA,2BAA2B,CAC/B,KACA,eACqC;AAC9B,aAAAD,MAAA;AAAA,QACL,MAAM;AAAA,UACJ,WAAW;AAAA,UACX,WAAW,EACR,OAAO,CAAA,MAAK,EAAE,aAAc,CAAA,EAC5B,IAAI,CAAK,MAAA,EAAE,EAAE,EACb,KAAK,GAAG;AAAA,QACb;AAAA,QACA,CAAW,YAAA;AACT,iBAAO,QAAQ,OAAO,CAAK,MAAA;;AAAA,2BAAE,iBAAF;AAAA,WAAkB;AAAA,QAC/C;AAAA,QACAC,MAAAA,eAAe,MAAM,SAAS,gBAAgB,GAAG;AAAA,MAAA;AAAA,IACnD;AAGF,UAAM,wBAAwB;AAAA,MAC5B;AAAA,MACA,MAAM,MAAM,kBAAkB;AAAA,IAAA;AAEhC,UAAM,wBAAwB;AAAA,MAC5B;AAAA,MACA,MAAM,MAAM,kBAAkB;AAAA,IAAA;AAEhC,UAAM,4BAA4B;AAAA,MAChC;AAAA,MACA,MAAM,MAAM,mBAAmB;AAAA,IAAA;AAEjC,UAAM,6BAA6B;AAAA,MACjC;AAAA,MACA,MAAM,MAAM,oBAAoB;AAAA,IAAA;AAElC,UAAM,8BAA8B;AAAA,MAClC;AAAA,MACA,MAAM,MAAM,qBAAqB;AAAA,IAAA;AAGnC,UAAM,sBAAsB,CAAA,YAAA;;AAC1B,+BAAM,SAAQ,6BAAd,4BAAyC;AAAA;AAE3C,UAAM,wBAAwB,CAAgB,iBAAA;AACtC,YAAA;AAAA,QACJ,eAAe,CAAA,IAAK,MAAM,aAAa,oBAAoB,CAAC;AAAA,MAAA;AAAA,IAC9D;AAGF,UAAM,0BAA0B,CAAS,UAAA;AAC/B,cAAA,SAAS,CAAC,MAAM,uBAAuB;AAEzC,YAAA;AAAA,QACJ,MAAM,oBAAoB;AAAA,UACxB,CAAC,KAAK,WAAY;;AAAA;AAAA,cAChB,GAAG;AAAA,cACH,CAAC,OAAO,EAAE,GAAG,CAAC,QAAQ,GAAC,YAAO,eAAP,mCAAwB;AAAA,YAAA;AAAA;AAAA,UAEjD,CAAC;AAAA,QACH;AAAA,MAAA;AAAA,IACF;AAGI,UAAA,yBAAyB,MAC7B,CAAC,MAAM,kBAAoB,EAAA,KAAK,CAAU,WAAA;;AAAA,gBAAC,YAAO,iBAAP;AAAA,KAAuB;AAE9D,UAAA,0BAA0B,MAC9B,MAAM,oBAAoB,KAAK,CAAA,WAAU;;AAAA,0BAAO,iBAAP;AAAA,KAAuB;AAElE,UAAM,uCAAuC,MAAM;AACjD,aAAO,CAAC,MAAe;;AACf,cAAA;AAAA,WACF,OAAiB,WAAjB,mBAA8C;AAAA,QAAA;AAAA,MAClD;AAAA,IACF;AAAA,EAEJ;AACF;AAEgB,SAAA,uBACd,OACA,UACA;AACA,SAAO,CAAC,WACJ,MAAM,sBAAsB,IAC5B,aAAa,WACX,MAAM,4BAA4B,IAClC,aAAa,SACX,MAAM,0BAA0B,IAChC,MAAM;AAChB;;;"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { ColumnPinningPosition } from '..';
|
|
2
|
+
import { Cell, Column, OnChangeFn, Table, Updater, RowData, TableFeature } from '../types';
|
|
3
|
+
|
|
4
|
+
export type VisibilityState = Record<string, boolean>;
|
|
5
|
+
export interface VisibilityTableState {
|
|
6
|
+
columnVisibility: VisibilityState;
|
|
7
|
+
}
|
|
8
|
+
export interface VisibilityOptions {
|
|
9
|
+
/**
|
|
10
|
+
* Whether to enable column hiding. Defaults to `true`.
|
|
11
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-visibility#enablehiding)
|
|
12
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-visibility)
|
|
13
|
+
*/
|
|
14
|
+
enableHiding?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* If provided, this function will be called with an `updaterFn` when `state.columnVisibility` changes. This overrides the default internal state management, so you will need to persist the state change either fully or partially outside of the table.
|
|
17
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-visibility#oncolumnvisibilitychange)
|
|
18
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-visibility)
|
|
19
|
+
*/
|
|
20
|
+
onColumnVisibilityChange?: OnChangeFn<VisibilityState>;
|
|
21
|
+
}
|
|
22
|
+
export type VisibilityDefaultOptions = Pick<VisibilityOptions, 'onColumnVisibilityChange'>;
|
|
23
|
+
export interface VisibilityInstance<TData extends RowData> {
|
|
24
|
+
/**
|
|
25
|
+
* If column pinning, returns a flat array of leaf-node columns that are visible in the unpinned/center portion of the table.
|
|
26
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-visibility#getcentervisibleleafcolumns)
|
|
27
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-visibility)
|
|
28
|
+
*/
|
|
29
|
+
getCenterVisibleLeafColumns: () => Column<TData, unknown>[];
|
|
30
|
+
/**
|
|
31
|
+
* Returns whether all columns are visible
|
|
32
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-visibility#getisallcolumnsvisible)
|
|
33
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-visibility)
|
|
34
|
+
*/
|
|
35
|
+
getIsAllColumnsVisible: () => boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Returns whether any columns are visible
|
|
38
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-visibility#getissomecolumnsvisible)
|
|
39
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-visibility)
|
|
40
|
+
*/
|
|
41
|
+
getIsSomeColumnsVisible: () => boolean;
|
|
42
|
+
/**
|
|
43
|
+
* If column pinning, returns a flat array of leaf-node columns that are visible in the left portion of the table.
|
|
44
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-visibility#getleftvisibleleafcolumns)
|
|
45
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-visibility)
|
|
46
|
+
*/
|
|
47
|
+
getLeftVisibleLeafColumns: () => Column<TData, unknown>[];
|
|
48
|
+
/**
|
|
49
|
+
* If column pinning, returns a flat array of leaf-node columns that are visible in the right portion of the table.
|
|
50
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-visibility#getrightvisibleleafcolumns)
|
|
51
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-visibility)
|
|
52
|
+
*/
|
|
53
|
+
getRightVisibleLeafColumns: () => Column<TData, unknown>[];
|
|
54
|
+
/**
|
|
55
|
+
* Returns a handler for toggling the visibility of all columns, meant to be bound to a `input[type=checkbox]` element.
|
|
56
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-visibility#gettoggleallcolumnsvisibilityhandler)
|
|
57
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-visibility)
|
|
58
|
+
*/
|
|
59
|
+
getToggleAllColumnsVisibilityHandler: () => (event: unknown) => void;
|
|
60
|
+
/**
|
|
61
|
+
* Returns a flat array of columns that are visible, including parent columns.
|
|
62
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-visibility#getvisibleflatcolumns)
|
|
63
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-visibility)
|
|
64
|
+
*/
|
|
65
|
+
getVisibleFlatColumns: () => Column<TData, unknown>[];
|
|
66
|
+
/**
|
|
67
|
+
* Returns a flat array of leaf-node columns that are visible.
|
|
68
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-visibility#getvisibleleafcolumns)
|
|
69
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-visibility)
|
|
70
|
+
*/
|
|
71
|
+
getVisibleLeafColumns: () => Column<TData, unknown>[];
|
|
72
|
+
/**
|
|
73
|
+
* Resets the column visibility state to the initial state. If `defaultState` is provided, the state will be reset to `{}`
|
|
74
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-visibility#resetcolumnvisibility)
|
|
75
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-visibility)
|
|
76
|
+
*/
|
|
77
|
+
resetColumnVisibility: (defaultState?: boolean) => void;
|
|
78
|
+
/**
|
|
79
|
+
* Sets or updates the `state.columnVisibility` state.
|
|
80
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-visibility#setcolumnvisibility)
|
|
81
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-visibility)
|
|
82
|
+
*/
|
|
83
|
+
setColumnVisibility: (updater: Updater<VisibilityState>) => void;
|
|
84
|
+
/**
|
|
85
|
+
* Toggles the visibility of all columns.
|
|
86
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-visibility#toggleallcolumnsvisible)
|
|
87
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-visibility)
|
|
88
|
+
*/
|
|
89
|
+
toggleAllColumnsVisible: (value?: boolean) => void;
|
|
90
|
+
}
|
|
91
|
+
export interface VisibilityColumnDef {
|
|
92
|
+
enableHiding?: boolean;
|
|
93
|
+
}
|
|
94
|
+
export interface VisibilityRow<TData extends RowData> {
|
|
95
|
+
_getAllVisibleCells: () => Cell<TData, unknown>[];
|
|
96
|
+
/**
|
|
97
|
+
* Returns an array of cells that account for column visibility for the row.
|
|
98
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-visibility#getvisiblecells)
|
|
99
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-visibility)
|
|
100
|
+
*/
|
|
101
|
+
getVisibleCells: () => Cell<TData, unknown>[];
|
|
102
|
+
}
|
|
103
|
+
export interface VisibilityColumn {
|
|
104
|
+
/**
|
|
105
|
+
* Returns whether the column can be hidden
|
|
106
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-visibility#getcanhide)
|
|
107
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-visibility)
|
|
108
|
+
*/
|
|
109
|
+
getCanHide: () => boolean;
|
|
110
|
+
/**
|
|
111
|
+
* Returns whether the column is visible
|
|
112
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-visibility#getisvisible)
|
|
113
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-visibility)
|
|
114
|
+
*/
|
|
115
|
+
getIsVisible: () => boolean;
|
|
116
|
+
/**
|
|
117
|
+
* Returns a function that can be used to toggle the column visibility. This function can be used to bind to an event handler to a checkbox.
|
|
118
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-visibility#gettogglevisibilityhandler)
|
|
119
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-visibility)
|
|
120
|
+
*/
|
|
121
|
+
getToggleVisibilityHandler: () => (event: unknown) => void;
|
|
122
|
+
/**
|
|
123
|
+
* Toggles the visibility of the column.
|
|
124
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-visibility#togglevisibility)
|
|
125
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-visibility)
|
|
126
|
+
*/
|
|
127
|
+
toggleVisibility: (value?: boolean) => void;
|
|
128
|
+
}
|
|
129
|
+
export declare const ColumnVisibility: TableFeature;
|
|
130
|
+
export declare function _getVisibleLeafColumns<TData extends RowData>(table: Table<TData>, position?: ColumnPinningPosition | 'center'): Column<TData, unknown>[];
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const GlobalFaceting = {
|
|
4
|
+
createTable: (table) => {
|
|
5
|
+
table._getGlobalFacetedRowModel = table.options.getFacetedRowModel && table.options.getFacetedRowModel(table, "__global__");
|
|
6
|
+
table.getGlobalFacetedRowModel = () => {
|
|
7
|
+
if (table.options.manualFiltering || !table._getGlobalFacetedRowModel) {
|
|
8
|
+
return table.getPreFilteredRowModel();
|
|
9
|
+
}
|
|
10
|
+
return table._getGlobalFacetedRowModel();
|
|
11
|
+
};
|
|
12
|
+
table._getGlobalFacetedUniqueValues = table.options.getFacetedUniqueValues && table.options.getFacetedUniqueValues(table, "__global__");
|
|
13
|
+
table.getGlobalFacetedUniqueValues = () => {
|
|
14
|
+
if (!table._getGlobalFacetedUniqueValues) {
|
|
15
|
+
return /* @__PURE__ */ new Map();
|
|
16
|
+
}
|
|
17
|
+
return table._getGlobalFacetedUniqueValues();
|
|
18
|
+
};
|
|
19
|
+
table._getGlobalFacetedMinMaxValues = table.options.getFacetedMinMaxValues && table.options.getFacetedMinMaxValues(table, "__global__");
|
|
20
|
+
table.getGlobalFacetedMinMaxValues = () => {
|
|
21
|
+
if (!table._getGlobalFacetedMinMaxValues) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
return table._getGlobalFacetedMinMaxValues();
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
exports.GlobalFaceting = GlobalFaceting;
|
|
29
|
+
//# sourceMappingURL=GlobalFaceting.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GlobalFaceting.cjs","sources":["../../../src/features/GlobalFaceting.ts"],"sourcesContent":["import { RowModel } from '..'\nimport { Table, RowData, TableFeature } from '../types'\n\nexport interface GlobalFacetingInstance<TData extends RowData> {\n _getGlobalFacetedMinMaxValues?: () => undefined | [number, number]\n _getGlobalFacetedRowModel?: () => RowModel<TData>\n _getGlobalFacetedUniqueValues?: () => Map<any, number>\n /**\n * Currently, this function returns the built-in `includesString` filter function. In future releases, it may return more dynamic filter functions based on the nature of the data provided.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/global-faceting#getglobalautofilterfn)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/global-faceting)\n */\n getGlobalFacetedMinMaxValues: () => undefined | [number, number]\n /**\n * Returns the row model for the table after **global** filtering has been applied.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/global-faceting#getglobalfacetedrowmodel)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/global-faceting)\n */\n getGlobalFacetedRowModel: () => RowModel<TData>\n /**\n * Returns the faceted unique values for the global filter.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/global-faceting#getglobalfaceteduniquevalues)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/global-faceting)\n */\n getGlobalFacetedUniqueValues: () => Map<any, number>\n}\n\n//\n\nexport const GlobalFaceting: TableFeature = {\n createTable: <TData extends RowData>(table: Table<TData>): void => {\n table._getGlobalFacetedRowModel =\n table.options.getFacetedRowModel &&\n table.options.getFacetedRowModel(table, '__global__')\n\n table.getGlobalFacetedRowModel = () => {\n if (table.options.manualFiltering || !table._getGlobalFacetedRowModel) {\n return table.getPreFilteredRowModel()\n }\n\n return table._getGlobalFacetedRowModel()\n }\n\n table._getGlobalFacetedUniqueValues =\n table.options.getFacetedUniqueValues &&\n table.options.getFacetedUniqueValues(table, '__global__')\n table.getGlobalFacetedUniqueValues = () => {\n if (!table._getGlobalFacetedUniqueValues) {\n return new Map()\n }\n\n return table._getGlobalFacetedUniqueValues()\n }\n\n table._getGlobalFacetedMinMaxValues =\n table.options.getFacetedMinMaxValues &&\n table.options.getFacetedMinMaxValues(table, '__global__')\n table.getGlobalFacetedMinMaxValues = () => {\n if (!table._getGlobalFacetedMinMaxValues) {\n return\n }\n\n return table._getGlobalFacetedMinMaxValues()\n }\n },\n}\n"],"names":[],"mappings":";;AA6BO,MAAM,iBAA+B;AAAA,EAC1C,aAAa,CAAwB,UAA8B;AAC3D,UAAA,4BACJ,MAAM,QAAQ,sBACd,MAAM,QAAQ,mBAAmB,OAAO,YAAY;AAEtD,UAAM,2BAA2B,MAAM;AACrC,UAAI,MAAM,QAAQ,mBAAmB,CAAC,MAAM,2BAA2B;AACrE,eAAO,MAAM;MACf;AAEA,aAAO,MAAM;IAA0B;AAGnC,UAAA,gCACJ,MAAM,QAAQ,0BACd,MAAM,QAAQ,uBAAuB,OAAO,YAAY;AAC1D,UAAM,+BAA+B,MAAM;AACrC,UAAA,CAAC,MAAM,+BAA+B;AACxC,mCAAW,IAAI;AAAA,MACjB;AAEA,aAAO,MAAM;IAA8B;AAGvC,UAAA,gCACJ,MAAM,QAAQ,0BACd,MAAM,QAAQ,uBAAuB,OAAO,YAAY;AAC1D,UAAM,+BAA+B,MAAM;AACrC,UAAA,CAAC,MAAM,+BAA+B;AACxC;AAAA,MACF;AAEA,aAAO,MAAM;IAA8B;AAAA,EAE/C;AACF;;"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { RowModel } from '..';
|
|
2
|
+
import { RowData, TableFeature } from '../types';
|
|
3
|
+
|
|
4
|
+
export interface GlobalFacetingInstance<TData extends RowData> {
|
|
5
|
+
_getGlobalFacetedMinMaxValues?: () => undefined | [number, number];
|
|
6
|
+
_getGlobalFacetedRowModel?: () => RowModel<TData>;
|
|
7
|
+
_getGlobalFacetedUniqueValues?: () => Map<any, number>;
|
|
8
|
+
/**
|
|
9
|
+
* Currently, this function returns the built-in `includesString` filter function. In future releases, it may return more dynamic filter functions based on the nature of the data provided.
|
|
10
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/global-faceting#getglobalautofilterfn)
|
|
11
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/global-faceting)
|
|
12
|
+
*/
|
|
13
|
+
getGlobalFacetedMinMaxValues: () => undefined | [number, number];
|
|
14
|
+
/**
|
|
15
|
+
* Returns the row model for the table after **global** filtering has been applied.
|
|
16
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/global-faceting#getglobalfacetedrowmodel)
|
|
17
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/global-faceting)
|
|
18
|
+
*/
|
|
19
|
+
getGlobalFacetedRowModel: () => RowModel<TData>;
|
|
20
|
+
/**
|
|
21
|
+
* Returns the faceted unique values for the global filter.
|
|
22
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/global-faceting#getglobalfaceteduniquevalues)
|
|
23
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/global-faceting)
|
|
24
|
+
*/
|
|
25
|
+
getGlobalFacetedUniqueValues: () => Map<any, number>;
|
|
26
|
+
}
|
|
27
|
+
export declare const GlobalFaceting: TableFeature;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const filterFns = require("../filterFns.cjs");
|
|
4
|
+
const utils = require("../utils.cjs");
|
|
5
|
+
const GlobalFiltering = {
|
|
6
|
+
getInitialState: (state) => {
|
|
7
|
+
return {
|
|
8
|
+
globalFilter: void 0,
|
|
9
|
+
...state
|
|
10
|
+
};
|
|
11
|
+
},
|
|
12
|
+
getDefaultOptions: (table) => {
|
|
13
|
+
return {
|
|
14
|
+
onGlobalFilterChange: utils.makeStateUpdater("globalFilter", table),
|
|
15
|
+
globalFilterFn: "auto",
|
|
16
|
+
getColumnCanGlobalFilter: (column) => {
|
|
17
|
+
var _a, _b;
|
|
18
|
+
const value = (_b = (_a = table.getCoreRowModel().flatRows[0]) == null ? void 0 : _a._getAllCellsByColumnId()[column.id]) == null ? void 0 : _b.getValue();
|
|
19
|
+
return typeof value === "string" || typeof value === "number";
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
},
|
|
23
|
+
createColumn: (column, table) => {
|
|
24
|
+
column.getCanGlobalFilter = () => {
|
|
25
|
+
var _a, _b;
|
|
26
|
+
return (column.columnDef.enableGlobalFilter ?? true) && (table.options.enableGlobalFilter ?? true) && (table.options.enableFilters ?? true) && (((_b = (_a = table.options).getColumnCanGlobalFilter) == null ? void 0 : _b.call(_a, column)) ?? true) && !!column.accessorFn;
|
|
27
|
+
};
|
|
28
|
+
},
|
|
29
|
+
createTable: (table) => {
|
|
30
|
+
table.getGlobalAutoFilterFn = () => {
|
|
31
|
+
return filterFns.filterFns.includesString;
|
|
32
|
+
};
|
|
33
|
+
table.getGlobalFilterFn = () => {
|
|
34
|
+
var _a;
|
|
35
|
+
const { globalFilterFn } = table.options;
|
|
36
|
+
return utils.isFunction(globalFilterFn) ? globalFilterFn : globalFilterFn === "auto" ? table.getGlobalAutoFilterFn() : ((_a = table.options.filterFns) == null ? void 0 : _a[globalFilterFn]) ?? filterFns.filterFns[globalFilterFn];
|
|
37
|
+
};
|
|
38
|
+
table.setGlobalFilter = (updater) => {
|
|
39
|
+
var _a, _b;
|
|
40
|
+
(_b = (_a = table.options).onGlobalFilterChange) == null ? void 0 : _b.call(_a, updater);
|
|
41
|
+
};
|
|
42
|
+
table.resetGlobalFilter = (defaultState) => {
|
|
43
|
+
table.setGlobalFilter(
|
|
44
|
+
defaultState ? void 0 : table.initialState.globalFilter
|
|
45
|
+
);
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
exports.GlobalFiltering = GlobalFiltering;
|
|
50
|
+
//# sourceMappingURL=GlobalFiltering.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GlobalFiltering.cjs","sources":["../../../src/features/GlobalFiltering.ts"],"sourcesContent":["import { FilterFn, FilterFnOption } from '..'\nimport { BuiltInFilterFn, filterFns } from '../filterFns'\nimport {\n Column,\n OnChangeFn,\n Table,\n Updater,\n RowData,\n TableFeature,\n} from '../types'\nimport { isFunction, makeStateUpdater } from '../utils'\n\nexport interface GlobalFilterTableState {\n globalFilter: any\n}\n\nexport interface GlobalFilterColumnDef {\n /**\n * Enables/disables the **global** filter for this column.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/global-filtering#enableglobalfilter)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/global-filtering)\n */\n enableGlobalFilter?: boolean\n}\n\nexport interface GlobalFilterColumn {\n /**\n * Returns whether or not the column can be **globally** filtered. Set to `false` to disable a column from being scanned during global filtering.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/global-filtering#getcanglobalfilter)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/global-filtering)\n */\n getCanGlobalFilter: () => boolean\n}\n\nexport interface GlobalFilterOptions<TData extends RowData> {\n /**\n * Enables/disables **global** filtering for all columns.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/global-filtering#enableglobalfilter)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/global-filtering)\n */\n enableGlobalFilter?: boolean\n /**\n * If provided, this function will be called with the column and should return `true` or `false` to indicate whether this column should be used for global filtering.\n *\n * This is useful if the column can contain data that is not `string` or `number` (i.e. `undefined`).\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/global-filtering#getcolumncanglobalfilter)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/global-filtering)\n */\n getColumnCanGlobalFilter?: (column: Column<TData, unknown>) => boolean\n /**\n * The filter function to use for global filtering.\n * - A `string` referencing a built-in filter function\n * - A `string` that references a custom filter functions provided via the `tableOptions.filterFns` option\n * - A custom filter function\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/global-filtering#globalfilterfn)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/global-filtering)\n */\n globalFilterFn?: FilterFnOption<TData>\n /**\n * If provided, this function will be called with an `updaterFn` when `state.globalFilter` changes. This overrides the default internal state management, so you will need to persist the state change either fully or partially outside of the table.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/global-filtering#onglobalfilterchange)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/global-filtering)\n */\n onGlobalFilterChange?: OnChangeFn<any>\n}\n\nexport interface GlobalFilterInstance<TData extends RowData> {\n /**\n * Currently, this function returns the built-in `includesString` filter function. In future releases, it may return more dynamic filter functions based on the nature of the data provided.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/global-filtering#getglobalautofilterfn)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/global-filtering)\n */\n getGlobalAutoFilterFn: () => FilterFn<TData> | undefined\n /**\n * Returns the filter function (either user-defined or automatic, depending on configuration) for the global filter.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/global-filtering#getglobalfilterfn)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/global-filtering)\n */\n getGlobalFilterFn: () => FilterFn<TData> | undefined\n /**\n * Resets the **globalFilter** state to `initialState.globalFilter`, or `true` can be passed to force a default blank state reset to `undefined`.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/global-filtering#resetglobalfilter)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/global-filtering)\n */\n resetGlobalFilter: (defaultState?: boolean) => void\n /**\n * Sets or updates the `state.globalFilter` state.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/global-filtering#setglobalfilter)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/global-filtering)\n */\n setGlobalFilter: (updater: Updater<any>) => void\n}\n\n//\n\nexport const GlobalFiltering: TableFeature = {\n getInitialState: (state): GlobalFilterTableState => {\n return {\n globalFilter: undefined,\n ...state,\n }\n },\n\n getDefaultOptions: <TData extends RowData>(\n table: Table<TData>\n ): GlobalFilterOptions<TData> => {\n return {\n onGlobalFilterChange: makeStateUpdater('globalFilter', table),\n globalFilterFn: 'auto',\n getColumnCanGlobalFilter: column => {\n const value = table\n .getCoreRowModel()\n .flatRows[0]?._getAllCellsByColumnId()\n [column.id]?.getValue()\n\n return typeof value === 'string' || typeof value === 'number'\n },\n } as GlobalFilterOptions<TData>\n },\n\n createColumn: <TData extends RowData>(\n column: Column<TData, unknown>,\n table: Table<TData>\n ): void => {\n column.getCanGlobalFilter = () => {\n return (\n (column.columnDef.enableGlobalFilter ?? true) &&\n (table.options.enableGlobalFilter ?? true) &&\n (table.options.enableFilters ?? true) &&\n (table.options.getColumnCanGlobalFilter?.(column) ?? true) &&\n !!column.accessorFn\n )\n }\n },\n\n createTable: <TData extends RowData>(table: Table<TData>): void => {\n table.getGlobalAutoFilterFn = () => {\n return filterFns.includesString\n }\n\n table.getGlobalFilterFn = () => {\n const { globalFilterFn: globalFilterFn } = table.options\n\n return isFunction(globalFilterFn)\n ? globalFilterFn\n : globalFilterFn === 'auto'\n ? table.getGlobalAutoFilterFn()\n : table.options.filterFns?.[globalFilterFn as string] ??\n filterFns[globalFilterFn as BuiltInFilterFn]\n }\n\n table.setGlobalFilter = updater => {\n table.options.onGlobalFilterChange?.(updater)\n }\n\n table.resetGlobalFilter = defaultState => {\n table.setGlobalFilter(\n defaultState ? undefined : table.initialState.globalFilter\n )\n }\n },\n}\n"],"names":["makeStateUpdater","filterFns","isFunction"],"mappings":";;;;AA+FO,MAAM,kBAAgC;AAAA,EAC3C,iBAAiB,CAAC,UAAkC;AAC3C,WAAA;AAAA,MACL,cAAc;AAAA,MACd,GAAG;AAAA,IAAA;AAAA,EAEP;AAAA,EAEA,mBAAmB,CACjB,UAC+B;AACxB,WAAA;AAAA,MACL,sBAAsBA,MAAAA,iBAAiB,gBAAgB,KAAK;AAAA,MAC5D,gBAAgB;AAAA,MAChB,0BAA0B,CAAU,WAAA;;AAClC,cAAM,SAAQ,iBACX,gBAAgB,EAChB,SAAS,CAAC,MAFC,mBAEE,yBACb,OAAO,QAHI,mBAGC;AAEf,eAAO,OAAO,UAAU,YAAY,OAAO,UAAU;AAAA,MACvD;AAAA,IAAA;AAAA,EAEJ;AAAA,EAEA,cAAc,CACZ,QACA,UACS;AACT,WAAO,qBAAqB,MAAM;;AAE7B,cAAA,OAAO,UAAU,sBAAsB,UACvC,MAAM,QAAQ,sBAAsB,UACpC,MAAM,QAAQ,iBAAiB,YAC/B,iBAAM,SAAQ,6BAAd,4BAAyC,YAAW,SACrD,CAAC,CAAC,OAAO;AAAA,IAAA;AAAA,EAGf;AAAA,EAEA,aAAa,CAAwB,UAA8B;AACjE,UAAM,wBAAwB,MAAM;AAClC,aAAOC,UAAAA,UAAU;AAAA,IAAA;AAGnB,UAAM,oBAAoB,MAAM;;AACxB,YAAA,EAAE,eAA+B,IAAI,MAAM;AAEjD,aAAOC,MAAAA,WAAW,cAAc,IAC5B,iBACA,mBAAmB,SACjB,MAAM,sBAAsB,MAC5B,WAAM,QAAQ,cAAd,mBAA0B,oBAC1BD,UAAAA,UAAU,cAAiC;AAAA,IAAA;AAGnD,UAAM,kBAAkB,CAAW,YAAA;;AAC3B,wBAAA,SAAQ,yBAAR,4BAA+B;AAAA,IAAO;AAG9C,UAAM,oBAAoB,CAAgB,iBAAA;AAClC,YAAA;AAAA,QACJ,eAAe,SAAY,MAAM,aAAa;AAAA,MAAA;AAAA,IAChD;AAAA,EAEJ;AACF;;"}
|