@octane-xplat/table 0.0.1 → 0.11.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/LICENSE +21 -0
- package/README.md +427 -3
- package/dist/native/ColumnDrag.tsrx.js +237 -0
- package/dist/native/DataGrid.tsrx.js +957 -0
- package/dist/native/GridControls.tsrx.js +424 -0
- package/dist/native/grid-accessibility.js +12 -0
- package/dist/native/grid-layout.js +43 -0
- package/dist/native/index.js +4 -0
- package/dist/native/octane-client-build.json +8 -0
- package/dist/native/table.js +56 -0
- package/dist/native/useTable.tsrx.js +24 -0
- package/dist/web/ColumnDrag.tsrx.js +85 -0
- package/dist/web/DataGrid.tsrx.js +242 -0
- package/dist/web/GridControls.tsrx.js +114 -0
- package/dist/web/grid-accessibility.js +12 -0
- package/dist/web/grid-layout.js +43 -0
- package/dist/web/index.js +4 -0
- package/dist/web/octane-client-build.json +8 -0
- package/dist/web/table.js +56 -0
- package/dist/web/useTable.tsrx.js +26 -0
- package/package.json +75 -3
- package/src/ColumnDrag.tsrx +123 -0
- package/src/DataGrid.mobile.test.tsrx +55 -0
- package/src/DataGrid.tsrx +350 -0
- package/src/DataGrid.web.test.tsrx +277 -0
- package/src/GridControls.tsrx +157 -0
- package/src/grid-accessibility.ts +14 -0
- package/src/grid-layout.test.ts +32 -0
- package/src/grid-layout.ts +52 -0
- package/src/index.macos.ts +8 -0
- package/src/index.ts +7 -0
- package/src/index.web.ts +8 -0
- package/src/props.ts +122 -0
- package/src/table.test.ts +114 -0
- package/src/table.ts +91 -0
- package/src/useTable.tsrx +34 -0
- package/types/index.d.ts +20 -0
- package/types/index.macos.d.ts +17 -0
- package/types/props.d.ts +96 -0
- package/types/table.d.ts +83 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
import { createTable } from './table'
|
|
3
|
+
|
|
4
|
+
const DATA = [
|
|
5
|
+
{ name: 'Charlie', n: 3 },
|
|
6
|
+
{ name: 'Alice', n: 1 },
|
|
7
|
+
{ name: 'Bob', n: 2 },
|
|
8
|
+
]
|
|
9
|
+
|
|
10
|
+
const columns = [
|
|
11
|
+
{ accessorKey: 'name', header: 'Name' },
|
|
12
|
+
{ accessorKey: 'n', header: 'N' },
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
const names = (table: any) => table.getRowModel().rows.map((r: any) => r.original.name)
|
|
16
|
+
|
|
17
|
+
describe('createTable', () => {
|
|
18
|
+
it('builds the core row model in data order', () => {
|
|
19
|
+
const table = createTable({ data: DATA, columns })
|
|
20
|
+
expect(names(table)).toEqual(['Charlie', 'Alice', 'Bob'])
|
|
21
|
+
expect(table.getHeaderGroups().map((g: any) => g.headers.map((h: any) => h.column.id))).toEqual(
|
|
22
|
+
[['name', 'n']],
|
|
23
|
+
)
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
it('sorts through the sorting state slice', () => {
|
|
27
|
+
const table = createTable({ data: DATA, columns })
|
|
28
|
+
table.setSorting([{ id: 'name', desc: false }])
|
|
29
|
+
expect(names(table)).toEqual(['Alice', 'Bob', 'Charlie'])
|
|
30
|
+
table.setSorting([{ id: 'name', desc: true }])
|
|
31
|
+
expect(names(table)).toEqual(['Charlie', 'Bob', 'Alice'])
|
|
32
|
+
table.setSorting([])
|
|
33
|
+
expect(names(table)).toEqual(['Charlie', 'Alice', 'Bob'])
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
it('notifies subscribers through table.store and memoizes the row model', () => {
|
|
37
|
+
const table = createTable({ data: DATA, columns })
|
|
38
|
+
const seen: unknown[] = []
|
|
39
|
+
const sub = table.store.subscribe((s: any) => seen.push(s.sorting))
|
|
40
|
+
const before = table.getRowModel()
|
|
41
|
+
table.setSorting([{ id: 'name', desc: false }])
|
|
42
|
+
expect(seen.at(-1)).toEqual([{ id: 'name', desc: false }])
|
|
43
|
+
expect(table.getRowModel() === before).toBe(false)
|
|
44
|
+
sub.unsubscribe()
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
it('filters via global filter', () => {
|
|
48
|
+
const table = createTable({ data: DATA, columns })
|
|
49
|
+
table.setGlobalFilter('ali')
|
|
50
|
+
expect(names(table)).toEqual(['Alice'])
|
|
51
|
+
table.setGlobalFilter('a')
|
|
52
|
+
expect(names(table)).toEqual(['Charlie', 'Alice'])
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
it('paginates', () => {
|
|
56
|
+
const table = createTable({
|
|
57
|
+
data: DATA,
|
|
58
|
+
columns,
|
|
59
|
+
initialState: { pagination: { pageIndex: 0, pageSize: 2 } },
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
expect(names(table)).toEqual(['Charlie', 'Alice'])
|
|
63
|
+
table.nextPage()
|
|
64
|
+
expect(names(table)).toEqual(['Bob'])
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
it('syncs option updates through setOptions', () => {
|
|
68
|
+
const table = createTable({ data: DATA, columns })
|
|
69
|
+
table.setOptions((prev: any) => ({ ...prev, data: [{ name: 'Zed', n: 9 }] }))
|
|
70
|
+
expect(names(table)).toEqual(['Zed'])
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
it('honors controlled state slices via options.state', () => {
|
|
74
|
+
const table = createTable({
|
|
75
|
+
data: DATA,
|
|
76
|
+
columns,
|
|
77
|
+
state: { sorting: [{ id: 'n', desc: true }] },
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
expect(names(table)).toEqual(['Charlie', 'Bob', 'Alice'])
|
|
81
|
+
})
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
describe('stable selection ownership', () => {
|
|
85
|
+
it('selects only eligible filtered page IDs and keeps missing IDs until the owner clears', () => {
|
|
86
|
+
const data = [
|
|
87
|
+
{ id: 'a', name: 'Alice' },
|
|
88
|
+
{ id: 'b', name: 'Bob' },
|
|
89
|
+
{ id: 'c', name: 'Charlie' },
|
|
90
|
+
]
|
|
91
|
+
|
|
92
|
+
const table = createTable({
|
|
93
|
+
data,
|
|
94
|
+
columns: [{ accessorKey: 'name' }],
|
|
95
|
+
getRowId: (row) => row.id,
|
|
96
|
+
enableRowSelection: (row) => row.id !== 'b',
|
|
97
|
+
initialState: { rowSelection: { absent: true }, pagination: { pageIndex: 0, pageSize: 2 } },
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
table.toggleAllPageRowsSelected(true)
|
|
101
|
+
expect(table.store.get().rowSelection).toEqual({ absent: true, a: true })
|
|
102
|
+
table.setGlobalFilter('char')
|
|
103
|
+
table.toggleAllPageRowsSelected(true)
|
|
104
|
+
expect(table.store.get().rowSelection).toEqual({ absent: true, a: true, c: true })
|
|
105
|
+
table.toggleAllPageRowsSelected(false)
|
|
106
|
+
expect(table.store.get().rowSelection).toEqual({ absent: true, a: true })
|
|
107
|
+
table.setOptions((prev) => ({ ...prev, data: [{ id: 'a', name: 'Updated Alice' }] }))
|
|
108
|
+
table.setGlobalFilter('')
|
|
109
|
+
expect(table.getRowModel().rows[0].getIsSelected()).toBe(true)
|
|
110
|
+
expect(table.getSelectedRowModel().rows.map((row) => row.id)).toEqual(['a'])
|
|
111
|
+
table.resetRowSelection(true)
|
|
112
|
+
expect(table.store.get().rowSelection).toEqual({})
|
|
113
|
+
})
|
|
114
|
+
})
|
package/src/table.ts
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import {
|
|
2
|
+
aggregationFns,
|
|
3
|
+
columnFacetingFeature,
|
|
4
|
+
columnFilteringFeature,
|
|
5
|
+
columnGroupingFeature,
|
|
6
|
+
columnOrderingFeature,
|
|
7
|
+
columnPinningFeature,
|
|
8
|
+
columnSizingFeature,
|
|
9
|
+
columnVisibilityFeature,
|
|
10
|
+
constructTable,
|
|
11
|
+
createExpandedRowModel,
|
|
12
|
+
createFacetedMinMaxValues,
|
|
13
|
+
createFacetedRowModel,
|
|
14
|
+
createFacetedUniqueValues,
|
|
15
|
+
createFilteredRowModel,
|
|
16
|
+
createGroupedRowModel,
|
|
17
|
+
createPaginatedRowModel,
|
|
18
|
+
createSortedRowModel,
|
|
19
|
+
filterFns,
|
|
20
|
+
globalFilteringFeature,
|
|
21
|
+
rowAggregationFeature,
|
|
22
|
+
rowExpandingFeature,
|
|
23
|
+
rowPaginationFeature,
|
|
24
|
+
rowPinningFeature,
|
|
25
|
+
rowSelectionFeature,
|
|
26
|
+
rowSortingFeature,
|
|
27
|
+
sortFns,
|
|
28
|
+
tableFeatures,
|
|
29
|
+
} from '@tanstack/table-core'
|
|
30
|
+
|
|
31
|
+
import { storeReactivityBindings } from '@tanstack/table-core/store-reactivity-bindings'
|
|
32
|
+
import type { RowData, Table, TableFeatures } from '@tanstack/table-core'
|
|
33
|
+
import type { DataGridOptions } from './props'
|
|
34
|
+
|
|
35
|
+
/** DataGrid's default feature slots: every stock feature whose machinery is
|
|
36
|
+
* DOM-free — sorting, filtering, grouping, expanding, pagination, pinning,
|
|
37
|
+
* selection, column ordering/visibility/sizing, faceting, global filtering,
|
|
38
|
+
* aggregation — plus the row-model factories and builtin fn registries that
|
|
39
|
+
* v9 keeps as separate slots. Omitted: `columnResizingFeature` (its drag
|
|
40
|
+
* handler installs global event listeners — web-only; resize gesture UI
|
|
41
|
+
* belongs to platform leaves) and `cellSelectionFeature`/`cellSpanningFeature`
|
|
42
|
+
* (range-selection UX is web-spreadsheet-shaped, not a v1 xplat idiom). Pass
|
|
43
|
+
* `features` to add them where a platform leaf supports them. */
|
|
44
|
+
export const dataGridFeatures = tableFeatures({
|
|
45
|
+
columnFacetingFeature,
|
|
46
|
+
columnFilteringFeature,
|
|
47
|
+
columnGroupingFeature,
|
|
48
|
+
columnOrderingFeature,
|
|
49
|
+
columnPinningFeature,
|
|
50
|
+
columnSizingFeature,
|
|
51
|
+
columnVisibilityFeature,
|
|
52
|
+
globalFilteringFeature,
|
|
53
|
+
rowAggregationFeature,
|
|
54
|
+
rowExpandingFeature,
|
|
55
|
+
rowPaginationFeature,
|
|
56
|
+
rowPinningFeature,
|
|
57
|
+
rowSelectionFeature,
|
|
58
|
+
rowSortingFeature,
|
|
59
|
+
sortedRowModel: createSortedRowModel(),
|
|
60
|
+
filteredRowModel: createFilteredRowModel(),
|
|
61
|
+
groupedRowModel: createGroupedRowModel(),
|
|
62
|
+
expandedRowModel: createExpandedRowModel(),
|
|
63
|
+
paginatedRowModel: createPaginatedRowModel(),
|
|
64
|
+
facetedRowModel: createFacetedRowModel(),
|
|
65
|
+
facetedMinMaxValues: createFacetedMinMaxValues(),
|
|
66
|
+
facetedUniqueValues: createFacetedUniqueValues(),
|
|
67
|
+
sortFns,
|
|
68
|
+
filterFns,
|
|
69
|
+
aggregationFns,
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
export type DataGridFeatures = typeof dataGridFeatures
|
|
73
|
+
|
|
74
|
+
/** Construct a table instance bound to TanStack Store reactivity — the
|
|
75
|
+
* vanilla/non-framework binding (`table.optionsStore` subscribable, atoms
|
|
76
|
+
* from `@tanstack/store`, `queueMicrotask` scheduling — all DOM-free). Wrap
|
|
77
|
+
* with `useTable` inside a component; call directly for non-rendering
|
|
78
|
+
* consumers (tests, headless row models). */
|
|
79
|
+
export function createTable<
|
|
80
|
+
TData extends RowData,
|
|
81
|
+
TFeatures extends TableFeatures = DataGridFeatures,
|
|
82
|
+
>(options: DataGridOptions<TFeatures, TData>): Table<TFeatures, TData> {
|
|
83
|
+
return constructTable({
|
|
84
|
+
...(options as object),
|
|
85
|
+
features: {
|
|
86
|
+
coreReactivityFeature: storeReactivityBindings(),
|
|
87
|
+
...dataGridFeatures,
|
|
88
|
+
...options.features,
|
|
89
|
+
},
|
|
90
|
+
} as never) as Table<TFeatures, TData>
|
|
91
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { useCallback, useState, useSyncExternalStore } from 'octane'
|
|
2
|
+
import type { RowData, TableFeatures } from '@tanstack/table-core'
|
|
3
|
+
import { createTable, type DataGridFeatures } from './table'
|
|
4
|
+
import type { DataGridOptions, UseTable } from './props'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Create a table instance bound to component rendering. The instance is
|
|
8
|
+
* constructed once; each render syncs `data`/`columns`/`state`/etc. into the
|
|
9
|
+
* options store (feature slots and `initialState` are first-render only).
|
|
10
|
+
*
|
|
11
|
+
* Re-render triggers: any `TableState` slice change (sorting, selection,
|
|
12
|
+
* filters, pagination, ...) through `table.store`, plus ordinary prop-driven
|
|
13
|
+
* renders for `data`/`columns` changes. Read rows via `table.getRowModel()`
|
|
14
|
+
* — memoized per revision, so snapshot reads stay Object.is-stable.
|
|
15
|
+
*
|
|
16
|
+
* Controlled slices: pass `state` + `atoms` (external `@tanstack/store`
|
|
17
|
+
* atoms own the slice) or subscribe `table.atoms.<slice>` yourself.
|
|
18
|
+
*/
|
|
19
|
+
export function useTable<TData extends RowData, TFeatures extends TableFeatures = DataGridFeatures>(
|
|
20
|
+
options: DataGridOptions<TFeatures, TData>,
|
|
21
|
+
): UseTable<TFeatures, TData> {
|
|
22
|
+
const [{ table }] = useState(() => ({ table: createTable<TData, TFeatures>(options) }))
|
|
23
|
+
table.setOptions((prev) => ({ ...prev, ...options }) as never)
|
|
24
|
+
const subscribe = useCallback(
|
|
25
|
+
(notify: () => void) => {
|
|
26
|
+
const sub = table.store.subscribe(() => notify())
|
|
27
|
+
return () => sub.unsubscribe()
|
|
28
|
+
},
|
|
29
|
+
[table],
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
const state = useSyncExternalStore(subscribe, () => table.store.get())
|
|
33
|
+
return { table, state }
|
|
34
|
+
}
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { RowData, TableFeatures } from '@tanstack/table-core'
|
|
2
|
+
import type { DataGridFeatures } from './table.js'
|
|
3
|
+
import type { DataGridOptions, DataGridProps, UseTable } from './props.js'
|
|
4
|
+
|
|
5
|
+
/** Headless data grid — table-core row model rendered through shared
|
|
6
|
+
* VirtualList. */
|
|
7
|
+
export declare function DataGrid<TData extends RowData = any>(props: DataGridProps<TData>): unknown
|
|
8
|
+
|
|
9
|
+
/** Create a table instance bound to component rendering — re-renders on any
|
|
10
|
+
* TableState slice change; sync this render's `data`/`columns`/`state` into
|
|
11
|
+
* the options store each render. */
|
|
12
|
+
export declare function useTable<
|
|
13
|
+
TData extends RowData,
|
|
14
|
+
TFeatures extends TableFeatures = DataGridFeatures,
|
|
15
|
+
>(options: DataGridOptions<TFeatures, TData>): UseTable<TFeatures, TData>
|
|
16
|
+
|
|
17
|
+
export { createTable, dataGridFeatures } from './table.js'
|
|
18
|
+
export type { DataGridFeatures } from './table.js'
|
|
19
|
+
export type { DataGridOptions, DataGridProps, UseTable } from './props.js'
|
|
20
|
+
export type { Cell, ColumnDef, Header, Row, Table, TableState } from '@tanstack/table-core'
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { RowData, TableFeatures } from '@tanstack/table-core'
|
|
2
|
+
import type { DataGridFeatures } from './table.js'
|
|
3
|
+
import type { DataGridOptions, DataGridProps, UseTable } from './props.js'
|
|
4
|
+
|
|
5
|
+
/** Headless data grid — table-core row model rendered through shared
|
|
6
|
+
* VirtualList. */
|
|
7
|
+
export declare function DataGrid<TData extends RowData = any>(props: DataGridProps<TData>): unknown
|
|
8
|
+
|
|
9
|
+
export declare function useTable<
|
|
10
|
+
TData extends RowData,
|
|
11
|
+
TFeatures extends TableFeatures = DataGridFeatures,
|
|
12
|
+
>(options: DataGridOptions<TFeatures, TData>): UseTable<TFeatures, TData>
|
|
13
|
+
|
|
14
|
+
export { createTable, dataGridFeatures } from './table.js'
|
|
15
|
+
export type { DataGridFeatures } from './table.js'
|
|
16
|
+
export type { DataGridOptions, DataGridProps, UseTable } from './props.js'
|
|
17
|
+
export type { Cell, ColumnDef, Header, Row, Table, TableState } from '@tanstack/table-core'
|
package/types/props.d.ts
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type { Cell, ColumnDef, Header, Row, RowData, Table, TableFeatures, TableOptions, TableState } from '@tanstack/table-core';
|
|
2
|
+
import type { DataGridFeatures } from './table';
|
|
3
|
+
export interface LayoutChildProps {
|
|
4
|
+
row?: number;
|
|
5
|
+
col?: number;
|
|
6
|
+
rowSpan?: number;
|
|
7
|
+
colSpan?: number;
|
|
8
|
+
dock?: 'left' | 'top' | 'right' | 'bottom';
|
|
9
|
+
left?: number;
|
|
10
|
+
top?: number;
|
|
11
|
+
flexGrow?: number;
|
|
12
|
+
flexShrink?: number;
|
|
13
|
+
alignSelf?: string;
|
|
14
|
+
order?: number;
|
|
15
|
+
}
|
|
16
|
+
export interface AccessibilityProps {
|
|
17
|
+
accessible?: boolean;
|
|
18
|
+
accessibilityLabel?: string;
|
|
19
|
+
accessibilityHint?: string;
|
|
20
|
+
accessibilityRole?: string;
|
|
21
|
+
accessibilityState?: Record<string, any>;
|
|
22
|
+
testID?: string;
|
|
23
|
+
}
|
|
24
|
+
/** Options shared by `createTable`/`useTable`/`DataGrid`. Extends the
|
|
25
|
+
* table-core options for the enabled feature set minus its reactivity slot
|
|
26
|
+
* (owned by the adapter). */
|
|
27
|
+
export type DataGridOptions<TFeatures extends TableFeatures, TData extends RowData> = Omit<TableOptions<TFeatures, TData>, 'features' | 'coreReactivityFeature'> & {
|
|
28
|
+
/** Feature slots beyond the defaults — pass `tableFeatures({...})`
|
|
29
|
+
* output or merge onto `dataGridFeatures`. */
|
|
30
|
+
features?: Partial<TableFeatures>;
|
|
31
|
+
};
|
|
32
|
+
/** `useTable` return — the live table instance plus the flat reactive state.
|
|
33
|
+
* `state` re-reads on every slice change; row models come from
|
|
34
|
+
* `table.getRowModel()` (memoized per state/option revision). */
|
|
35
|
+
export interface UseTable<TFeatures extends TableFeatures, TData extends RowData> {
|
|
36
|
+
table: Table<TFeatures, TData>;
|
|
37
|
+
state: TableState<TFeatures>;
|
|
38
|
+
}
|
|
39
|
+
export interface DataGridProps<TData extends RowData = any, TFeatures extends TableFeatures = DataGridFeatures> extends LayoutChildProps, AccessibilityProps {
|
|
40
|
+
id?: string;
|
|
41
|
+
className?: any;
|
|
42
|
+
style?: any;
|
|
43
|
+
/** Row data — pass a new array reference when data changes. */
|
|
44
|
+
data: TData[];
|
|
45
|
+
columns: ColumnDef<TFeatures, TData, any>[];
|
|
46
|
+
/** Feature overrides merged onto the defaults (see `dataGridFeatures`). */
|
|
47
|
+
features?: Partial<TableFeatures>;
|
|
48
|
+
/** Core options (atoms, change callbacks, manual row models, selection
|
|
49
|
+
* predicates). Data/columns and the explicit props below take precedence. */
|
|
50
|
+
options?: Omit<DataGridOptions<TFeatures, TData>, 'data' | 'columns' | 'features' | 'state' | 'initialState' | 'getRowId'>;
|
|
51
|
+
/** Partial controlled state. Pair with options.atoms or per-slice
|
|
52
|
+
* options callbacks; a state snapshot alone is read-only. */
|
|
53
|
+
state?: Partial<TableState<TFeatures>>;
|
|
54
|
+
initialState?: Partial<TableState<TFeatures>>;
|
|
55
|
+
getRowId?: (row: TData, index: number) => string;
|
|
56
|
+
/** Per-cell content override. Defaults to the column's `cell` template,
|
|
57
|
+
* then `cell.getValue()`. */
|
|
58
|
+
renderCell?: (cell: Cell<TFeatures, TData, any>) => any;
|
|
59
|
+
/** Per-header content override. Defaults to the column's `header`
|
|
60
|
+
* template plus a sort affordance when the column can sort. */
|
|
61
|
+
renderHeader?: (header: Header<TFeatures, TData, any>) => any;
|
|
62
|
+
/** Row tap — marks rows pressable. */
|
|
63
|
+
onRowPress?: (row: Row<TFeatures, TData>) => void;
|
|
64
|
+
renderEmpty?: () => any;
|
|
65
|
+
/** Show a text query across globally filterable columns. */
|
|
66
|
+
showGlobalFilter?: boolean;
|
|
67
|
+
/** Show text filters beneath filterable leaf-column headings. */
|
|
68
|
+
showColumnFilters?: boolean;
|
|
69
|
+
/** Show previous/next and page-size controls. Client-side by default;
|
|
70
|
+
* use options.manualPagination with pageCount/rowCount for server data. */
|
|
71
|
+
showPagination?: boolean;
|
|
72
|
+
/** Positive integer page sizes offered by the pager. Defaults to [10, 25, 50]. */
|
|
73
|
+
pageSizeOptions?: readonly number[];
|
|
74
|
+
/** Show row checkboxes and a current-page select-all checkbox. Selection
|
|
75
|
+
* survives filtering/pagination by ID; provide getRowId for mutable data. */
|
|
76
|
+
showRowSelection?: boolean;
|
|
77
|
+
/** Optional label for each selection checkbox. */
|
|
78
|
+
getRowLabel?: (row: Row<TFeatures, TData>) => string;
|
|
79
|
+
/** Show a column visibility/order panel, reset to initial state, and
|
|
80
|
+
* keyboard/touch move buttons. Non-hideable columns stay visible. */
|
|
81
|
+
showColumnSettings?: boolean;
|
|
82
|
+
/** Fixed-width columns with pan resize handles and accessible +/- actions.
|
|
83
|
+
* Widths use column minSize/maxSize; cancellation restores prior state. */
|
|
84
|
+
resizableColumns?: boolean;
|
|
85
|
+
/** Separate pan handles reorder leaf columns on release. Cancel preserves
|
|
86
|
+
* order; settings move buttons provide a non-drag alternative. */
|
|
87
|
+
reorderableColumns?: boolean;
|
|
88
|
+
/** Horizontal gesture direction. Defaults to ltr; use rtl for mirrored layouts. */
|
|
89
|
+
direction?: 'ltr' | 'rtl';
|
|
90
|
+
/** Caller-owned bulk actions; selected IDs include off-page selections. */
|
|
91
|
+
renderSelectionActions?: (table: Table<TFeatures, TData>) => any;
|
|
92
|
+
/** Platform escape bags — applied after shared props on the root view. */
|
|
93
|
+
ios?: Record<string, any>;
|
|
94
|
+
android?: Record<string, any>;
|
|
95
|
+
web?: Record<string, any>;
|
|
96
|
+
}
|
package/types/table.d.ts
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { RowData, Table, TableFeatures } from '@tanstack/table-core';
|
|
2
|
+
import type { DataGridOptions } from './props';
|
|
3
|
+
/** DataGrid's default feature slots: every stock feature whose machinery is
|
|
4
|
+
* DOM-free — sorting, filtering, grouping, expanding, pagination, pinning,
|
|
5
|
+
* selection, column ordering/visibility/sizing, faceting, global filtering,
|
|
6
|
+
* aggregation — plus the row-model factories and builtin fn registries that
|
|
7
|
+
* v9 keeps as separate slots. Omitted: `columnResizingFeature` (its drag
|
|
8
|
+
* handler installs global event listeners — web-only; resize gesture UI
|
|
9
|
+
* belongs to platform leaves) and `cellSelectionFeature`/`cellSpanningFeature`
|
|
10
|
+
* (range-selection UX is web-spreadsheet-shaped, not a v1 xplat idiom). Pass
|
|
11
|
+
* `features` to add them where a platform leaf supports them. */
|
|
12
|
+
export declare const dataGridFeatures: {
|
|
13
|
+
columnFacetingFeature: import("@tanstack/table-core").TableFeature;
|
|
14
|
+
columnFilteringFeature: import("@tanstack/table-core").TableFeature;
|
|
15
|
+
columnGroupingFeature: import("@tanstack/table-core").TableFeature;
|
|
16
|
+
columnOrderingFeature: import("@tanstack/table-core").TableFeature;
|
|
17
|
+
columnPinningFeature: import("@tanstack/table-core").TableFeature;
|
|
18
|
+
columnSizingFeature: import("@tanstack/table-core").TableFeature;
|
|
19
|
+
columnVisibilityFeature: import("@tanstack/table-core").TableFeature;
|
|
20
|
+
globalFilteringFeature: import("@tanstack/table-core").TableFeature;
|
|
21
|
+
rowAggregationFeature: import("@tanstack/table-core").TableFeature;
|
|
22
|
+
rowExpandingFeature: import("@tanstack/table-core").TableFeature;
|
|
23
|
+
rowPaginationFeature: import("@tanstack/table-core").TableFeature;
|
|
24
|
+
rowPinningFeature: import("@tanstack/table-core").TableFeature;
|
|
25
|
+
rowSelectionFeature: import("@tanstack/table-core").TableFeature;
|
|
26
|
+
rowSortingFeature: import("@tanstack/table-core").TableFeature;
|
|
27
|
+
sortedRowModel: (table: Table<any, any>) => () => import("@tanstack/table-core").RowModel<any, any>;
|
|
28
|
+
filteredRowModel: (table: Table<any, any>) => () => import("@tanstack/table-core").RowModel<any, any>;
|
|
29
|
+
groupedRowModel: (table: Table<any, any>) => () => import("@tanstack/table-core").RowModel<any, any>;
|
|
30
|
+
expandedRowModel: (table: Table<any, any>) => () => import("@tanstack/table-core").RowModel<any, any>;
|
|
31
|
+
paginatedRowModel: (table: Table<any, any>) => () => import("@tanstack/table-core").RowModel<any, any>;
|
|
32
|
+
facetedRowModel: (table: Table<any, any>, columnId: string) => () => import("@tanstack/table-core").RowModel<any, any>;
|
|
33
|
+
facetedMinMaxValues: (table: Table<TableFeatures, any>, columnId: string) => () => undefined | [number, number];
|
|
34
|
+
facetedUniqueValues: (table: Table<TableFeatures, any>, columnId: string) => () => Map<any, number>;
|
|
35
|
+
sortFns: {
|
|
36
|
+
alphanumeric: import("@tanstack/table-core").CreatedSortFn<any, any>;
|
|
37
|
+
alphanumericCaseSensitive: import("@tanstack/table-core").CreatedSortFn<any, any>;
|
|
38
|
+
basic: import("@tanstack/table-core").CreatedSortFn<any, any>;
|
|
39
|
+
datetime: import("@tanstack/table-core").CreatedSortFn<any, any>;
|
|
40
|
+
text: import("@tanstack/table-core").CreatedSortFn<any, any>;
|
|
41
|
+
textCaseSensitive: import("@tanstack/table-core").CreatedSortFn<any, any>;
|
|
42
|
+
};
|
|
43
|
+
filterFns: {
|
|
44
|
+
arrIncludes: import("@tanstack/table-core").CreatedFilterFn<any, any>;
|
|
45
|
+
arrIncludesAll: import("@tanstack/table-core").CreatedFilterFn<any, any>;
|
|
46
|
+
arrHas: import("@tanstack/table-core").CreatedFilterFn<any, any>;
|
|
47
|
+
arrIncludesSome: import("@tanstack/table-core").CreatedFilterFn<any, any>;
|
|
48
|
+
between: import("@tanstack/table-core").CreatedFilterFn<any, any>;
|
|
49
|
+
betweenInclusive: import("@tanstack/table-core").CreatedFilterFn<any, any>;
|
|
50
|
+
empty: import("@tanstack/table-core").CreatedFilterFn<any, any>;
|
|
51
|
+
endsWith: import("@tanstack/table-core").CreatedFilterFn<any, any>;
|
|
52
|
+
equals: import("@tanstack/table-core").CreatedFilterFn<any, any>;
|
|
53
|
+
equalsString: import("@tanstack/table-core").CreatedFilterFn<any, any>;
|
|
54
|
+
equalsStringSensitive: import("@tanstack/table-core").CreatedFilterFn<any, any>;
|
|
55
|
+
inDateRange: import("@tanstack/table-core").CreatedFilterFn<any, any>;
|
|
56
|
+
inNumberRange: import("@tanstack/table-core").CreatedFilterFn<any, any>;
|
|
57
|
+
includesString: import("@tanstack/table-core").CreatedFilterFn<any, any>;
|
|
58
|
+
includesStringSensitive: import("@tanstack/table-core").CreatedFilterFn<any, any>;
|
|
59
|
+
notEmpty: import("@tanstack/table-core").CreatedFilterFn<any, any>;
|
|
60
|
+
startsWith: import("@tanstack/table-core").CreatedFilterFn<any, any>;
|
|
61
|
+
weakEquals: import("@tanstack/table-core").CreatedFilterFn<any, any>;
|
|
62
|
+
};
|
|
63
|
+
aggregationFns: {
|
|
64
|
+
sum: import("@tanstack/table-core").AggregationFnDef<any, any, unknown, number>;
|
|
65
|
+
min: import("@tanstack/table-core").AggregationFnDef<any, any, unknown, (number | Date) | undefined>;
|
|
66
|
+
max: import("@tanstack/table-core").AggregationFnDef<any, any, unknown, (number | Date) | undefined>;
|
|
67
|
+
extent: import("@tanstack/table-core").AggregationFnDef<any, any, unknown, [(number | Date) | undefined, (number | Date) | undefined]>;
|
|
68
|
+
mean: import("@tanstack/table-core").AggregationFnDef<any, any, unknown, number | undefined>;
|
|
69
|
+
median: import("@tanstack/table-core").AggregationFnDef<any, any, unknown, number | undefined>;
|
|
70
|
+
unique: import("@tanstack/table-core").AggregationFnDef<any, any, unknown, unknown[]>;
|
|
71
|
+
uniqueCount: import("@tanstack/table-core").AggregationFnDef<any, any, unknown, number>;
|
|
72
|
+
count: import("@tanstack/table-core").AggregationFnDef<any, any, unknown, number>;
|
|
73
|
+
first: import("@tanstack/table-core").AggregationFnDef<any, any, unknown, unknown>;
|
|
74
|
+
last: import("@tanstack/table-core").AggregationFnDef<any, any, unknown, unknown>;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
export type DataGridFeatures = typeof dataGridFeatures;
|
|
78
|
+
/** Construct a table instance bound to TanStack Store reactivity — the
|
|
79
|
+
* vanilla/non-framework binding (`table.optionsStore` subscribable, atoms
|
|
80
|
+
* from `@tanstack/store`, `queueMicrotask` scheduling — all DOM-free). Wrap
|
|
81
|
+
* with `useTable` inside a component; call directly for non-rendering
|
|
82
|
+
* consumers (tests, headless row models). */
|
|
83
|
+
export declare function createTable<TData extends RowData, TFeatures extends TableFeatures = DataGridFeatures>(options: DataGridOptions<TFeatures, TData>): Table<TFeatures, TData>;
|