@tanstack/table-core 9.0.0-alpha.34 → 9.0.0-alpha.37
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/core/columns/constructColumn.cjs.map +1 -1
- package/dist/core/columns/constructColumn.js.map +1 -1
- package/dist/core/columns/coreColumnsFeature.utils.cjs.map +1 -1
- package/dist/core/columns/coreColumnsFeature.utils.js.map +1 -1
- package/dist/core/headers/buildHeaderGroups.cjs.map +1 -1
- package/dist/core/headers/buildHeaderGroups.js.map +1 -1
- package/dist/core/headers/coreHeadersFeature.utils.cjs.map +1 -1
- package/dist/core/headers/coreHeadersFeature.utils.js.map +1 -1
- package/dist/core/row-models/createCoreRowModel.cjs.map +1 -1
- package/dist/core/row-models/createCoreRowModel.js.map +1 -1
- package/dist/core/rows/constructRow.cjs.map +1 -1
- package/dist/core/rows/constructRow.js.map +1 -1
- package/dist/core/table/constructTable.cjs +2 -1
- package/dist/core/table/constructTable.cjs.map +1 -1
- package/dist/core/table/constructTable.js +2 -1
- package/dist/core/table/constructTable.js.map +1 -1
- package/dist/core/table/coreTablesFeature.utils.cjs +1 -1
- package/dist/core/table/coreTablesFeature.utils.cjs.map +1 -1
- package/dist/core/table/coreTablesFeature.utils.js +2 -2
- package/dist/core/table/coreTablesFeature.utils.js.map +1 -1
- package/dist/features/column-faceting/createFacetedMinMaxValues.cjs.map +1 -1
- package/dist/features/column-faceting/createFacetedMinMaxValues.js.map +1 -1
- package/dist/features/column-faceting/createFacetedRowModel.cjs.map +1 -1
- package/dist/features/column-faceting/createFacetedRowModel.js.map +1 -1
- package/dist/features/column-faceting/createFacetedUniqueValues.cjs.map +1 -1
- package/dist/features/column-faceting/createFacetedUniqueValues.js.map +1 -1
- package/dist/features/column-filtering/columnFilteringFeature.utils.cjs +2 -2
- package/dist/features/column-filtering/columnFilteringFeature.utils.cjs.map +1 -1
- package/dist/features/column-filtering/columnFilteringFeature.utils.js +3 -3
- package/dist/features/column-filtering/columnFilteringFeature.utils.js.map +1 -1
- package/dist/features/column-filtering/createFilteredRowModel.cjs.map +1 -1
- package/dist/features/column-filtering/createFilteredRowModel.js.map +1 -1
- package/dist/features/column-filtering/filterRowsUtils.cjs.map +1 -1
- package/dist/features/column-filtering/filterRowsUtils.js.map +1 -1
- package/dist/features/column-grouping/columnGroupingFeature.utils.cjs +2 -2
- package/dist/features/column-grouping/columnGroupingFeature.utils.cjs.map +1 -1
- package/dist/features/column-grouping/columnGroupingFeature.utils.js +3 -3
- package/dist/features/column-grouping/columnGroupingFeature.utils.js.map +1 -1
- package/dist/features/column-grouping/createGroupedRowModel.cjs.map +1 -1
- package/dist/features/column-grouping/createGroupedRowModel.js.map +1 -1
- package/dist/features/column-ordering/columnOrderingFeature.utils.cjs +3 -2
- package/dist/features/column-ordering/columnOrderingFeature.utils.cjs.map +1 -1
- package/dist/features/column-ordering/columnOrderingFeature.utils.js +3 -2
- package/dist/features/column-ordering/columnOrderingFeature.utils.js.map +1 -1
- package/dist/features/column-pinning/columnPinningFeature.utils.cjs +3 -3
- package/dist/features/column-pinning/columnPinningFeature.utils.cjs.map +1 -1
- package/dist/features/column-pinning/columnPinningFeature.utils.js +4 -4
- package/dist/features/column-pinning/columnPinningFeature.utils.js.map +1 -1
- package/dist/features/column-resizing/columnResizingFeature.utils.cjs +4 -3
- package/dist/features/column-resizing/columnResizingFeature.utils.cjs.map +1 -1
- package/dist/features/column-resizing/columnResizingFeature.utils.js +4 -3
- package/dist/features/column-resizing/columnResizingFeature.utils.js.map +1 -1
- package/dist/features/column-sizing/columnSizingFeature.utils.cjs +4 -4
- package/dist/features/column-sizing/columnSizingFeature.utils.cjs.map +1 -1
- package/dist/features/column-sizing/columnSizingFeature.utils.js +5 -5
- package/dist/features/column-sizing/columnSizingFeature.utils.js.map +1 -1
- package/dist/features/column-visibility/columnVisibilityFeature.utils.cjs +2 -2
- package/dist/features/column-visibility/columnVisibilityFeature.utils.cjs.map +1 -1
- package/dist/features/column-visibility/columnVisibilityFeature.utils.js +3 -3
- package/dist/features/column-visibility/columnVisibilityFeature.utils.js.map +1 -1
- package/dist/features/global-filtering/globalFilteringFeature.utils.cjs +1 -1
- package/dist/features/global-filtering/globalFilteringFeature.utils.cjs.map +1 -1
- package/dist/features/global-filtering/globalFilteringFeature.utils.js +2 -2
- package/dist/features/global-filtering/globalFilteringFeature.utils.js.map +1 -1
- package/dist/features/row-expanding/createExpandedRowModel.cjs.map +1 -1
- package/dist/features/row-expanding/createExpandedRowModel.js.map +1 -1
- package/dist/features/row-expanding/rowExpandingFeature.utils.cjs +3 -2
- package/dist/features/row-expanding/rowExpandingFeature.utils.cjs.map +1 -1
- package/dist/features/row-expanding/rowExpandingFeature.utils.js +4 -2
- package/dist/features/row-expanding/rowExpandingFeature.utils.js.map +1 -1
- package/dist/features/row-pagination/createPaginatedRowModel.cjs.map +1 -1
- package/dist/features/row-pagination/createPaginatedRowModel.js.map +1 -1
- package/dist/features/row-pagination/rowPaginationFeature.utils.cjs +19 -13
- package/dist/features/row-pagination/rowPaginationFeature.utils.cjs.map +1 -1
- package/dist/features/row-pagination/rowPaginationFeature.utils.js +20 -14
- package/dist/features/row-pagination/rowPaginationFeature.utils.js.map +1 -1
- package/dist/features/row-pinning/rowPinningFeature.utils.cjs +3 -3
- package/dist/features/row-pinning/rowPinningFeature.utils.cjs.map +1 -1
- package/dist/features/row-pinning/rowPinningFeature.utils.js +4 -4
- package/dist/features/row-pinning/rowPinningFeature.utils.js.map +1 -1
- package/dist/features/row-selection/rowSelectionFeature.utils.cjs +3 -2
- package/dist/features/row-selection/rowSelectionFeature.utils.cjs.map +1 -1
- package/dist/features/row-selection/rowSelectionFeature.utils.js +4 -2
- package/dist/features/row-selection/rowSelectionFeature.utils.js.map +1 -1
- package/dist/features/row-sorting/createSortedRowModel.cjs.map +1 -1
- package/dist/features/row-sorting/createSortedRowModel.js.map +1 -1
- package/dist/features/row-sorting/rowSortingFeature.utils.cjs +2 -2
- package/dist/features/row-sorting/rowSortingFeature.utils.cjs.map +1 -1
- package/dist/features/row-sorting/rowSortingFeature.utils.js +3 -3
- package/dist/features/row-sorting/rowSortingFeature.utils.js.map +1 -1
- package/dist/flex-render.cjs +19 -0
- package/dist/flex-render.cjs.map +1 -0
- package/dist/flex-render.d.cts +24 -0
- package/dist/flex-render.d.ts +24 -0
- package/dist/flex-render.js +16 -0
- package/dist/flex-render.js.map +1 -0
- package/dist/fns/filterFns.cjs.map +1 -1
- package/dist/fns/filterFns.js.map +1 -1
- package/dist/index.cjs +1 -2
- package/dist/index.d.cts +2 -3
- package/dist/index.d.ts +2 -3
- package/dist/index.js +2 -3
- package/dist/utils.cjs +12 -0
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +2 -1
- package/dist/utils.d.ts +2 -1
- package/dist/utils.js +12 -1
- package/dist/utils.js.map +1 -1
- package/package.json +5 -1
- package/src/core/columns/coreColumnsFeature.utils.ts +1 -1
- package/src/core/row-models/createCoreRowModel.ts +1 -1
- package/src/core/rows/constructRow.ts +1 -1
- package/src/core/table/constructTable.ts +4 -5
- package/src/core/table/coreTablesFeature.utils.ts +2 -2
- package/src/features/column-faceting/createFacetedMinMaxValues.ts +1 -1
- package/src/features/column-faceting/createFacetedRowModel.ts +1 -1
- package/src/features/column-faceting/createFacetedUniqueValues.ts +1 -1
- package/src/features/column-filtering/columnFilteringFeature.utils.ts +8 -13
- package/src/features/column-filtering/createFilteredRowModel.ts +1 -1
- package/src/features/column-grouping/columnGroupingFeature.utils.ts +7 -7
- package/src/features/column-grouping/createGroupedRowModel.ts +1 -1
- package/src/features/column-ordering/columnOrderingFeature.utils.ts +3 -2
- package/src/features/column-pinning/columnPinningFeature.utils.ts +6 -4
- package/src/features/column-resizing/columnResizingFeature.utils.ts +6 -3
- package/src/features/column-sizing/columnSizingFeature.utils.ts +5 -5
- package/src/features/column-visibility/columnVisibilityFeature.utils.ts +3 -3
- package/src/features/global-filtering/globalFilteringFeature.utils.ts +4 -5
- package/src/features/row-expanding/createExpandedRowModel.ts +1 -1
- package/src/features/row-expanding/rowExpandingFeature.utils.ts +4 -3
- package/src/features/row-pagination/createPaginatedRowModel.ts +1 -1
- package/src/features/row-pagination/rowPaginationFeature.utils.ts +20 -16
- package/src/features/row-pinning/rowPinningFeature.utils.ts +6 -4
- package/src/features/row-selection/rowSelectionFeature.utils.ts +5 -6
- package/src/features/row-sorting/createSortedRowModel.ts +3 -4
- package/src/features/row-sorting/rowSortingFeature.utils.ts +7 -9
- package/src/flex-render.ts +60 -0
- package/src/index.ts +0 -1
- package/src/utils.ts +24 -0
- package/dist/helpers/tableHelper.cjs +0 -21
- package/dist/helpers/tableHelper.cjs.map +0 -1
- package/dist/helpers/tableHelper.d.cts +0 -30
- package/dist/helpers/tableHelper.d.ts +0 -30
- package/dist/helpers/tableHelper.js +0 -21
- package/dist/helpers/tableHelper.js.map +0 -1
- package/src/helpers/tableHelper.ts +0 -61
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { filterFn_includesString } from '../../fns/filterFns'
|
|
2
|
-
import { isFunction } from '../../utils'
|
|
2
|
+
import { cloneState, isFunction } from '../../utils'
|
|
3
3
|
import type { Column_Internal } from '../../types/Column'
|
|
4
4
|
import type { FilterFn } from '../column-filtering/columnFilteringFeature.types'
|
|
5
5
|
import type { CellData, RowData } from '../../types/type-utils'
|
|
@@ -31,9 +31,8 @@ export function table_getGlobalFilterFn<
|
|
|
31
31
|
table: Table_Internal<TFeatures, TData>,
|
|
32
32
|
): FilterFn<TFeatures, TData> | FilterFn<TFeatures, TData> | undefined {
|
|
33
33
|
const { globalFilterFn: globalFilterFn } = table.options
|
|
34
|
-
const filterFns
|
|
35
|
-
|
|
36
|
-
| undefined
|
|
34
|
+
const filterFns: Record<string, FilterFn<TFeatures, TData>> | undefined =
|
|
35
|
+
table._rowModelFns.filterFns
|
|
37
36
|
|
|
38
37
|
return isFunction(globalFilterFn)
|
|
39
38
|
? globalFilterFn
|
|
@@ -55,6 +54,6 @@ export function table_resetGlobalFilter<
|
|
|
55
54
|
>(table: Table_Internal<TFeatures, TData>, defaultState?: boolean) {
|
|
56
55
|
table_setGlobalFilter(
|
|
57
56
|
table,
|
|
58
|
-
defaultState ? undefined : table.initialState.globalFilter,
|
|
57
|
+
defaultState ? undefined : cloneState(table.initialState.globalFilter),
|
|
59
58
|
)
|
|
60
59
|
}
|
|
@@ -11,7 +11,7 @@ export function createExpandedRowModel<
|
|
|
11
11
|
TData extends RowData = any,
|
|
12
12
|
>(): (table: Table<TFeatures, TData>) => () => RowModel<TFeatures, TData> {
|
|
13
13
|
return (_table) => {
|
|
14
|
-
const table
|
|
14
|
+
const table: Table_Internal<TFeatures, TData> = _table
|
|
15
15
|
return tableMemo({
|
|
16
16
|
feature: 'rowExpandingFeature',
|
|
17
17
|
table,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { cloneState } from '../../utils'
|
|
1
2
|
import type { RowData, Updater } from '../../types/type-utils'
|
|
2
3
|
import type { TableFeatures } from '../../types/TableFeatures'
|
|
3
4
|
import type { Table_Internal } from '../../types/Table'
|
|
@@ -8,7 +9,7 @@ import type {
|
|
|
8
9
|
} from './rowExpandingFeature.types'
|
|
9
10
|
|
|
10
11
|
export function getDefaultExpandedState(): ExpandedState {
|
|
11
|
-
return
|
|
12
|
+
return {}
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
export function table_autoResetExpanded<
|
|
@@ -48,7 +49,7 @@ export function table_resetExpanded<
|
|
|
48
49
|
>(table: Table_Internal<TFeatures, TData>, defaultState?: boolean) {
|
|
49
50
|
table_setExpanded(
|
|
50
51
|
table,
|
|
51
|
-
defaultState ? {} : (table.initialState.expanded ?? {}),
|
|
52
|
+
defaultState ? {} : cloneState(table.initialState.expanded ?? {}),
|
|
52
53
|
)
|
|
53
54
|
}
|
|
54
55
|
|
|
@@ -161,7 +162,7 @@ export function row_getIsExpanded<
|
|
|
161
162
|
TFeatures extends TableFeatures,
|
|
162
163
|
TData extends RowData,
|
|
163
164
|
>(row: Row<TFeatures, TData>) {
|
|
164
|
-
const expanded = row.table.atoms.expanded?.get() ??
|
|
165
|
+
const expanded: ExpandedState = row.table.atoms.expanded?.get() ?? {}
|
|
165
166
|
|
|
166
167
|
return !!(
|
|
167
168
|
row.table.options.getIsRowExpanded?.(row) ??
|
|
@@ -12,7 +12,7 @@ export function createPaginatedRowModel<
|
|
|
12
12
|
TData extends RowData = any,
|
|
13
13
|
>(): (table: Table<TFeatures, TData>) => () => RowModel<TFeatures, TData> {
|
|
14
14
|
return (_table) => {
|
|
15
|
-
const table
|
|
15
|
+
const table: Table_Internal<TFeatures, TData> = _table
|
|
16
16
|
return tableMemo({
|
|
17
17
|
feature: 'rowPaginationFeature',
|
|
18
18
|
table,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { functionalUpdate } from '../../utils'
|
|
1
|
+
import { cloneState, functionalUpdate } from '../../utils'
|
|
2
2
|
import type { RowData, Updater } from '../../types/type-utils'
|
|
3
3
|
import type { TableFeatures } from '../../types/TableFeatures'
|
|
4
4
|
import type { Table_Internal } from '../../types/Table'
|
|
@@ -8,10 +8,10 @@ const defaultPageIndex = 0
|
|
|
8
8
|
const defaultPageSize = 10
|
|
9
9
|
|
|
10
10
|
export function getDefaultPaginationState(): PaginationState {
|
|
11
|
-
return
|
|
11
|
+
return {
|
|
12
12
|
pageIndex: defaultPageIndex,
|
|
13
13
|
pageSize: defaultPageSize,
|
|
14
|
-
}
|
|
14
|
+
}
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export function table_autoResetPageIndex<
|
|
@@ -48,7 +48,9 @@ export function table_resetPagination<
|
|
|
48
48
|
table,
|
|
49
49
|
defaultState
|
|
50
50
|
? getDefaultPaginationState()
|
|
51
|
-
: (
|
|
51
|
+
: cloneState(
|
|
52
|
+
table.initialState.pagination ?? getDefaultPaginationState(),
|
|
53
|
+
),
|
|
52
54
|
)
|
|
53
55
|
}
|
|
54
56
|
|
|
@@ -78,24 +80,26 @@ export function table_resetPageIndex<
|
|
|
78
80
|
TFeatures extends TableFeatures,
|
|
79
81
|
TData extends RowData,
|
|
80
82
|
>(table: Table_Internal<TFeatures, TData>, defaultState?: boolean) {
|
|
81
|
-
|
|
82
|
-
table
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
)
|
|
83
|
+
const currentPageIndex =
|
|
84
|
+
table.atoms.pagination?.get()?.pageIndex ?? defaultPageIndex
|
|
85
|
+
const newPageIndex = defaultState
|
|
86
|
+
? defaultPageIndex
|
|
87
|
+
: (table.initialState.pagination?.pageIndex ?? defaultPageIndex)
|
|
88
|
+
if (newPageIndex === currentPageIndex) return
|
|
89
|
+
table_setPageIndex(table, newPageIndex)
|
|
87
90
|
}
|
|
88
91
|
|
|
89
92
|
export function table_resetPageSize<
|
|
90
93
|
TFeatures extends TableFeatures,
|
|
91
94
|
TData extends RowData,
|
|
92
95
|
>(table: Table_Internal<TFeatures, TData>, defaultState?: boolean) {
|
|
93
|
-
|
|
94
|
-
table
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
)
|
|
96
|
+
const currentPageSize =
|
|
97
|
+
table.atoms.pagination?.get()?.pageSize ?? defaultPageSize
|
|
98
|
+
const newPageSize = defaultState
|
|
99
|
+
? defaultPageSize
|
|
100
|
+
: (table.initialState.pagination?.pageSize ?? defaultPageSize)
|
|
101
|
+
if (newPageSize === currentPageSize) return
|
|
102
|
+
table_setPageSize(table, newPageSize)
|
|
99
103
|
}
|
|
100
104
|
|
|
101
105
|
export function table_setPageSize<
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { row_getIsAllParentsExpanded } from '../row-expanding/rowExpandingFeature.utils'
|
|
2
|
-
import { callMemoOrStaticFn } from '../../utils'
|
|
2
|
+
import { callMemoOrStaticFn, cloneState } from '../../utils'
|
|
3
3
|
import type { RowData, Updater } from '../../types/type-utils'
|
|
4
4
|
import type { TableFeatures } from '../../types/TableFeatures'
|
|
5
5
|
import type { Table_Internal } from '../../types/Table'
|
|
@@ -12,10 +12,10 @@ import type {
|
|
|
12
12
|
// State Utils
|
|
13
13
|
|
|
14
14
|
export function getDefaultRowPinningState(): RowPinningState {
|
|
15
|
-
return
|
|
15
|
+
return {
|
|
16
16
|
top: [],
|
|
17
17
|
bottom: [],
|
|
18
|
-
}
|
|
18
|
+
}
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
export function table_setRowPinning<
|
|
@@ -36,7 +36,9 @@ export function table_resetRowPinning<
|
|
|
36
36
|
table,
|
|
37
37
|
defaultState
|
|
38
38
|
? getDefaultRowPinningState()
|
|
39
|
-
: (
|
|
39
|
+
: cloneState(
|
|
40
|
+
table.initialState.rowPinning ?? getDefaultRowPinningState(),
|
|
41
|
+
),
|
|
40
42
|
)
|
|
41
43
|
}
|
|
42
44
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { cloneState } from '../../utils'
|
|
1
2
|
import type { RowData, Updater } from '../../types/type-utils'
|
|
2
3
|
import type { TableFeatures } from '../../types/TableFeatures'
|
|
3
4
|
import type { RowModel } from '../../core/row-models/coreRowModelsFeature.types'
|
|
@@ -8,7 +9,7 @@ import type { RowSelectionState } from './rowSelectionFeature.types'
|
|
|
8
9
|
// State APIs
|
|
9
10
|
|
|
10
11
|
export function getDefaultRowSelectionState(): RowSelectionState {
|
|
11
|
-
return
|
|
12
|
+
return {}
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
export function table_setRowSelection<
|
|
@@ -27,7 +28,7 @@ export function table_resetRowSelection<
|
|
|
27
28
|
>(table: Table_Internal<TFeatures, TData>, defaultState?: boolean) {
|
|
28
29
|
table_setRowSelection(
|
|
29
30
|
table,
|
|
30
|
-
defaultState ? {} : (table.initialState.rowSelection ?? {}),
|
|
31
|
+
defaultState ? {} : cloneState(table.initialState.rowSelection ?? {}),
|
|
31
32
|
)
|
|
32
33
|
}
|
|
33
34
|
|
|
@@ -147,8 +148,7 @@ export function table_getIsAllRowsSelected<
|
|
|
147
148
|
TData extends RowData,
|
|
148
149
|
>(table: Table_Internal<TFeatures, TData>) {
|
|
149
150
|
const preGroupedFlatRows = table.getFilteredRowModel().flatRows
|
|
150
|
-
const rowSelection =
|
|
151
|
-
table.atoms.rowSelection?.get() ?? ({} as RowSelectionState)
|
|
151
|
+
const rowSelection: RowSelectionState = table.atoms.rowSelection?.get() ?? {}
|
|
152
152
|
|
|
153
153
|
let isAllRowsSelected = Boolean(
|
|
154
154
|
preGroupedFlatRows.length && Object.keys(rowSelection).length,
|
|
@@ -174,8 +174,7 @@ export function table_getIsAllPageRowsSelected<
|
|
|
174
174
|
const paginationFlatRows = table
|
|
175
175
|
.getPaginatedRowModel()
|
|
176
176
|
.flatRows.filter((row) => row_getCanSelect(row))
|
|
177
|
-
const rowSelection =
|
|
178
|
-
table.atoms.rowSelection?.get() ?? ({} as RowSelectionState)
|
|
177
|
+
const rowSelection: RowSelectionState = table.atoms.rowSelection?.get() ?? {}
|
|
179
178
|
|
|
180
179
|
let isAllPageRowsSelected = !!paginationFlatRows.length
|
|
181
180
|
|
|
@@ -16,7 +16,7 @@ export function createSortedRowModel<
|
|
|
16
16
|
sortFns: Record<keyof SortFns, SortFn<TFeatures, TData>>,
|
|
17
17
|
): (table: Table<TFeatures, TData>) => () => RowModel<TFeatures, TData> {
|
|
18
18
|
return (_table) => {
|
|
19
|
-
const table
|
|
19
|
+
const table: Table_Internal<TFeatures, TData> = _table
|
|
20
20
|
if (!table._rowModelFns.sortFns) table._rowModelFns.sortFns = sortFns
|
|
21
21
|
return tableMemo({
|
|
22
22
|
feature: 'rowSortingFeature',
|
|
@@ -62,9 +62,8 @@ function _createSortedRowModel<
|
|
|
62
62
|
> = {}
|
|
63
63
|
|
|
64
64
|
availableSorting.forEach((sortEntry) => {
|
|
65
|
-
const column
|
|
66
|
-
|
|
67
|
-
| undefined
|
|
65
|
+
const column: Column_Internal<TFeatures, TData> | undefined =
|
|
66
|
+
table.getColumn(sortEntry.id)
|
|
68
67
|
if (!column) return
|
|
69
68
|
|
|
70
69
|
columnInfoById[sortEntry.id] = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { reSplitAlphaNumeric, sortFn_basic } from '../../fns/sortFns'
|
|
2
|
-
import { isFunction } from '../../utils'
|
|
2
|
+
import { cloneState, isFunction } from '../../utils'
|
|
3
3
|
import type { CellData, RowData, Updater } from '../../types/type-utils'
|
|
4
4
|
import type { TableFeatures } from '../../types/TableFeatures'
|
|
5
5
|
import type { Table_Internal } from '../../types/Table'
|
|
@@ -13,7 +13,7 @@ import type {
|
|
|
13
13
|
// State Utils
|
|
14
14
|
|
|
15
15
|
export function getDefaultSortingState(): SortingState {
|
|
16
|
-
return
|
|
16
|
+
return []
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
export function table_setSorting<
|
|
@@ -29,7 +29,7 @@ export function table_resetSorting<
|
|
|
29
29
|
>(table: Table_Internal<TFeatures, TData>, defaultState?: boolean) {
|
|
30
30
|
table_setSorting(
|
|
31
31
|
table,
|
|
32
|
-
defaultState ? [] : (table.initialState.sorting ?? []),
|
|
32
|
+
defaultState ? [] : cloneState(table.initialState.sorting ?? []),
|
|
33
33
|
)
|
|
34
34
|
}
|
|
35
35
|
|
|
@@ -40,9 +40,8 @@ export function column_getAutoSortFn<
|
|
|
40
40
|
TData extends RowData,
|
|
41
41
|
TValue extends CellData = CellData,
|
|
42
42
|
>(column: Column_Internal<TFeatures, TData, TValue>): SortFn<TFeatures, TData> {
|
|
43
|
-
const sortFns
|
|
44
|
-
|
|
45
|
-
| undefined
|
|
43
|
+
const sortFns: Record<string, SortFn<TFeatures, TData>> | undefined =
|
|
44
|
+
column.table._rowModelFns.sortFns
|
|
46
45
|
|
|
47
46
|
let sortFn: SortFn<TFeatures, TData> | undefined
|
|
48
47
|
|
|
@@ -94,9 +93,8 @@ export function column_getSortFn<
|
|
|
94
93
|
TData extends RowData,
|
|
95
94
|
TValue extends CellData = CellData,
|
|
96
95
|
>(column: Column_Internal<TFeatures, TData, TValue>): SortFn<TFeatures, TData> {
|
|
97
|
-
const sortFns
|
|
98
|
-
|
|
99
|
-
| undefined
|
|
96
|
+
const sortFns: Record<string, SortFn<TFeatures, TData>> | undefined =
|
|
97
|
+
column.table._rowModelFns.sortFns
|
|
100
98
|
|
|
101
99
|
return isFunction(column.columnDef.sortFn)
|
|
102
100
|
? column.columnDef.sortFn
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { Cell } from './types/Cell'
|
|
2
|
+
import type { Header } from './types/Header'
|
|
3
|
+
import type { TableFeatures } from './types/TableFeatures'
|
|
4
|
+
import type { CellData, RowData } from './types/type-utils'
|
|
5
|
+
|
|
6
|
+
export function flexRender<TProps extends object>(
|
|
7
|
+
comp: unknown,
|
|
8
|
+
props: TProps,
|
|
9
|
+
): unknown | null {
|
|
10
|
+
if (comp == null) return null
|
|
11
|
+
|
|
12
|
+
if (typeof comp === 'function') {
|
|
13
|
+
return comp(props)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return comp
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export type FlexRenderProps<
|
|
20
|
+
TFeatures extends TableFeatures,
|
|
21
|
+
TData extends RowData,
|
|
22
|
+
TValue extends CellData = CellData,
|
|
23
|
+
> =
|
|
24
|
+
| { cell: Cell<TFeatures, TData, TValue>; header?: never; footer?: never }
|
|
25
|
+
| {
|
|
26
|
+
header: Header<TFeatures, TData, TValue>
|
|
27
|
+
cell?: never
|
|
28
|
+
footer?: never
|
|
29
|
+
}
|
|
30
|
+
| {
|
|
31
|
+
footer: Header<TFeatures, TData, TValue>
|
|
32
|
+
cell?: never
|
|
33
|
+
header?: never
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function FlexRender<
|
|
37
|
+
TFeatures extends TableFeatures,
|
|
38
|
+
TData extends RowData,
|
|
39
|
+
TValue extends CellData = CellData,
|
|
40
|
+
>(props: FlexRenderProps<TFeatures, TData, TValue>): unknown | null {
|
|
41
|
+
if ('cell' in props && props.cell) {
|
|
42
|
+
return flexRender(props.cell.column.columnDef.cell, props.cell.getContext())
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if ('header' in props && props.header) {
|
|
46
|
+
return flexRender(
|
|
47
|
+
props.header.column.columnDef.header,
|
|
48
|
+
props.header.getContext(),
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if ('footer' in props && props.footer) {
|
|
53
|
+
return flexRender(
|
|
54
|
+
props.footer.column.columnDef.footer,
|
|
55
|
+
props.footer.getContext(),
|
|
56
|
+
)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return null
|
|
60
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -23,7 +23,6 @@ export * from './types/type-utils'
|
|
|
23
23
|
export * from './core/coreFeatures'
|
|
24
24
|
export * from './helpers/columnHelper'
|
|
25
25
|
export * from './helpers/tableFeatures'
|
|
26
|
-
export * from './helpers/tableHelper'
|
|
27
26
|
export * from './helpers/tableOptions'
|
|
28
27
|
export * from './utils'
|
|
29
28
|
|
package/src/utils.ts
CHANGED
|
@@ -9,6 +9,30 @@ export function functionalUpdate<T>(updater: Updater<T>, input: T): T {
|
|
|
9
9
|
: updater
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
export function cloneState<T>(value: T): T {
|
|
13
|
+
if (Array.isArray(value)) {
|
|
14
|
+
return value.map(cloneState) as T
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (value && typeof value === 'object') {
|
|
18
|
+
const proto = Object.getPrototypeOf(value)
|
|
19
|
+
|
|
20
|
+
if (proto !== Object.prototype && proto !== null) {
|
|
21
|
+
return value
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const copy: Record<string, unknown> = {}
|
|
25
|
+
|
|
26
|
+
for (const key of Object.keys(value)) {
|
|
27
|
+
copy[key] = cloneState((value as Record<string, unknown>)[key])
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return copy as T
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return value
|
|
34
|
+
}
|
|
35
|
+
|
|
12
36
|
export function noop() {}
|
|
13
37
|
|
|
14
38
|
export function makeStateUpdater<
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
const require_columnHelper = require('./columnHelper.cjs');
|
|
2
|
-
|
|
3
|
-
//#region src/helpers/tableHelper.ts
|
|
4
|
-
/**
|
|
5
|
-
* Internal function to create a table helper that each adapter package will use to create their own table helper
|
|
6
|
-
*/
|
|
7
|
-
function constructTableHelper(tableCreator, tableHelperOptions) {
|
|
8
|
-
return {
|
|
9
|
-
createColumnHelper: require_columnHelper.createColumnHelper,
|
|
10
|
-
features: tableHelperOptions._features,
|
|
11
|
-
options: tableHelperOptions,
|
|
12
|
-
tableCreator: (tableOptions, selector) => tableCreator({
|
|
13
|
-
...tableHelperOptions,
|
|
14
|
-
...tableOptions
|
|
15
|
-
}, selector)
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
//#endregion
|
|
20
|
-
exports.constructTableHelper = constructTableHelper;
|
|
21
|
-
//# sourceMappingURL=tableHelper.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tableHelper.cjs","names":[],"sources":["../../src/helpers/tableHelper.ts"],"sourcesContent":["import { createColumnHelper } from './columnHelper'\nimport type { ColumnHelper } from './columnHelper'\nimport type { RowData } from '../types/type-utils'\nimport type { TableFeatures } from '../types/TableFeatures'\nimport type { Table } from '../types/Table'\nimport type { TableOptions } from '../types/TableOptions'\n\n/**\n * Options for creating a table helper to share common options across multiple tables\n * coreColumnsFeature, data, and state are excluded from this type and reserved for only the `useTable`/`createTable` functions\n */\nexport type TableHelperOptions<TFeatures extends TableFeatures> = Omit<\n TableOptions<TFeatures, any>,\n 'columns' | 'data' | 'store' | 'state' | 'initialState'\n> & {\n _features: TFeatures\n}\n\n/**\n * Internal type that each adapter package will build off of to create a table helper\n */\nexport type TableHelper_Core<TFeatures extends TableFeatures> = {\n createColumnHelper: <TData extends RowData>() => ColumnHelper<\n TFeatures,\n TData\n >\n features: TFeatures\n options: Omit<\n TableOptions<TFeatures, any>,\n 'columns' | 'data' | 'store' | 'state' | 'initialState'\n >\n tableCreator: <TData extends RowData>(\n tableOptions: Omit<\n TableOptions<TFeatures, TData>,\n '_features' | '_rowModels'\n >,\n selector?: any,\n ) => Table<TFeatures, TData>\n}\n\n/**\n * Internal function to create a table helper that each adapter package will use to create their own table helper\n */\nexport function constructTableHelper<TFeatures extends TableFeatures>(\n tableCreator: <TData extends RowData>(\n tableOptions: Omit<\n TableOptions<TFeatures, TData>,\n '_features' | '_rowModels'\n >,\n selector?: any,\n ) => Table<TFeatures, TData>,\n tableHelperOptions: TableHelperOptions<TFeatures>,\n): TableHelper_Core<TFeatures> {\n return {\n createColumnHelper,\n features: tableHelperOptions._features,\n options: tableHelperOptions,\n tableCreator: (tableOptions, selector) =>\n tableCreator({ ...tableHelperOptions, ...tableOptions }, selector),\n }\n}\n"],"mappings":";;;;;;AA2CA,SAAgB,qBACd,cAOA,oBAC6B;AAC7B,QAAO;EACL;EACA,UAAU,mBAAmB;EAC7B,SAAS;EACT,eAAe,cAAc,aAC3B,aAAa;GAAE,GAAG;GAAoB,GAAG;GAAc,EAAE,SAAS;EACrE"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { RowData } from "../types/type-utils.cjs";
|
|
2
|
-
import { TableOptions } from "../types/TableOptions.cjs";
|
|
3
|
-
import { TableFeatures } from "../types/TableFeatures.cjs";
|
|
4
|
-
import { Table } from "../types/Table.cjs";
|
|
5
|
-
import { ColumnHelper } from "./columnHelper.cjs";
|
|
6
|
-
|
|
7
|
-
//#region src/helpers/tableHelper.d.ts
|
|
8
|
-
/**
|
|
9
|
-
* Options for creating a table helper to share common options across multiple tables
|
|
10
|
-
* coreColumnsFeature, data, and state are excluded from this type and reserved for only the `useTable`/`createTable` functions
|
|
11
|
-
*/
|
|
12
|
-
type TableHelperOptions<TFeatures extends TableFeatures> = Omit<TableOptions<TFeatures, any>, 'columns' | 'data' | 'store' | 'state' | 'initialState'> & {
|
|
13
|
-
_features: TFeatures;
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* Internal type that each adapter package will build off of to create a table helper
|
|
17
|
-
*/
|
|
18
|
-
type TableHelper_Core<TFeatures extends TableFeatures> = {
|
|
19
|
-
createColumnHelper: <TData extends RowData>() => ColumnHelper<TFeatures, TData>;
|
|
20
|
-
features: TFeatures;
|
|
21
|
-
options: Omit<TableOptions<TFeatures, any>, 'columns' | 'data' | 'store' | 'state' | 'initialState'>;
|
|
22
|
-
tableCreator: <TData extends RowData>(tableOptions: Omit<TableOptions<TFeatures, TData>, '_features' | '_rowModels'>, selector?: any) => Table<TFeatures, TData>;
|
|
23
|
-
};
|
|
24
|
-
/**
|
|
25
|
-
* Internal function to create a table helper that each adapter package will use to create their own table helper
|
|
26
|
-
*/
|
|
27
|
-
declare function constructTableHelper<TFeatures extends TableFeatures>(tableCreator: <TData extends RowData>(tableOptions: Omit<TableOptions<TFeatures, TData>, '_features' | '_rowModels'>, selector?: any) => Table<TFeatures, TData>, tableHelperOptions: TableHelperOptions<TFeatures>): TableHelper_Core<TFeatures>;
|
|
28
|
-
//#endregion
|
|
29
|
-
export { TableHelperOptions, TableHelper_Core, constructTableHelper };
|
|
30
|
-
//# sourceMappingURL=tableHelper.d.cts.map
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { RowData } from "../types/type-utils.js";
|
|
2
|
-
import { TableOptions } from "../types/TableOptions.js";
|
|
3
|
-
import { TableFeatures } from "../types/TableFeatures.js";
|
|
4
|
-
import { Table } from "../types/Table.js";
|
|
5
|
-
import { ColumnHelper } from "./columnHelper.js";
|
|
6
|
-
|
|
7
|
-
//#region src/helpers/tableHelper.d.ts
|
|
8
|
-
/**
|
|
9
|
-
* Options for creating a table helper to share common options across multiple tables
|
|
10
|
-
* coreColumnsFeature, data, and state are excluded from this type and reserved for only the `useTable`/`createTable` functions
|
|
11
|
-
*/
|
|
12
|
-
type TableHelperOptions<TFeatures extends TableFeatures> = Omit<TableOptions<TFeatures, any>, 'columns' | 'data' | 'store' | 'state' | 'initialState'> & {
|
|
13
|
-
_features: TFeatures;
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* Internal type that each adapter package will build off of to create a table helper
|
|
17
|
-
*/
|
|
18
|
-
type TableHelper_Core<TFeatures extends TableFeatures> = {
|
|
19
|
-
createColumnHelper: <TData extends RowData>() => ColumnHelper<TFeatures, TData>;
|
|
20
|
-
features: TFeatures;
|
|
21
|
-
options: Omit<TableOptions<TFeatures, any>, 'columns' | 'data' | 'store' | 'state' | 'initialState'>;
|
|
22
|
-
tableCreator: <TData extends RowData>(tableOptions: Omit<TableOptions<TFeatures, TData>, '_features' | '_rowModels'>, selector?: any) => Table<TFeatures, TData>;
|
|
23
|
-
};
|
|
24
|
-
/**
|
|
25
|
-
* Internal function to create a table helper that each adapter package will use to create their own table helper
|
|
26
|
-
*/
|
|
27
|
-
declare function constructTableHelper<TFeatures extends TableFeatures>(tableCreator: <TData extends RowData>(tableOptions: Omit<TableOptions<TFeatures, TData>, '_features' | '_rowModels'>, selector?: any) => Table<TFeatures, TData>, tableHelperOptions: TableHelperOptions<TFeatures>): TableHelper_Core<TFeatures>;
|
|
28
|
-
//#endregion
|
|
29
|
-
export { TableHelperOptions, TableHelper_Core, constructTableHelper };
|
|
30
|
-
//# sourceMappingURL=tableHelper.d.ts.map
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { createColumnHelper } from "./columnHelper.js";
|
|
2
|
-
|
|
3
|
-
//#region src/helpers/tableHelper.ts
|
|
4
|
-
/**
|
|
5
|
-
* Internal function to create a table helper that each adapter package will use to create their own table helper
|
|
6
|
-
*/
|
|
7
|
-
function constructTableHelper(tableCreator, tableHelperOptions) {
|
|
8
|
-
return {
|
|
9
|
-
createColumnHelper,
|
|
10
|
-
features: tableHelperOptions._features,
|
|
11
|
-
options: tableHelperOptions,
|
|
12
|
-
tableCreator: (tableOptions, selector) => tableCreator({
|
|
13
|
-
...tableHelperOptions,
|
|
14
|
-
...tableOptions
|
|
15
|
-
}, selector)
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
//#endregion
|
|
20
|
-
export { constructTableHelper };
|
|
21
|
-
//# sourceMappingURL=tableHelper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tableHelper.js","names":[],"sources":["../../src/helpers/tableHelper.ts"],"sourcesContent":["import { createColumnHelper } from './columnHelper'\nimport type { ColumnHelper } from './columnHelper'\nimport type { RowData } from '../types/type-utils'\nimport type { TableFeatures } from '../types/TableFeatures'\nimport type { Table } from '../types/Table'\nimport type { TableOptions } from '../types/TableOptions'\n\n/**\n * Options for creating a table helper to share common options across multiple tables\n * coreColumnsFeature, data, and state are excluded from this type and reserved for only the `useTable`/`createTable` functions\n */\nexport type TableHelperOptions<TFeatures extends TableFeatures> = Omit<\n TableOptions<TFeatures, any>,\n 'columns' | 'data' | 'store' | 'state' | 'initialState'\n> & {\n _features: TFeatures\n}\n\n/**\n * Internal type that each adapter package will build off of to create a table helper\n */\nexport type TableHelper_Core<TFeatures extends TableFeatures> = {\n createColumnHelper: <TData extends RowData>() => ColumnHelper<\n TFeatures,\n TData\n >\n features: TFeatures\n options: Omit<\n TableOptions<TFeatures, any>,\n 'columns' | 'data' | 'store' | 'state' | 'initialState'\n >\n tableCreator: <TData extends RowData>(\n tableOptions: Omit<\n TableOptions<TFeatures, TData>,\n '_features' | '_rowModels'\n >,\n selector?: any,\n ) => Table<TFeatures, TData>\n}\n\n/**\n * Internal function to create a table helper that each adapter package will use to create their own table helper\n */\nexport function constructTableHelper<TFeatures extends TableFeatures>(\n tableCreator: <TData extends RowData>(\n tableOptions: Omit<\n TableOptions<TFeatures, TData>,\n '_features' | '_rowModels'\n >,\n selector?: any,\n ) => Table<TFeatures, TData>,\n tableHelperOptions: TableHelperOptions<TFeatures>,\n): TableHelper_Core<TFeatures> {\n return {\n createColumnHelper,\n features: tableHelperOptions._features,\n options: tableHelperOptions,\n tableCreator: (tableOptions, selector) =>\n tableCreator({ ...tableHelperOptions, ...tableOptions }, selector),\n }\n}\n"],"mappings":";;;;;;AA2CA,SAAgB,qBACd,cAOA,oBAC6B;AAC7B,QAAO;EACL;EACA,UAAU,mBAAmB;EAC7B,SAAS;EACT,eAAe,cAAc,aAC3B,aAAa;GAAE,GAAG;GAAoB,GAAG;GAAc,EAAE,SAAS;EACrE"}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { createColumnHelper } from './columnHelper'
|
|
2
|
-
import type { ColumnHelper } from './columnHelper'
|
|
3
|
-
import type { RowData } from '../types/type-utils'
|
|
4
|
-
import type { TableFeatures } from '../types/TableFeatures'
|
|
5
|
-
import type { Table } from '../types/Table'
|
|
6
|
-
import type { TableOptions } from '../types/TableOptions'
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Options for creating a table helper to share common options across multiple tables
|
|
10
|
-
* coreColumnsFeature, data, and state are excluded from this type and reserved for only the `useTable`/`createTable` functions
|
|
11
|
-
*/
|
|
12
|
-
export type TableHelperOptions<TFeatures extends TableFeatures> = Omit<
|
|
13
|
-
TableOptions<TFeatures, any>,
|
|
14
|
-
'columns' | 'data' | 'store' | 'state' | 'initialState'
|
|
15
|
-
> & {
|
|
16
|
-
_features: TFeatures
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Internal type that each adapter package will build off of to create a table helper
|
|
21
|
-
*/
|
|
22
|
-
export type TableHelper_Core<TFeatures extends TableFeatures> = {
|
|
23
|
-
createColumnHelper: <TData extends RowData>() => ColumnHelper<
|
|
24
|
-
TFeatures,
|
|
25
|
-
TData
|
|
26
|
-
>
|
|
27
|
-
features: TFeatures
|
|
28
|
-
options: Omit<
|
|
29
|
-
TableOptions<TFeatures, any>,
|
|
30
|
-
'columns' | 'data' | 'store' | 'state' | 'initialState'
|
|
31
|
-
>
|
|
32
|
-
tableCreator: <TData extends RowData>(
|
|
33
|
-
tableOptions: Omit<
|
|
34
|
-
TableOptions<TFeatures, TData>,
|
|
35
|
-
'_features' | '_rowModels'
|
|
36
|
-
>,
|
|
37
|
-
selector?: any,
|
|
38
|
-
) => Table<TFeatures, TData>
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Internal function to create a table helper that each adapter package will use to create their own table helper
|
|
43
|
-
*/
|
|
44
|
-
export function constructTableHelper<TFeatures extends TableFeatures>(
|
|
45
|
-
tableCreator: <TData extends RowData>(
|
|
46
|
-
tableOptions: Omit<
|
|
47
|
-
TableOptions<TFeatures, TData>,
|
|
48
|
-
'_features' | '_rowModels'
|
|
49
|
-
>,
|
|
50
|
-
selector?: any,
|
|
51
|
-
) => Table<TFeatures, TData>,
|
|
52
|
-
tableHelperOptions: TableHelperOptions<TFeatures>,
|
|
53
|
-
): TableHelper_Core<TFeatures> {
|
|
54
|
-
return {
|
|
55
|
-
createColumnHelper,
|
|
56
|
-
features: tableHelperOptions._features,
|
|
57
|
-
options: tableHelperOptions,
|
|
58
|
-
tableCreator: (tableOptions, selector) =>
|
|
59
|
-
tableCreator({ ...tableHelperOptions, ...tableOptions }, selector),
|
|
60
|
-
}
|
|
61
|
-
}
|