@jielga/tmdatagrid 0.1.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.
@@ -0,0 +1,592 @@
1
+ import * as react from 'react';
2
+ import { ReactNode, CSSProperties } from 'react';
3
+ import { TableFeatures, RowData, Row, TableState, Column, Table, TableOptions, ColumnPinningState } from '@tanstack/react-table';
4
+ import { MantineSize } from '@mantine/core';
5
+ import * as _tanstack_table_core from '@tanstack/table-core';
6
+ import { Store } from '@tanstack/store';
7
+
8
+ /**
9
+ * The "Manage columns" surface. Reachable from every column header menu and
10
+ * from the grid's burger menu, so it lives on its own and is rendered by
11
+ * `TMDataGrid.ColumnsButton`.
12
+ */
13
+ declare function TMDataGridColumnsPanel(): react.JSX.Element;
14
+
15
+ /**
16
+ * The MUI-style filter surface: one row per active column filter, each row a
17
+ * column / operator / value triple. It only ever reads and writes the table's
18
+ * `columnFilters` state, so a `manualFiltering` grid gets the same panel for
19
+ * free — the state is forwarded to the server instead of a row model.
20
+ */
21
+ declare function TMDataGridFilterPanel(): react.JSX.Element | null;
22
+
23
+ type TMDataGridFooterProps = {
24
+ pageSizeOptions?: ReadonlyArray<number>;
25
+ };
26
+ /**
27
+ * MUI-style pager: "Rows per page · from–to of total · ‹ ›".
28
+ *
29
+ * Row totals come from `table.getRowCount()`, which prefers `options.rowCount`
30
+ * — so a server-paged grid shows the server's total without changes here.
31
+ */
32
+ declare function TMDataGridFooter({ pageSizeOptions, }: TMDataGridFooterProps): react.JSX.Element;
33
+
34
+ type TMDataGridSize = MantineSize;
35
+ declare const DEFAULT_TMDATAGRID_SIZE: TMDataGridSize;
36
+ /**
37
+ * Row height per size, in px.
38
+ *
39
+ * The virtualizer needs this as a number — it cannot read the CSS variable —
40
+ * so the scale lives here and `TMDataGrid.module.css` mirrors it. `meta.rowHeight`
41
+ * overrides it when a grid needs a height the scale doesn't offer.
42
+ */
43
+ declare const SIZE_ROW_HEIGHT: Record<TMDataGridSize, number>;
44
+ /** Size of the Mantine controls rendered inside the grid chrome. */
45
+ declare const SIZE_CONTROL_SIZE: Record<TMDataGridSize, MantineSize>;
46
+
47
+ /**
48
+ * The value shape stored in `columnFilters` for every TMDataGrid column.
49
+ *
50
+ * TanStack resolves `filterFn` statically per column, so the operator travels
51
+ * inside the filter *value* instead. That keeps the whole filter model plain,
52
+ * serialisable JSON — which is what makes it portable to a server-side
53
+ * `manualFiltering` table (just forward `columnFilters` to the API).
54
+ */
55
+ type TMDataGridFilterValue = {
56
+ operator: TMDataGridFilterOperator;
57
+ value: string;
58
+ };
59
+ type TMDataGridColumnType = "string" | "number";
60
+ type TMDataGridFilterOperator = "contains" | "equals" | "notEquals" | "startsWith" | "endsWith" | "greaterThan" | "greaterThanOrEqual" | "lessThan" | "lessThanOrEqual" | "isEmpty" | "isNotEmpty";
61
+ declare const FILTER_OPERATOR_LABELS: Record<TMDataGridFilterOperator, string>;
62
+ /**
63
+ * A filter only narrows the row set once it has something to compare against.
64
+ * Half-typed filters stay in state (so the panel keeps rendering their row) but
65
+ * are treated as inactive for the funnel indicator and for row matching.
66
+ */
67
+ declare function isFilterActive(value: unknown): boolean;
68
+ /**
69
+ * The single filter function every TMDataGrid column uses. It dispatches on the
70
+ * operator carried by the filter value, which is what lets one column offer
71
+ * "contains" / "does not equal" / "is empty" without redefining the column.
72
+ */
73
+ declare function tmDataGridFilterFn<TFeatures extends TableFeatures, TData extends RowData>(row: Row<TFeatures, TData>, columnId: string, filterValue: unknown): boolean;
74
+
75
+ type GridState = TableState<TMDataGridFeatures>;
76
+ /**
77
+ * Persistence deliberately does not use Mantine's `useLocalStorage`.
78
+ *
79
+ * That hook owns a piece of state and returns `[value, setValue]`. Here the
80
+ * table already owns the state and storage only mirrors it, so routing writes
81
+ * through the hook would keep a second copy and trigger a React state update on
82
+ * every change, including every pointer move during a column resize. Its
83
+ * defaults also work against this use: `getInitialValueInEffect: true` delivers
84
+ * the stored value after mount, while `initialState` is only read on the first
85
+ * render, and `sync: true` would let two open tabs overwrite each other's
86
+ * column layout.
87
+ *
88
+ * The option vocabulary follows Mantine's: `StorageType` is its type, and
89
+ * `serialize` / `deserialize` behave as they do in `UseStorageOptions`.
90
+ */
91
+ /**
92
+ * State slices describing what the user is looking at. Derived from the data,
93
+ * so they can go stale as it changes.
94
+ */
95
+ declare const DATA_STATE_SLICES: readonly ["columnFilters", "globalFilter", "sorting", "pagination"];
96
+ /**
97
+ * State slices describing how the user configured the grid. Independent of the
98
+ * data, and the ones users notice losing.
99
+ */
100
+ declare const SETTINGS_STATE_SLICES: readonly ["columnVisibility", "columnSizing", "columnOrder", "columnPinning"];
101
+ type TMDataGridDataSlice = (typeof DATA_STATE_SLICES)[number];
102
+ type TMDataGridSettingsSlice = (typeof SETTINGS_STATE_SLICES)[number];
103
+ /**
104
+ * A storage key, optionally narrowed to a subset of its group's slices.
105
+ *
106
+ * - `"employees.data"` — persists every slice in the group.
107
+ * - `["employees.data", ["sorting"]]` — persists only the listed slices.
108
+ */
109
+ type TMDataGridPersistKey<TSlice extends string> = string | readonly [key: string, slices: readonly TSlice[]];
110
+ /** Same values as Mantine's `StorageType`, which the package does not re-export. */
111
+ type TMDataGridStorageMode = "localStorage" | "sessionStorage";
112
+ type TMDataGridPersistence = {
113
+ /** Key for filters, global filter, sorting and pagination. */
114
+ dataKey?: TMDataGridPersistKey<TMDataGridDataSlice>;
115
+ /** Key for column visibility, sizing, order and pinning. */
116
+ settingsKey?: TMDataGridPersistKey<TMDataGridSettingsSlice>;
117
+ /** Which storage area to use. Defaults to `"localStorage"`. */
118
+ storageMode?: TMDataGridStorageMode;
119
+ /** Serializes a payload before it is stored. Defaults to `JSON.stringify`. */
120
+ serialize?: (value: Partial<GridState>) => string;
121
+ /** Parses a stored payload. Defaults to `JSON.parse`. */
122
+ deserialize?: (value: string) => unknown;
123
+ };
124
+
125
+ /**
126
+ * Table-level feature switches, read straight off the options object.
127
+ *
128
+ * Why not just call `column.getCanSort()` everywhere? Because that is a method
129
+ * call on a `column` whose identity survives an options change, so the React
130
+ * Compiler caches the result and the chrome keeps rendering for a feature that
131
+ * was switched off. Reading the options into a fresh object each render gives
132
+ * every derived value something that actually changes to invalidate on.
133
+ *
134
+ * TanStack still decides: these flags are combined with `getCanX()`, which is
135
+ * what applies the per-column overrides.
136
+ */
137
+ type TMDataGridFeatureFlags = {
138
+ sorting: boolean;
139
+ filtering: boolean;
140
+ hiding: boolean;
141
+ pinning: boolean;
142
+ resizing: boolean;
143
+ ordering: boolean;
144
+ rowSelection: boolean;
145
+ };
146
+ declare function readFeatureFlags<TData extends RowData>(options: Pick<UseTMDataGridOptions<TData>, "enableSorting" | "enableColumnFilters" | "enableHiding" | "enableColumnPinning" | "enableColumnResizing" | "enableColumnOrdering" | "enableRowSelection">): TMDataGridFeatureFlags;
147
+ /**
148
+ * What one column's header may offer.
149
+ *
150
+ * | Affordance | Turned off by |
151
+ * | ---------- | ------------- |
152
+ * | Sort arrow, Sort ASC/DESC | `enableSorting` (table or column) |
153
+ * | Filter item, panel entry | `enableColumnFilters` / `enableColumnFilter` |
154
+ * | Hide column | `enableHiding` (table or column) |
155
+ * | Pin to left / right | `enableColumnPinning` / `enablePinning` |
156
+ * | Resize dragging | `enableColumnResizing` / `enableResizing` |
157
+ * | Header dragging, Move left / right | `enableColumnOrdering` / `meta.enableOrdering` |
158
+ */
159
+ type TMDataGridColumnCapabilities = {
160
+ canSort: boolean;
161
+ canFilter: boolean;
162
+ canHide: boolean;
163
+ canPin: boolean;
164
+ canResize: boolean;
165
+ canReorder: boolean;
166
+ };
167
+ declare function getColumnCapabilities(column: Column<TMDataGridFeatures, TMDataGridRowData, unknown>, features: TMDataGridFeatureFlags): TMDataGridColumnCapabilities;
168
+ /** The same questions, asked of the whole grid — used to hide toolbar buttons. */
169
+ type TMDataGridCapabilities = {
170
+ canSortAny: boolean;
171
+ canFilterAny: boolean;
172
+ canHideAny: boolean;
173
+ canPinAny: boolean;
174
+ canReorderAny: boolean;
175
+ canSelectRows: boolean;
176
+ };
177
+ declare function getGridCapabilities(table: TMDataGridTable$1<TMDataGridRowData>, features: TMDataGridFeatureFlags): TMDataGridCapabilities;
178
+
179
+ declare const SELECT_COLUMN_ID = "__select__";
180
+ /** Per-column configuration the TMDataGrid chrome reads. */
181
+ type TMDataGridColumnMeta = {
182
+ /** Name shown in menus and the column manager. Falls back to a string header. */
183
+ label?: string;
184
+ /** Drives which filter operators are offered. Defaults to `"string"`. */
185
+ type?: TMDataGridColumnType;
186
+ /** Share of the leftover width this column claims. Defaults to `1`. */
187
+ flex?: number;
188
+ align?: "left" | "right" | "center";
189
+ /**
190
+ * `false` keeps the column where it is: no header dragging, no move items.
191
+ * Column ordering is the one feature TanStack defines no column option for,
192
+ * so its switch lives here rather than on the column definition.
193
+ */
194
+ enableOrdering?: boolean;
195
+ };
196
+ /** Grid-wide configuration passed through `options.meta`. */
197
+ type TMDataGridTableMeta = {
198
+ loading?: boolean;
199
+ noResultsLabel?: string;
200
+ /** Row height used by the virtualizer. Defaults to `52`. */
201
+ rowHeight?: number;
202
+ /**
203
+ * Unfiltered row total. Only needed for server-driven grids, where the client
204
+ * never holds the full data set — `TMDataGrid.SummaryCount` uses it as denominator.
205
+ */
206
+ totalRowCount?: number;
207
+ };
208
+ /**
209
+ * Every feature the TMDataGrid chrome can drive. Defined at module scope so the
210
+ * reference stays stable across renders (see the TanStack table-state skill).
211
+ */
212
+ declare const tmDataGridFeatures: {
213
+ columnFilteringFeature: _tanstack_table_core.TableFeature;
214
+ globalFilteringFeature: _tanstack_table_core.TableFeature;
215
+ rowSortingFeature: _tanstack_table_core.TableFeature;
216
+ rowPaginationFeature: _tanstack_table_core.TableFeature;
217
+ rowSelectionFeature: _tanstack_table_core.TableFeature;
218
+ columnPinningFeature: _tanstack_table_core.TableFeature;
219
+ columnVisibilityFeature: _tanstack_table_core.TableFeature;
220
+ columnOrderingFeature: _tanstack_table_core.TableFeature;
221
+ columnSizingFeature: _tanstack_table_core.TableFeature;
222
+ columnResizingFeature: _tanstack_table_core.TableFeature;
223
+ columnFacetingFeature: _tanstack_table_core.TableFeature;
224
+ filteredRowModel: (table: Table<any, any>) => () => _tanstack_table_core.RowModel<any, any>;
225
+ sortedRowModel: (table: Table<any, any>) => () => _tanstack_table_core.RowModel<any, any>;
226
+ paginatedRowModel: (table: Table<any, any>) => () => _tanstack_table_core.RowModel<any, any>;
227
+ facetedRowModel: (table: Table<any, any>, columnId: string) => () => _tanstack_table_core.RowModel<any, any>;
228
+ facetedMinMaxValues: (table: Table<_tanstack_table_core.TableFeatures, any>, columnId: string) => () => undefined | [number, number];
229
+ facetedUniqueValues: (table: Table<_tanstack_table_core.TableFeatures, any>, columnId: string) => () => Map<any, number>;
230
+ filterFns: {
231
+ tmDataGrid: typeof tmDataGridFilterFn;
232
+ arrIncludes: (<TFeatures extends _tanstack_table_core.TableFeatures, TData extends RowData>(row: _tanstack_table_core.Row<TFeatures, TData>, columnId: string, filterValue: Array<unknown>) => boolean) & {
233
+ autoRemove: (val: any) => boolean;
234
+ };
235
+ arrIncludesAll: (<TFeatures extends _tanstack_table_core.TableFeatures, TData extends RowData>(row: _tanstack_table_core.Row<TFeatures, TData>, columnId: string, filterValue: Array<unknown>) => boolean) & {
236
+ autoRemove: (val: any) => boolean;
237
+ };
238
+ arrHas: <TFeatures extends _tanstack_table_core.TableFeatures, TData extends RowData>(row: _tanstack_table_core.Row<TFeatures, TData>, columnId: string, filterValue: Array<unknown>) => boolean;
239
+ arrIncludesSome: (<TFeatures extends _tanstack_table_core.TableFeatures, TData extends RowData>(row: _tanstack_table_core.Row<TFeatures, TData>, columnId: string, filterValue: Array<unknown>) => boolean) & {
240
+ autoRemove: (val: any) => boolean;
241
+ };
242
+ between: (<TFeatures extends _tanstack_table_core.TableFeatures, TData extends RowData>(row: _tanstack_table_core.Row<TFeatures, TData>, columnId: string, filterValues: [unknown, unknown]) => boolean) & {
243
+ autoRemove: (val: any) => boolean;
244
+ };
245
+ betweenInclusive: (<TFeatures extends _tanstack_table_core.TableFeatures, TData extends RowData>(row: _tanstack_table_core.Row<TFeatures, TData>, columnId: string, filterValues: [unknown, unknown]) => boolean) & {
246
+ autoRemove: (val: any) => boolean;
247
+ };
248
+ equals: (<TFeatures extends _tanstack_table_core.TableFeatures, TData extends RowData>(row: _tanstack_table_core.Row<TFeatures, TData>, columnId: string, filterValue: unknown) => boolean) & {
249
+ autoRemove: (val: any) => boolean;
250
+ };
251
+ equalsString: (<TFeatures extends _tanstack_table_core.TableFeatures, TData extends RowData>(row: _tanstack_table_core.Row<TFeatures, TData>, columnId: string, filterValue: unknown) => boolean) & {
252
+ autoRemove: (val: any) => boolean;
253
+ };
254
+ inNumberRange: (<TFeatures extends _tanstack_table_core.TableFeatures, TData extends RowData>(row: _tanstack_table_core.Row<TFeatures, TData>, columnId: string, filterValue: [number, number]) => boolean) & {
255
+ resolveFilterValue: (val: [any, any]) => readonly [number, number];
256
+ autoRemove: (val: any) => boolean;
257
+ };
258
+ includesString: (<TFeatures extends _tanstack_table_core.TableFeatures, TData extends RowData>(row: _tanstack_table_core.Row<TFeatures, TData>, columnId: string, filterValue: unknown) => boolean) & {
259
+ autoRemove: (val: any) => boolean;
260
+ };
261
+ includesStringSensitive: (<TFeatures extends _tanstack_table_core.TableFeatures, TData extends RowData>(row: _tanstack_table_core.Row<TFeatures, TData>, columnId: string, filterValue: unknown) => boolean) & {
262
+ autoRemove: (val: any) => boolean;
263
+ };
264
+ weakEquals: (<TFeatures extends _tanstack_table_core.TableFeatures, TData extends RowData>(row: _tanstack_table_core.Row<TFeatures, TData>, columnId: string, filterValue: unknown) => boolean) & {
265
+ autoRemove: (val: any) => boolean;
266
+ };
267
+ };
268
+ sortFns: {
269
+ alphanumeric: <TFeatures extends _tanstack_table_core.TableFeatures, TData extends RowData>(rowA: _tanstack_table_core.Row<TFeatures, TData>, rowB: _tanstack_table_core.Row<TFeatures, TData>, columnId: string) => number;
270
+ alphanumericCaseSensitive: <TFeatures extends _tanstack_table_core.TableFeatures, TData extends RowData>(rowA: _tanstack_table_core.Row<TFeatures, TData>, rowB: _tanstack_table_core.Row<TFeatures, TData>, columnId: string) => number;
271
+ basic: <TFeatures extends _tanstack_table_core.TableFeatures, TData extends RowData>(rowA: _tanstack_table_core.Row<TFeatures, TData>, rowB: _tanstack_table_core.Row<TFeatures, TData>, columnId: string) => 0 | 1 | -1;
272
+ datetime: <TFeatures extends _tanstack_table_core.TableFeatures, TData extends RowData>(rowA: _tanstack_table_core.Row<TFeatures, TData>, rowB: _tanstack_table_core.Row<TFeatures, TData>, columnId: string) => 0 | 1 | -1;
273
+ text: <TFeatures extends _tanstack_table_core.TableFeatures, TData extends RowData>(rowA: _tanstack_table_core.Row<TFeatures, TData>, rowB: _tanstack_table_core.Row<TFeatures, TData>, columnId: string) => 0 | 1 | -1;
274
+ textCaseSensitive: <TFeatures extends _tanstack_table_core.TableFeatures, TData extends RowData>(rowA: _tanstack_table_core.Row<TFeatures, TData>, rowB: _tanstack_table_core.Row<TFeatures, TData>, columnId: string) => 0 | 1 | -1;
275
+ };
276
+ tableMeta: TMDataGridTableMeta;
277
+ columnMeta: TMDataGridColumnMeta;
278
+ };
279
+ type TMDataGridFeatures = typeof tmDataGridFeatures;
280
+ type TMDataGridTable$1<TData extends RowData> = Table<TMDataGridFeatures, TData>;
281
+ declare function createTMDataGridColumnHelper<TData extends RowData>(): _tanstack_table_core.ColumnHelper<{
282
+ columnFilteringFeature: _tanstack_table_core.TableFeature;
283
+ globalFilteringFeature: _tanstack_table_core.TableFeature;
284
+ rowSortingFeature: _tanstack_table_core.TableFeature;
285
+ rowPaginationFeature: _tanstack_table_core.TableFeature;
286
+ rowSelectionFeature: _tanstack_table_core.TableFeature;
287
+ columnPinningFeature: _tanstack_table_core.TableFeature;
288
+ columnVisibilityFeature: _tanstack_table_core.TableFeature;
289
+ columnOrderingFeature: _tanstack_table_core.TableFeature;
290
+ columnSizingFeature: _tanstack_table_core.TableFeature;
291
+ columnResizingFeature: _tanstack_table_core.TableFeature;
292
+ columnFacetingFeature: _tanstack_table_core.TableFeature;
293
+ filteredRowModel: (table: Table<any, any>) => () => _tanstack_table_core.RowModel<any, any>;
294
+ sortedRowModel: (table: Table<any, any>) => () => _tanstack_table_core.RowModel<any, any>;
295
+ paginatedRowModel: (table: Table<any, any>) => () => _tanstack_table_core.RowModel<any, any>;
296
+ facetedRowModel: (table: Table<any, any>, columnId: string) => () => _tanstack_table_core.RowModel<any, any>;
297
+ facetedMinMaxValues: (table: Table<_tanstack_table_core.TableFeatures, any>, columnId: string) => () => undefined | [number, number];
298
+ facetedUniqueValues: (table: Table<_tanstack_table_core.TableFeatures, any>, columnId: string) => () => Map<any, number>;
299
+ filterFns: {
300
+ tmDataGrid: typeof tmDataGridFilterFn;
301
+ arrIncludes: (<TFeatures extends _tanstack_table_core.TableFeatures, TData_1 extends RowData>(row: _tanstack_table_core.Row<TFeatures, TData_1>, columnId: string, filterValue: Array<unknown>) => boolean) & {
302
+ autoRemove: (val: any) => boolean;
303
+ };
304
+ arrIncludesAll: (<TFeatures extends _tanstack_table_core.TableFeatures, TData_1 extends RowData>(row: _tanstack_table_core.Row<TFeatures, TData_1>, columnId: string, filterValue: Array<unknown>) => boolean) & {
305
+ autoRemove: (val: any) => boolean;
306
+ };
307
+ arrHas: <TFeatures extends _tanstack_table_core.TableFeatures, TData_1 extends RowData>(row: _tanstack_table_core.Row<TFeatures, TData_1>, columnId: string, filterValue: Array<unknown>) => boolean;
308
+ arrIncludesSome: (<TFeatures extends _tanstack_table_core.TableFeatures, TData_1 extends RowData>(row: _tanstack_table_core.Row<TFeatures, TData_1>, columnId: string, filterValue: Array<unknown>) => boolean) & {
309
+ autoRemove: (val: any) => boolean;
310
+ };
311
+ between: (<TFeatures extends _tanstack_table_core.TableFeatures, TData_1 extends RowData>(row: _tanstack_table_core.Row<TFeatures, TData_1>, columnId: string, filterValues: [unknown, unknown]) => boolean) & {
312
+ autoRemove: (val: any) => boolean;
313
+ };
314
+ betweenInclusive: (<TFeatures extends _tanstack_table_core.TableFeatures, TData_1 extends RowData>(row: _tanstack_table_core.Row<TFeatures, TData_1>, columnId: string, filterValues: [unknown, unknown]) => boolean) & {
315
+ autoRemove: (val: any) => boolean;
316
+ };
317
+ equals: (<TFeatures extends _tanstack_table_core.TableFeatures, TData_1 extends RowData>(row: _tanstack_table_core.Row<TFeatures, TData_1>, columnId: string, filterValue: unknown) => boolean) & {
318
+ autoRemove: (val: any) => boolean;
319
+ };
320
+ equalsString: (<TFeatures extends _tanstack_table_core.TableFeatures, TData_1 extends RowData>(row: _tanstack_table_core.Row<TFeatures, TData_1>, columnId: string, filterValue: unknown) => boolean) & {
321
+ autoRemove: (val: any) => boolean;
322
+ };
323
+ inNumberRange: (<TFeatures extends _tanstack_table_core.TableFeatures, TData_1 extends RowData>(row: _tanstack_table_core.Row<TFeatures, TData_1>, columnId: string, filterValue: [number, number]) => boolean) & {
324
+ resolveFilterValue: (val: [any, any]) => readonly [number, number];
325
+ autoRemove: (val: any) => boolean;
326
+ };
327
+ includesString: (<TFeatures extends _tanstack_table_core.TableFeatures, TData_1 extends RowData>(row: _tanstack_table_core.Row<TFeatures, TData_1>, columnId: string, filterValue: unknown) => boolean) & {
328
+ autoRemove: (val: any) => boolean;
329
+ };
330
+ includesStringSensitive: (<TFeatures extends _tanstack_table_core.TableFeatures, TData_1 extends RowData>(row: _tanstack_table_core.Row<TFeatures, TData_1>, columnId: string, filterValue: unknown) => boolean) & {
331
+ autoRemove: (val: any) => boolean;
332
+ };
333
+ weakEquals: (<TFeatures extends _tanstack_table_core.TableFeatures, TData_1 extends RowData>(row: _tanstack_table_core.Row<TFeatures, TData_1>, columnId: string, filterValue: unknown) => boolean) & {
334
+ autoRemove: (val: any) => boolean;
335
+ };
336
+ };
337
+ sortFns: {
338
+ alphanumeric: <TFeatures extends _tanstack_table_core.TableFeatures, TData_1 extends RowData>(rowA: _tanstack_table_core.Row<TFeatures, TData_1>, rowB: _tanstack_table_core.Row<TFeatures, TData_1>, columnId: string) => number;
339
+ alphanumericCaseSensitive: <TFeatures extends _tanstack_table_core.TableFeatures, TData_1 extends RowData>(rowA: _tanstack_table_core.Row<TFeatures, TData_1>, rowB: _tanstack_table_core.Row<TFeatures, TData_1>, columnId: string) => number;
340
+ basic: <TFeatures extends _tanstack_table_core.TableFeatures, TData_1 extends RowData>(rowA: _tanstack_table_core.Row<TFeatures, TData_1>, rowB: _tanstack_table_core.Row<TFeatures, TData_1>, columnId: string) => 0 | 1 | -1;
341
+ datetime: <TFeatures extends _tanstack_table_core.TableFeatures, TData_1 extends RowData>(rowA: _tanstack_table_core.Row<TFeatures, TData_1>, rowB: _tanstack_table_core.Row<TFeatures, TData_1>, columnId: string) => 0 | 1 | -1;
342
+ text: <TFeatures extends _tanstack_table_core.TableFeatures, TData_1 extends RowData>(rowA: _tanstack_table_core.Row<TFeatures, TData_1>, rowB: _tanstack_table_core.Row<TFeatures, TData_1>, columnId: string) => 0 | 1 | -1;
343
+ textCaseSensitive: <TFeatures extends _tanstack_table_core.TableFeatures, TData_1 extends RowData>(rowA: _tanstack_table_core.Row<TFeatures, TData_1>, rowB: _tanstack_table_core.Row<TFeatures, TData_1>, columnId: string) => 0 | 1 | -1;
344
+ };
345
+ tableMeta: TMDataGridTableMeta;
346
+ columnMeta: TMDataGridColumnMeta;
347
+ }, TData>;
348
+ /**
349
+ * Chrome state that is *not* table state: which panels are open, and which
350
+ * column opened the filter panel. Kept in a TanStack Store so consumers can
351
+ * subscribe to it the same way they subscribe to `table.store`.
352
+ */
353
+ type TMDataGridUiState = {
354
+ filterPanelOpen: boolean;
355
+ columnsPanelOpen: boolean;
356
+ /** Column whose filter row should be focused when the panel opens. */
357
+ filterPanelColumnId: string | null;
358
+ /**
359
+ * Column being dragged by its header, if any. Held here rather than read from
360
+ * `dataTransfer`, which browsers keep unreadable until the drop.
361
+ */
362
+ draggedColumnId: string | null;
363
+ };
364
+ type TMDataGridUiActions = {
365
+ openFilterPanel: (columnId?: string | null) => void;
366
+ closeFilterPanel: () => void;
367
+ setColumnsPanelOpen: (open: boolean) => void;
368
+ toggleColumnsPanel: () => void;
369
+ startColumnDrag: (columnId: string) => void;
370
+ endColumnDrag: () => void;
371
+ };
372
+ type TMDataGridUiStore = Store<TMDataGridUiState, TMDataGridUiActions>;
373
+ /** What `useTMDataGrid` returns — spread straight onto `<TMDataGrid />`. */
374
+ type TMDataGridApi<TData extends RowData> = {
375
+ table: TMDataGridTable$1<TData>;
376
+ ui: TMDataGridUiStore;
377
+ /** Table-level feature switches, re-read from options on every render. */
378
+ features: TMDataGridFeatureFlags;
379
+ };
380
+ type UseTMDataGridOptions<TData extends RowData> = Omit<TableOptions<TMDataGridFeatures, TData>, "features"> & {
381
+ /**
382
+ * Restore and persist table state across mounts. Two keys, because the two
383
+ * kinds of state have different lifetimes — see {@link TMDataGridPersistence}.
384
+ *
385
+ * Keep the object referentially stable (module scope or `useMemo`); it is a
386
+ * dependency of the subscription that writes back.
387
+ */
388
+ persist?: TMDataGridPersistence;
389
+ /**
390
+ * Header drag-and-drop and the move items in the column menu. Defaults to
391
+ * `true`.
392
+ *
393
+ * The one feature switch the grid defines itself: TanStack's
394
+ * `columnOrderingFeature` ships state and APIs but no `enable` option, since
395
+ * reordering is entirely a matter of interface.
396
+ */
397
+ enableColumnOrdering?: boolean;
398
+ };
399
+ /**
400
+ * Builds a TMDataGrid table plus its chrome store.
401
+ *
402
+ * Every `TableOptions` field passes straight through, so a server-driven grid
403
+ * only needs `manualPagination` / `manualFiltering` / `manualSorting`,
404
+ * `rowCount` and the matching `onXChange` callbacks — the chrome reads
405
+ * `getRowCount()` / `getPageCount()` / `getPaginatedRowModel()`, all of which
406
+ * already respect manual mode.
407
+ */
408
+ declare function useTMDataGrid<TData extends RowData>({ persist, enableColumnOrdering, ...options }: UseTMDataGridOptions<TData>): TMDataGridApi<TData>;
409
+ /**
410
+ * Opens the filter panel for a column, seeding an empty filter row when the
411
+ * column has none yet — mirrors "Filter" in the column header menu.
412
+ */
413
+ declare function openColumnFilter<TData extends RowData>(api: TMDataGridApi<TData>, columnId: string): void;
414
+
415
+ /**
416
+ * Row shape the chrome components work against. They only ever touch columns,
417
+ * rows and cells generically, so the concrete row type is erased at the context
418
+ * boundary — the same trick Mantine uses for its compound components.
419
+ */
420
+ type TMDataGridRowData = Record<string, unknown>;
421
+ type TMDataGridContextValue = TMDataGridApi<TMDataGridRowData> & {
422
+ size: TMDataGridSize;
423
+ /** Row height in px, already resolved from `size` and `meta.rowHeight`. */
424
+ rowHeight: number;
425
+ /** Mantine control size that pairs with `size`. */
426
+ controlSize: TMDataGridSize;
427
+ };
428
+ declare function useTMDataGridContext(): TMDataGridContextValue;
429
+
430
+ /** Where a column sits relative to the pinned regions, resolved once per render. */
431
+ type TMDataGridColumnLayout = {
432
+ pinnedAt: "left" | "right" | false;
433
+ /** Distance in px from the grid's left or right edge. */
434
+ offset: number;
435
+ /** Last left-pinned / first right-pinned column — the one that casts the edge. */
436
+ isBoundary: boolean;
437
+ };
438
+ type TMDataGridTableProps<TData extends RowData> = {
439
+ /** Called when a body row is clicked. */
440
+ onRowClick?: (row: Row<TMDataGridFeatures, TData>) => void;
441
+ };
442
+ /**
443
+ * The scrollable grid surface. Always virtualized: only the rows inside the
444
+ * viewport (plus overscan) are mounted, regardless of page size.
445
+ */
446
+ declare function TMDataGridTable<TData extends RowData = TMDataGridRowData>({ onRowClick, }: TMDataGridTableProps<TData>): react.JSX.Element;
447
+
448
+ /** Row above the grid. Compose it from the pieces below, or anything else. */
449
+ declare function TMDataGridToolbar({ children }: {
450
+ children?: ReactNode;
451
+ }): react.JSX.Element;
452
+ /** Pushes the following toolbar items to the right. */
453
+ declare function TMDataGridToolbarSpacer(): react.JSX.Element;
454
+ /**
455
+ * Visible rows over total rows. On a server-driven grid, set
456
+ * `meta.totalRowCount` for the denominator — the client never sees every row.
457
+ */
458
+ declare function TMDataGridSummaryCount({ children }: {
459
+ children?: ReactNode;
460
+ }): react.JSX.Element;
461
+ /**
462
+ * Burger menu in the grid's top-right corner — opens "Manage columns".
463
+ * Renders nothing when no column can be hidden (`enableHiding: false`).
464
+ */
465
+ declare function TMDataGridColumnsButton(): react.JSX.Element | null;
466
+ /**
467
+ * Toggles the filter panel, seeding a filter row on the first filterable column.
468
+ * Renders nothing when no column can be filtered (`enableColumnFilters: false`).
469
+ */
470
+ declare function TMDataGridFilterButton(): react.JSX.Element | null;
471
+
472
+ type TMDataGridProps<TData extends RowData> = TMDataGridApi<TData> & {
473
+ children: ReactNode;
474
+ /**
475
+ * Mantine size scale. Drives row height, font size, cell padding and the
476
+ * size of the controls in the chrome. `meta.rowHeight` still wins if set.
477
+ */
478
+ size?: TMDataGridSize;
479
+ className?: string;
480
+ style?: CSSProperties;
481
+ };
482
+ /**
483
+ * Root of the grid. Takes the object returned by `useTMDataGrid` — spread it —
484
+ * and publishes it to the compound components below it:
485
+ *
486
+ * ```tsx
487
+ * const grid = useTMDataGrid({ data, columns });
488
+ *
489
+ * <TMDataGrid {...grid}>
490
+ * <TMDataGrid.Toolbar>
491
+ * <TMDataGrid.SummaryCount />
492
+ * <TMDataGrid.Spacer />
493
+ * <TMDataGrid.ColumnsButton />
494
+ * </TMDataGrid.Toolbar>
495
+ * <TMDataGrid.Table />
496
+ * <TMDataGrid.Footer />
497
+ * </TMDataGrid>
498
+ * ```
499
+ */
500
+ declare function TMDataGridRoot<TData extends RowData>({ table, ui, features, size, children, className, style, }: TMDataGridProps<TData>): react.JSX.Element;
501
+ declare const TMDataGrid: typeof TMDataGridRoot & {
502
+ Toolbar: typeof TMDataGridToolbar;
503
+ Spacer: typeof TMDataGridToolbarSpacer;
504
+ SummaryCount: typeof TMDataGridSummaryCount;
505
+ ColumnsButton: typeof TMDataGridColumnsButton;
506
+ FilterButton: typeof TMDataGridFilterButton;
507
+ Table: typeof TMDataGridTable;
508
+ Footer: typeof TMDataGridFooter;
509
+ /** Rendered by `TMDataGrid.Table`; exported for custom layouts. */
510
+ FilterPanel: typeof TMDataGridFilterPanel;
511
+ /** Rendered by `TMDataGrid.ColumnsButton`; exported for custom layouts. */
512
+ ColumnsPanel: typeof TMDataGridColumnsPanel;
513
+ };
514
+
515
+ /**
516
+ * Structural shape of the column bits the chrome reads. Kept minimal so these
517
+ * helpers work with any `Column`/`Header` instance without dragging generics
518
+ * through every call site.
519
+ */
520
+ type ColumnLike = {
521
+ id: string;
522
+ columnDef: {
523
+ header?: unknown;
524
+ meta?: TMDataGridColumnMeta;
525
+ };
526
+ /** Set on a leaf that sits inside a header group. */
527
+ parent?: unknown;
528
+ };
529
+ /** Menu- and panel-facing column name. */
530
+ declare function getColumnLabel(column: ColumnLike): string;
531
+ declare function getColumnType(column: ColumnLike): TMDataGridColumnType;
532
+ /**
533
+ * Whether a column may be moved. Ordering is the one column feature TanStack
534
+ * has no column option for, so the switch lives in `meta.enableOrdering`.
535
+ *
536
+ * A leaf inside a header group is never movable: `columnOrder` sequences leaf
537
+ * columns, so moving one out of its group would leave the group header spanning
538
+ * columns that no longer belong to it.
539
+ */
540
+ declare function isColumnReorderable(column: ColumnLike): boolean;
541
+
542
+ type GridColumn = Column<TMDataGridFeatures, TMDataGridRowData, unknown>;
543
+ type GridTable = TMDataGridTable$1<TMDataGridRowData>;
544
+ /**
545
+ * The lane a column renders in.
546
+ *
547
+ * Pinning splits the grid into three, and TanStack sequences them from two
548
+ * different state slices: `columnPinning.left` / `.right` order the pinned
549
+ * lanes, `columnOrder` orders the centre. A move therefore always stays inside
550
+ * one lane — moving a column into another one would be a pin, not a reorder.
551
+ */
552
+ type TMDataGridColumnRegion = "left" | "center" | "right";
553
+ /** Which edge of the column under the pointer a dragged column lands on. */
554
+ type TMDataGridDropSide = "before" | "after";
555
+ declare function getColumnRegion(columnPinning: ColumnPinningState, columnId: string): TMDataGridColumnRegion;
556
+ type MoveColumnArgs = {
557
+ table: GridTable;
558
+ /** Column being moved. */
559
+ columnId: string;
560
+ /** Column it was dropped on. */
561
+ targetId: string;
562
+ side: TMDataGridDropSide;
563
+ };
564
+ /**
565
+ * Moves a column next to another one. A no-op when the two are in different
566
+ * pinned regions, or when either id is unknown.
567
+ *
568
+ * `columnOrder` is always written as the full leaf order, including hidden and
569
+ * pinned columns, so a column keeps its place when it is later shown or
570
+ * unpinned. Pinned lanes are read from `columnPinning`, so a move inside one
571
+ * updates that array as well.
572
+ */
573
+ declare function moveColumn({ table, columnId, targetId, side, }: MoveColumnArgs): void;
574
+ type ColumnStepArgs = {
575
+ table: GridTable;
576
+ columnId: string;
577
+ /** `-1` moves towards the start of the lane, `1` towards its end. */
578
+ direction: -1 | 1;
579
+ };
580
+ /**
581
+ * The column a single step would swap with, or `null` when there is none.
582
+ *
583
+ * A neighbour that cannot be reordered acts as a wall rather than being skipped
584
+ * — that is what keeps the checkbox column anchored at the start of the left
585
+ * lane. Use it to enable or disable a "move" control.
586
+ */
587
+ declare function getStepTargetColumn({ table, columnId, direction, }: ColumnStepArgs): GridColumn | null;
588
+ /** Moves a column one position within its lane. Hidden columns are stepped over. */
589
+ declare function moveColumnByStep({ table, columnId, direction, }: ColumnStepArgs): void;
590
+
591
+ export { DATA_STATE_SLICES, DEFAULT_TMDATAGRID_SIZE, FILTER_OPERATOR_LABELS, SELECT_COLUMN_ID, SETTINGS_STATE_SLICES, SIZE_CONTROL_SIZE, SIZE_ROW_HEIGHT, TMDataGrid, createTMDataGridColumnHelper, getColumnCapabilities, getColumnLabel, getColumnRegion, getColumnType, getGridCapabilities, getStepTargetColumn, isColumnReorderable, isFilterActive, moveColumn, moveColumnByStep, openColumnFilter, readFeatureFlags, tmDataGridFeatures, useTMDataGrid, useTMDataGridContext };
592
+ export type { ColumnStepArgs, MoveColumnArgs, TMDataGridApi, TMDataGridCapabilities, TMDataGridColumnCapabilities, TMDataGridColumnLayout, TMDataGridColumnMeta, TMDataGridColumnRegion, TMDataGridColumnType, TMDataGridContextValue, TMDataGridDataSlice, TMDataGridDropSide, TMDataGridFeatureFlags, TMDataGridFeatures, TMDataGridFilterOperator, TMDataGridFilterValue, TMDataGridPersistKey, TMDataGridPersistence, TMDataGridProps, TMDataGridRowData, TMDataGridSettingsSlice, TMDataGridSize, TMDataGridStorageMode, TMDataGridTable$1 as TMDataGridTable, TMDataGridTableMeta, TMDataGridUiActions, TMDataGridUiState, TMDataGridUiStore, UseTMDataGridOptions };