@tanstack/table-core 9.0.0-alpha.33 → 9.0.0-alpha.36
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/coreColumnsFeature.cjs +18 -12
- package/dist/core/columns/coreColumnsFeature.cjs.map +1 -1
- package/dist/core/columns/coreColumnsFeature.js +18 -12
- package/dist/core/columns/coreColumnsFeature.js.map +1 -1
- package/dist/core/headers/coreHeadersFeature.cjs +11 -8
- package/dist/core/headers/coreHeadersFeature.cjs.map +1 -1
- package/dist/core/headers/coreHeadersFeature.js +11 -8
- package/dist/core/headers/coreHeadersFeature.js.map +1 -1
- package/dist/core/headers/coreHeadersFeature.utils.cjs +2 -1
- package/dist/core/headers/coreHeadersFeature.utils.cjs.map +1 -1
- package/dist/core/headers/coreHeadersFeature.utils.js +2 -1
- package/dist/core/headers/coreHeadersFeature.utils.js.map +1 -1
- package/dist/core/table/constructTable.cjs +21 -11
- package/dist/core/table/constructTable.cjs.map +1 -1
- package/dist/core/table/constructTable.d.cts +1 -3
- package/dist/core/table/constructTable.d.ts +1 -3
- package/dist/core/table/constructTable.js +23 -12
- package/dist/core/table/constructTable.js.map +1 -1
- package/dist/core/table/coreTablesFeature.types.d.cts +54 -10
- package/dist/core/table/coreTablesFeature.types.d.ts +54 -10
- package/dist/core/table/coreTablesFeature.utils.cjs +5 -1
- package/dist/core/table/coreTablesFeature.utils.cjs.map +1 -1
- package/dist/core/table/coreTablesFeature.utils.js +6 -2
- package/dist/core/table/coreTablesFeature.utils.js.map +1 -1
- package/dist/features/column-faceting/columnFacetingFeature.cjs +18 -12
- package/dist/features/column-faceting/columnFacetingFeature.cjs.map +1 -1
- package/dist/features/column-faceting/columnFacetingFeature.js +18 -12
- package/dist/features/column-faceting/columnFacetingFeature.js.map +1 -1
- package/dist/features/column-faceting/createFacetedRowModel.cjs +9 -6
- package/dist/features/column-faceting/createFacetedRowModel.cjs.map +1 -1
- package/dist/features/column-faceting/createFacetedRowModel.js +9 -6
- package/dist/features/column-faceting/createFacetedRowModel.js.map +1 -1
- package/dist/features/column-filtering/columnFilteringFeature.utils.cjs +6 -6
- package/dist/features/column-filtering/columnFilteringFeature.utils.cjs.map +1 -1
- package/dist/features/column-filtering/columnFilteringFeature.utils.js +7 -7
- package/dist/features/column-filtering/columnFilteringFeature.utils.js.map +1 -1
- package/dist/features/column-filtering/createFilteredRowModel.cjs +11 -6
- package/dist/features/column-filtering/createFilteredRowModel.cjs.map +1 -1
- package/dist/features/column-filtering/createFilteredRowModel.js +11 -6
- package/dist/features/column-filtering/createFilteredRowModel.js.map +1 -1
- package/dist/features/column-grouping/columnGroupingFeature.utils.cjs +6 -6
- package/dist/features/column-grouping/columnGroupingFeature.utils.cjs.map +1 -1
- package/dist/features/column-grouping/columnGroupingFeature.utils.js +7 -7
- package/dist/features/column-grouping/columnGroupingFeature.utils.js.map +1 -1
- package/dist/features/column-grouping/createGroupedRowModel.cjs +6 -2
- package/dist/features/column-grouping/createGroupedRowModel.cjs.map +1 -1
- package/dist/features/column-grouping/createGroupedRowModel.js +6 -2
- package/dist/features/column-grouping/createGroupedRowModel.js.map +1 -1
- package/dist/features/column-ordering/columnOrderingFeature.cjs +17 -11
- package/dist/features/column-ordering/columnOrderingFeature.cjs.map +1 -1
- package/dist/features/column-ordering/columnOrderingFeature.js +17 -11
- package/dist/features/column-ordering/columnOrderingFeature.js.map +1 -1
- package/dist/features/column-ordering/columnOrderingFeature.utils.cjs +8 -5
- package/dist/features/column-ordering/columnOrderingFeature.utils.cjs.map +1 -1
- package/dist/features/column-ordering/columnOrderingFeature.utils.js +8 -5
- package/dist/features/column-ordering/columnOrderingFeature.utils.js.map +1 -1
- package/dist/features/column-pinning/columnPinningFeature.cjs +72 -45
- package/dist/features/column-pinning/columnPinningFeature.cjs.map +1 -1
- package/dist/features/column-pinning/columnPinningFeature.js +72 -45
- package/dist/features/column-pinning/columnPinningFeature.js.map +1 -1
- package/dist/features/column-pinning/columnPinningFeature.utils.cjs +27 -16
- package/dist/features/column-pinning/columnPinningFeature.utils.cjs.map +1 -1
- package/dist/features/column-pinning/columnPinningFeature.utils.js +28 -17
- package/dist/features/column-pinning/columnPinningFeature.utils.js.map +1 -1
- package/dist/features/column-resizing/columnResizingFeature.utils.cjs +6 -5
- package/dist/features/column-resizing/columnResizingFeature.utils.cjs.map +1 -1
- package/dist/features/column-resizing/columnResizingFeature.utils.js +6 -5
- package/dist/features/column-resizing/columnResizingFeature.utils.js.map +1 -1
- package/dist/features/column-sizing/columnSizingFeature.cjs +16 -10
- package/dist/features/column-sizing/columnSizingFeature.cjs.map +1 -1
- package/dist/features/column-sizing/columnSizingFeature.js +16 -10
- package/dist/features/column-sizing/columnSizingFeature.js.map +1 -1
- package/dist/features/column-sizing/columnSizingFeature.utils.cjs +6 -6
- package/dist/features/column-sizing/columnSizingFeature.utils.cjs.map +1 -1
- package/dist/features/column-sizing/columnSizingFeature.utils.js +7 -7
- package/dist/features/column-sizing/columnSizingFeature.utils.js.map +1 -1
- package/dist/features/column-visibility/columnVisibilityFeature.cjs +28 -16
- package/dist/features/column-visibility/columnVisibilityFeature.cjs.map +1 -1
- package/dist/features/column-visibility/columnVisibilityFeature.js +28 -16
- package/dist/features/column-visibility/columnVisibilityFeature.js.map +1 -1
- package/dist/features/column-visibility/columnVisibilityFeature.utils.cjs +4 -4
- package/dist/features/column-visibility/columnVisibilityFeature.utils.cjs.map +1 -1
- package/dist/features/column-visibility/columnVisibilityFeature.utils.js +5 -5
- 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 +10 -6
- package/dist/features/row-expanding/createExpandedRowModel.cjs.map +1 -1
- package/dist/features/row-expanding/createExpandedRowModel.js +10 -6
- package/dist/features/row-expanding/createExpandedRowModel.js.map +1 -1
- package/dist/features/row-expanding/rowExpandingFeature.utils.cjs +11 -7
- package/dist/features/row-expanding/rowExpandingFeature.utils.cjs.map +1 -1
- package/dist/features/row-expanding/rowExpandingFeature.utils.js +12 -7
- package/dist/features/row-expanding/rowExpandingFeature.utils.js.map +1 -1
- package/dist/features/row-pagination/createPaginatedRowModel.cjs +10 -6
- package/dist/features/row-pagination/createPaginatedRowModel.cjs.map +1 -1
- package/dist/features/row-pagination/createPaginatedRowModel.js +10 -6
- 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.cjs +12 -6
- package/dist/features/row-pinning/rowPinningFeature.cjs.map +1 -1
- package/dist/features/row-pinning/rowPinningFeature.js +12 -6
- package/dist/features/row-pinning/rowPinningFeature.js.map +1 -1
- package/dist/features/row-pinning/rowPinningFeature.utils.cjs +11 -8
- package/dist/features/row-pinning/rowPinningFeature.utils.cjs.map +1 -1
- package/dist/features/row-pinning/rowPinningFeature.utils.js +12 -9
- package/dist/features/row-pinning/rowPinningFeature.utils.js.map +1 -1
- package/dist/features/row-selection/rowSelectionFeature.cjs +12 -3
- package/dist/features/row-selection/rowSelectionFeature.cjs.map +1 -1
- package/dist/features/row-selection/rowSelectionFeature.js +12 -3
- package/dist/features/row-selection/rowSelectionFeature.js.map +1 -1
- package/dist/features/row-selection/rowSelectionFeature.types.d.cts +1 -1
- package/dist/features/row-selection/rowSelectionFeature.types.d.ts +1 -1
- package/dist/features/row-selection/rowSelectionFeature.utils.cjs +17 -9
- package/dist/features/row-selection/rowSelectionFeature.utils.cjs.map +1 -1
- package/dist/features/row-selection/rowSelectionFeature.utils.js +18 -9
- package/dist/features/row-selection/rowSelectionFeature.utils.js.map +1 -1
- package/dist/features/row-sorting/createSortedRowModel.cjs +6 -2
- package/dist/features/row-sorting/createSortedRowModel.cjs.map +1 -1
- package/dist/features/row-sorting/createSortedRowModel.js +6 -2
- package/dist/features/row-sorting/createSortedRowModel.js.map +1 -1
- package/dist/features/row-sorting/rowSortingFeature.utils.cjs +6 -6
- package/dist/features/row-sorting/rowSortingFeature.utils.cjs.map +1 -1
- package/dist/features/row-sorting/rowSortingFeature.utils.js +7 -7
- package/dist/features/row-sorting/rowSortingFeature.utils.js.map +1 -1
- package/dist/features/table-reactivity/tableReactivityFeature.cjs +23 -1
- package/dist/features/table-reactivity/tableReactivityFeature.cjs.map +1 -1
- package/dist/features/table-reactivity/tableReactivityFeature.js +23 -1
- package/dist/features/table-reactivity/tableReactivityFeature.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/index.cjs +2 -263
- package/dist/index.d.cts +4 -25
- package/dist/index.d.ts +4 -25
- package/dist/index.js +3 -24
- package/dist/static-functions.cjs +261 -0
- package/dist/static-functions.d.cts +21 -0
- package/dist/static-functions.d.ts +21 -0
- package/dist/static-functions.js +22 -0
- package/dist/types/Table.d.cts +5 -3
- package/dist/types/Table.d.ts +5 -3
- package/dist/utils.cjs +14 -6
- 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 +14 -7
- package/dist/utils.js.map +1 -1
- package/package.json +9 -1
- package/src/core/columns/coreColumnsFeature.ts +4 -4
- package/src/core/headers/coreHeadersFeature.ts +4 -4
- package/src/core/headers/coreHeadersFeature.utils.ts +1 -1
- package/src/core/table/constructTable.ts +33 -16
- package/src/core/table/coreTablesFeature.types.ts +69 -9
- package/src/core/table/coreTablesFeature.utils.ts +8 -2
- package/src/features/column-faceting/columnFacetingFeature.ts +4 -4
- package/src/features/column-faceting/createFacetedRowModel.ts +2 -2
- package/src/features/column-filtering/columnFilteringFeature.utils.ts +9 -8
- package/src/features/column-filtering/createFilteredRowModel.ts +4 -3
- package/src/features/column-grouping/columnGroupingFeature.utils.ts +5 -5
- package/src/features/column-grouping/createGroupedRowModel.ts +2 -2
- package/src/features/column-ordering/columnOrderingFeature.ts +5 -5
- package/src/features/column-ordering/columnOrderingFeature.utils.ts +6 -5
- package/src/features/column-pinning/columnPinningFeature.ts +22 -21
- package/src/features/column-pinning/columnPinningFeature.utils.ts +18 -16
- package/src/features/column-resizing/columnResizingFeature.utils.ts +9 -4
- package/src/features/column-sizing/columnSizingFeature.ts +2 -2
- package/src/features/column-sizing/columnSizingFeature.utils.ts +6 -6
- package/src/features/column-visibility/columnVisibilityFeature.ts +6 -6
- package/src/features/column-visibility/columnVisibilityFeature.utils.ts +4 -4
- package/src/features/global-filtering/globalFilteringFeature.utils.ts +2 -2
- package/src/features/row-expanding/createExpandedRowModel.ts +2 -2
- package/src/features/row-expanding/rowExpandingFeature.utils.ts +8 -7
- package/src/features/row-pagination/createPaginatedRowModel.ts +3 -3
- package/src/features/row-pagination/rowPaginationFeature.utils.ts +23 -19
- package/src/features/row-pinning/rowPinningFeature.ts +4 -4
- package/src/features/row-pinning/rowPinningFeature.utils.ts +10 -8
- package/src/features/row-selection/rowSelectionFeature.ts +3 -3
- package/src/features/row-selection/rowSelectionFeature.types.ts +1 -1
- package/src/features/row-selection/rowSelectionFeature.utils.ts +13 -10
- package/src/features/row-sorting/createSortedRowModel.ts +5 -2
- package/src/features/row-sorting/rowSortingFeature.utils.ts +8 -7
- package/src/features/table-reactivity/tableReactivityFeature.ts +46 -1
- package/src/flex-render.ts +60 -0
- package/src/index.ts +0 -21
- package/src/static-functions.ts +31 -0
- package/src/types/Table.ts +10 -3
- package/src/utils.ts +27 -8
- 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 { 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
|
|
|
@@ -271,9 +271,9 @@ export function column_getIsSorted<
|
|
|
271
271
|
TData extends RowData,
|
|
272
272
|
TValue extends CellData = CellData,
|
|
273
273
|
>(column: Column_Internal<TFeatures, TData, TValue>): false | SortDirection {
|
|
274
|
-
const columnSort = column.table.
|
|
275
|
-
(
|
|
276
|
-
|
|
274
|
+
const columnSort = column.table.atoms.sorting
|
|
275
|
+
?.get()
|
|
276
|
+
?.find((d) => d.id === column.id)
|
|
277
277
|
return !columnSort ? false : columnSort.desc ? 'desc' : 'asc'
|
|
278
278
|
}
|
|
279
279
|
|
|
@@ -283,7 +283,8 @@ export function column_getSortIndex<
|
|
|
283
283
|
TValue extends CellData = CellData,
|
|
284
284
|
>(column: Column_Internal<TFeatures, TData, TValue>): number {
|
|
285
285
|
return (
|
|
286
|
-
column.table.
|
|
286
|
+
column.table.atoms.sorting?.get()?.findIndex((d) => d.id === column.id) ??
|
|
287
|
+
-1
|
|
287
288
|
)
|
|
288
289
|
}
|
|
289
290
|
|
|
@@ -16,11 +16,11 @@ export function constructReactivityFeature<
|
|
|
16
16
|
}): TableFeature<TableReactivityFeatureConstructors<TFeatures, TData>> {
|
|
17
17
|
return {
|
|
18
18
|
constructTableAPIs: (table) => {
|
|
19
|
-
table.store = bindStore(table.store, bindings.stateNotifier)
|
|
20
19
|
table.optionsStore = bindStore(
|
|
21
20
|
table.optionsStore,
|
|
22
21
|
bindings.optionsNotifier,
|
|
23
22
|
)
|
|
23
|
+
table.atoms = bindAtoms(table.atoms, bindings.stateNotifier)
|
|
24
24
|
},
|
|
25
25
|
}
|
|
26
26
|
}
|
|
@@ -45,3 +45,48 @@ const bindStore = <T extends Store<any> | ReadonlyStore<any>>(
|
|
|
45
45
|
|
|
46
46
|
return store
|
|
47
47
|
}
|
|
48
|
+
|
|
49
|
+
// Wraps an atoms/baseAtoms map so that `.get()` on any individual atom
|
|
50
|
+
// calls the framework notifier first — matching how `bindStore` wraps
|
|
51
|
+
// `store.state`. The proxy also transparently forwards missing slices
|
|
52
|
+
// (atoms for features not registered on this table) as `undefined`.
|
|
53
|
+
const bindAtoms = <T extends object>(atoms: T, notifier?: () => unknown): T => {
|
|
54
|
+
if (!notifier) return atoms
|
|
55
|
+
// Cache wrapped atoms so referential identity is stable per slice.
|
|
56
|
+
const wrappedCache = new Map<PropertyKey, any>()
|
|
57
|
+
return new Proxy(atoms, {
|
|
58
|
+
get(target, prop, receiver) {
|
|
59
|
+
const atom = Reflect.get(target, prop, receiver) as unknown
|
|
60
|
+
if (!atom || typeof prop !== 'string' || !isAtomLike(atom)) {
|
|
61
|
+
return atom
|
|
62
|
+
}
|
|
63
|
+
if (wrappedCache.has(prop)) return wrappedCache.get(prop)
|
|
64
|
+
const originalGet = atom.get.bind(atom)
|
|
65
|
+
const wrapped = new Proxy(atom, {
|
|
66
|
+
get(atomTarget, atomProp, atomReceiver) {
|
|
67
|
+
if (atomProp === 'get') {
|
|
68
|
+
return () => {
|
|
69
|
+
notifier()
|
|
70
|
+
return originalGet()
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return Reflect.get(atomTarget, atomProp, atomReceiver)
|
|
74
|
+
},
|
|
75
|
+
})
|
|
76
|
+
wrappedCache.set(prop, wrapped)
|
|
77
|
+
return wrapped
|
|
78
|
+
},
|
|
79
|
+
})
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
interface AtomLike {
|
|
83
|
+
get: () => unknown
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function isAtomLike(value: unknown): value is AtomLike {
|
|
87
|
+
return (
|
|
88
|
+
typeof value === 'object' &&
|
|
89
|
+
value !== null &&
|
|
90
|
+
typeof (value as { get?: unknown }).get === 'function'
|
|
91
|
+
)
|
|
92
|
+
}
|
|
@@ -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
|
|
|
@@ -31,38 +30,32 @@ export * from './utils'
|
|
|
31
30
|
export * from './core/cells/constructCell'
|
|
32
31
|
export * from './core/cells/coreCellsFeature'
|
|
33
32
|
export * from './core/cells/coreCellsFeature.types'
|
|
34
|
-
export * from './core/cells/coreCellsFeature.utils'
|
|
35
33
|
|
|
36
34
|
// Columns
|
|
37
35
|
export * from './core/columns/constructColumn'
|
|
38
36
|
export * from './core/columns/coreColumnsFeature'
|
|
39
37
|
export * from './core/columns/coreColumnsFeature.types'
|
|
40
|
-
export * from './core/columns/coreColumnsFeature.utils'
|
|
41
38
|
|
|
42
39
|
// Headers
|
|
43
40
|
export * from './core/headers/buildHeaderGroups'
|
|
44
41
|
export * from './core/headers/constructHeader'
|
|
45
42
|
export * from './core/headers/coreHeadersFeature'
|
|
46
43
|
export * from './core/headers/coreHeadersFeature.types'
|
|
47
|
-
export * from './core/headers/coreHeadersFeature.utils'
|
|
48
44
|
|
|
49
45
|
// Rows
|
|
50
46
|
export * from './core/rows/constructRow'
|
|
51
47
|
export * from './core/rows/coreRowsFeature'
|
|
52
48
|
export * from './core/rows/coreRowsFeature.types'
|
|
53
|
-
export * from './core/rows/coreRowsFeature.utils'
|
|
54
49
|
|
|
55
50
|
// Row Models
|
|
56
51
|
export * from './core/row-models/coreRowModelsFeature'
|
|
57
52
|
export * from './core/row-models/coreRowModelsFeature.types'
|
|
58
|
-
export * from './core/row-models/coreRowModelsFeature.utils'
|
|
59
53
|
export * from './core/row-models/createCoreRowModel'
|
|
60
54
|
|
|
61
55
|
// Tables
|
|
62
56
|
export * from './core/table/constructTable'
|
|
63
57
|
export * from './core/table/coreTablesFeature'
|
|
64
58
|
export * from './core/table/coreTablesFeature.types'
|
|
65
|
-
export * from './core/table/coreTablesFeature.utils'
|
|
66
59
|
|
|
67
60
|
/**
|
|
68
61
|
* RowModelFns
|
|
@@ -84,7 +77,6 @@ export * from './features/table-reactivity/tableReactivityFeature'
|
|
|
84
77
|
// columnFacetingFeature
|
|
85
78
|
export * from './features/column-faceting/columnFacetingFeature'
|
|
86
79
|
export * from './features/column-faceting/columnFacetingFeature.types'
|
|
87
|
-
export * from './features/column-faceting/columnFacetingFeature.utils'
|
|
88
80
|
export * from './features/column-faceting/createFacetedMinMaxValues'
|
|
89
81
|
export * from './features/column-faceting/createFacetedRowModel'
|
|
90
82
|
export * from './features/column-faceting/createFacetedUniqueValues'
|
|
@@ -92,71 +84,58 @@ export * from './features/column-faceting/createFacetedUniqueValues'
|
|
|
92
84
|
// columnFilteringFeature
|
|
93
85
|
export * from './features/column-filtering/columnFilteringFeature'
|
|
94
86
|
export * from './features/column-filtering/columnFilteringFeature.types'
|
|
95
|
-
export * from './features/column-filtering/columnFilteringFeature.utils'
|
|
96
87
|
export * from './features/column-filtering/createFilteredRowModel'
|
|
97
88
|
|
|
98
89
|
// columnGroupingFeature
|
|
99
90
|
export * from './features/column-grouping/columnGroupingFeature'
|
|
100
91
|
export * from './features/column-grouping/columnGroupingFeature.types'
|
|
101
|
-
export * from './features/column-grouping/columnGroupingFeature.utils'
|
|
102
92
|
export * from './features/column-grouping/createGroupedRowModel'
|
|
103
93
|
|
|
104
94
|
// columnOrderingFeature
|
|
105
95
|
export * from './features/column-ordering/columnOrderingFeature'
|
|
106
96
|
export * from './features/column-ordering/columnOrderingFeature.types'
|
|
107
|
-
export * from './features/column-ordering/columnOrderingFeature.utils'
|
|
108
97
|
|
|
109
98
|
// columnPinningFeature
|
|
110
99
|
export * from './features/column-pinning/columnPinningFeature'
|
|
111
100
|
export * from './features/column-pinning/columnPinningFeature.types'
|
|
112
|
-
export * from './features/column-pinning/columnPinningFeature.utils'
|
|
113
101
|
|
|
114
102
|
// columnResizingFeature
|
|
115
103
|
export * from './features/column-resizing/columnResizingFeature'
|
|
116
104
|
export * from './features/column-resizing/columnResizingFeature.types'
|
|
117
|
-
export * from './features/column-resizing/columnResizingFeature.utils'
|
|
118
105
|
|
|
119
106
|
// columnSizingFeature
|
|
120
107
|
export * from './features/column-sizing/columnSizingFeature'
|
|
121
108
|
export * from './features/column-sizing/columnSizingFeature.types'
|
|
122
|
-
export * from './features/column-sizing/columnSizingFeature.utils'
|
|
123
109
|
|
|
124
110
|
// columnVisibilityFeature
|
|
125
111
|
export * from './features/column-visibility/columnVisibilityFeature'
|
|
126
112
|
export * from './features/column-visibility/columnVisibilityFeature.types'
|
|
127
|
-
export * from './features/column-visibility/columnVisibilityFeature.utils'
|
|
128
113
|
|
|
129
114
|
// globalFilteringFeature
|
|
130
115
|
export * from './features/global-filtering/globalFilteringFeature'
|
|
131
116
|
export * from './features/global-filtering/globalFilteringFeature.types'
|
|
132
|
-
export * from './features/global-filtering/globalFilteringFeature.utils'
|
|
133
117
|
|
|
134
118
|
// rowExpandingFeature
|
|
135
119
|
export * from './features/row-expanding/rowExpandingFeature'
|
|
136
120
|
export * from './features/row-expanding/rowExpandingFeature.types'
|
|
137
|
-
export * from './features/row-expanding/rowExpandingFeature.utils'
|
|
138
121
|
export * from './features/row-expanding/createExpandedRowModel'
|
|
139
122
|
|
|
140
123
|
// rowPaginationFeature
|
|
141
124
|
export * from './features/row-pagination/rowPaginationFeature'
|
|
142
125
|
export * from './features/row-pagination/rowPaginationFeature.types'
|
|
143
|
-
export * from './features/row-pagination/rowPaginationFeature.utils'
|
|
144
126
|
export * from './features/row-pagination/createPaginatedRowModel'
|
|
145
127
|
|
|
146
128
|
// rowPinningFeature
|
|
147
129
|
export * from './features/row-pinning/rowPinningFeature'
|
|
148
130
|
export * from './features/row-pinning/rowPinningFeature.types'
|
|
149
|
-
export * from './features/row-pinning/rowPinningFeature.utils'
|
|
150
131
|
|
|
151
132
|
// rowSelectionFeature
|
|
152
133
|
export * from './features/row-selection/rowSelectionFeature'
|
|
153
134
|
export * from './features/row-selection/rowSelectionFeature.types'
|
|
154
|
-
export * from './features/row-selection/rowSelectionFeature.utils'
|
|
155
135
|
|
|
156
136
|
// rowSortingFeature
|
|
157
137
|
export * from './features/row-sorting/rowSortingFeature'
|
|
158
138
|
export * from './features/row-sorting/rowSortingFeature.types'
|
|
159
|
-
export * from './features/row-sorting/rowSortingFeature.utils'
|
|
160
139
|
export * from './features/row-sorting/createSortedRowModel'
|
|
161
140
|
|
|
162
141
|
// force
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Static utility functions sub-entry.
|
|
3
|
+
*
|
|
4
|
+
* Re-exports all standalone utility functions from each feature's `.utils.ts`
|
|
5
|
+
* module so consumers that want the functions (without constructing a table)
|
|
6
|
+
* can grab them from a single path.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
// Core
|
|
10
|
+
export * from './core/cells/coreCellsFeature.utils'
|
|
11
|
+
export * from './core/columns/coreColumnsFeature.utils'
|
|
12
|
+
export * from './core/headers/coreHeadersFeature.utils'
|
|
13
|
+
export * from './core/rows/coreRowsFeature.utils'
|
|
14
|
+
export * from './core/row-models/coreRowModelsFeature.utils'
|
|
15
|
+
export * from './core/table/coreTablesFeature.utils'
|
|
16
|
+
|
|
17
|
+
// Features
|
|
18
|
+
export * from './features/column-faceting/columnFacetingFeature.utils'
|
|
19
|
+
export * from './features/column-filtering/columnFilteringFeature.utils'
|
|
20
|
+
export * from './features/column-grouping/columnGroupingFeature.utils'
|
|
21
|
+
export * from './features/column-ordering/columnOrderingFeature.utils'
|
|
22
|
+
export * from './features/column-pinning/columnPinningFeature.utils'
|
|
23
|
+
export * from './features/column-resizing/columnResizingFeature.utils'
|
|
24
|
+
export * from './features/column-sizing/columnSizingFeature.utils'
|
|
25
|
+
export * from './features/column-visibility/columnVisibilityFeature.utils'
|
|
26
|
+
export * from './features/global-filtering/globalFilteringFeature.utils'
|
|
27
|
+
export * from './features/row-expanding/rowExpandingFeature.utils'
|
|
28
|
+
export * from './features/row-pagination/rowPaginationFeature.utils'
|
|
29
|
+
export * from './features/row-pinning/rowPinningFeature.utils'
|
|
30
|
+
export * from './features/row-selection/rowSelectionFeature.utils'
|
|
31
|
+
export * from './features/row-sorting/rowSortingFeature.utils'
|
package/src/types/Table.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ReadonlyStore
|
|
1
|
+
import type { ReadonlyStore } from '@tanstack/store'
|
|
2
2
|
import type { Table_ColumnFaceting } from '../features/column-faceting/columnFacetingFeature.types'
|
|
3
3
|
import type { Table_ColumnResizing } from '../features/column-resizing/columnResizingFeature.types'
|
|
4
4
|
import type { Table_ColumnFiltering } from '../features/column-filtering/columnFilteringFeature.types'
|
|
@@ -22,7 +22,12 @@ import type { ExtractFeatureTypes, TableFeatures } from './TableFeatures'
|
|
|
22
22
|
import type { Table_Columns } from '../core/columns/coreColumnsFeature.types'
|
|
23
23
|
import type { Table_Headers } from '../core/headers/coreHeadersFeature.types'
|
|
24
24
|
import type { Table_Rows } from '../core/rows/coreRowsFeature.types'
|
|
25
|
-
import type {
|
|
25
|
+
import type {
|
|
26
|
+
Atoms_All,
|
|
27
|
+
BaseAtoms_All,
|
|
28
|
+
ExternalAtoms_All,
|
|
29
|
+
Table_Table,
|
|
30
|
+
} from '../core/table/coreTablesFeature.types'
|
|
26
31
|
import type { TableOptions_All } from './TableOptions'
|
|
27
32
|
|
|
28
33
|
/**
|
|
@@ -118,8 +123,10 @@ export type Table_Internal<
|
|
|
118
123
|
_rowModels?: CreateRowModels_All<TFeatures, TData>
|
|
119
124
|
state?: TableState_All
|
|
120
125
|
initialState?: TableState_All
|
|
126
|
+
atoms?: ExternalAtoms_All
|
|
121
127
|
}
|
|
122
128
|
initialState: TableState_All
|
|
123
|
-
|
|
129
|
+
baseAtoms: BaseAtoms_All
|
|
130
|
+
atoms: Atoms_All
|
|
124
131
|
store: ReadonlyStore<TableState_All>
|
|
125
132
|
}
|
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<
|
|
@@ -16,14 +40,9 @@ export function makeStateUpdater<
|
|
|
16
40
|
K extends (string & {}) | keyof TableState_All | keyof TableState<TFeatures>,
|
|
17
41
|
>(key: K, instance: Table<TFeatures, any>) {
|
|
18
42
|
return (updater: Updater<TableState<any>[K & keyof TableState<any>]>) => {
|
|
19
|
-
instance.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
...old,
|
|
23
|
-
[key]: functionalUpdate(updater, (old as any)[key]),
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
)
|
|
43
|
+
const externalAtom = (instance.options as any).atoms?.[key]
|
|
44
|
+
const targetAtom = externalAtom ?? (instance.baseAtoms as any)[key]
|
|
45
|
+
targetAtom.set((old: any) => functionalUpdate(updater, old))
|
|
27
46
|
}
|
|
28
47
|
}
|
|
29
48
|
|
|
@@ -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
|
-
}
|