react-gridix 0.1.0 → 0.2.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/README.html +1742 -0
- package/README.md +2080 -0
- package/dist/index.d.ts +287 -81
- package/dist/react-gridix.cjs +2 -1
- package/dist/react-gridix.js +1238 -499
- package/dist/style.css +1 -1
- package/package.json +3 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,47 +1,13 @@
|
|
|
1
|
-
import { ButtonHTMLAttributes } from 'react';
|
|
2
1
|
import { ComponentType } from 'react';
|
|
3
2
|
import { CSSProperties } from 'react';
|
|
4
|
-
import { ForwardRefExoticComponent } from 'react';
|
|
5
|
-
import { HTMLAttributes } from 'react';
|
|
6
|
-
import { InputHTMLAttributes } from 'react';
|
|
7
3
|
import { JSX as JSX_2 } from 'react';
|
|
4
|
+
import { MutableRefObject } from 'react';
|
|
8
5
|
import { ReactNode } from 'react';
|
|
9
|
-
import { ReactPortal } from 'react';
|
|
10
|
-
import { RefAttributes } from 'react';
|
|
11
|
-
|
|
12
|
-
export declare function Alert({ tone, title, onClose, className, children, ...rest }: AlertProps): JSX_2.Element;
|
|
13
|
-
|
|
14
|
-
export declare interface AlertProps extends Omit<HTMLAttributes<HTMLDivElement>, "title"> {
|
|
15
|
-
tone?: "info" | "success" | "warning" | "danger";
|
|
16
|
-
title?: ReactNode;
|
|
17
|
-
onClose?: () => void;
|
|
18
|
-
}
|
|
19
6
|
|
|
20
7
|
declare type AnyRow = Record<string, any>;
|
|
21
8
|
|
|
22
|
-
export declare function Badge({ tone, className, children, ...rest }: BadgeProps): JSX_2.Element;
|
|
23
|
-
|
|
24
|
-
export declare interface BadgeProps extends HTMLAttributes<HTMLSpanElement> {
|
|
25
|
-
tone?: "neutral" | "info" | "success" | "warning" | "danger";
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export declare const Button: ForwardRefExoticComponent<ButtonProps & RefAttributes<HTMLButtonElement>>;
|
|
29
|
-
|
|
30
|
-
export declare interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
31
|
-
variant?: "primary" | "secondary" | "ghost" | "danger";
|
|
32
|
-
size?: "sm" | "md" | "lg";
|
|
33
|
-
loading?: boolean;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export declare function Card({ title, footer, className, children, ...rest }: CardProps): JSX_2.Element;
|
|
37
|
-
|
|
38
|
-
export declare interface CardProps extends Omit<HTMLAttributes<HTMLDivElement>, "title"> {
|
|
39
|
-
title?: ReactNode;
|
|
40
|
-
footer?: ReactNode;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
9
|
export declare interface CellEditableParams<T = Record<string, any>> {
|
|
44
|
-
/** The raw value stored in the row. */
|
|
10
|
+
/** The raw value stored in the row (read from nested objects for `"a.b"` fields). */
|
|
45
11
|
value: unknown;
|
|
46
12
|
/** The value as text, after `valueFormatter`. */
|
|
47
13
|
formattedValue: string;
|
|
@@ -54,9 +20,11 @@ export declare interface CellEditableParams<T = Record<string, any>> {
|
|
|
54
20
|
export declare interface CellEditEvent<T> {
|
|
55
21
|
rowId: string | number;
|
|
56
22
|
rowIndex: number;
|
|
23
|
+
/** The column's field, for example `"contact.phone"`. */
|
|
57
24
|
field: string;
|
|
58
25
|
oldValue: unknown;
|
|
59
26
|
newValue: unknown;
|
|
27
|
+
/** The updated row. */
|
|
60
28
|
row: T;
|
|
61
29
|
}
|
|
62
30
|
|
|
@@ -136,7 +104,7 @@ export declare type CheckboxVariant = "button" | "tick" | "native";
|
|
|
136
104
|
export declare interface ColumnCheckboxOptions {
|
|
137
105
|
/** Overrides the grid's `checkboxVariant` for this column. */
|
|
138
106
|
variant?: CheckboxVariant;
|
|
139
|
-
/**
|
|
107
|
+
/** A custom character (or any node) drawn inside the box when checked, for example `"✕"` or `"★"`. */
|
|
140
108
|
indicator?: ReactNode;
|
|
141
109
|
className?: string;
|
|
142
110
|
style?: CSSProperties;
|
|
@@ -145,22 +113,59 @@ export declare interface ColumnCheckboxOptions {
|
|
|
145
113
|
}
|
|
146
114
|
|
|
147
115
|
export declare interface ColumnDef<T = Record<string, any>> {
|
|
148
|
-
/**
|
|
149
|
-
|
|
150
|
-
|
|
116
|
+
/**
|
|
117
|
+
* Key of the row object this column reads and writes. Use dot notation for nested objects:
|
|
118
|
+
* `"contact.phone"`. Edits to a nested field copy the objects on the way and never change your data in place.
|
|
119
|
+
*/
|
|
120
|
+
field: FieldPath<T> & string;
|
|
121
|
+
/**
|
|
122
|
+
* Text shown in the header. Defaults to the field name, except for `type: "boolean"` columns,
|
|
123
|
+
* which default to an empty string.
|
|
124
|
+
*/
|
|
151
125
|
headerName?: string;
|
|
152
126
|
/**
|
|
153
|
-
* "number"
|
|
154
|
-
* "boolean"
|
|
127
|
+
* - `"number"` : sorts numerically, edits parse as numbers, filters with a min / max range.
|
|
128
|
+
* - `"boolean"` : shows a checkbox that toggles with one click (see `checkbox`).
|
|
129
|
+
* - `"date"` : shows a formatted date, edits with a date picker, sorts by day, filters with a from / to range.
|
|
130
|
+
* Values can be ISO strings (`"2026-11-05"`), `Date` objects or timestamps. A date is saved in the same
|
|
131
|
+
* kind the cell already had (a `Date` stays a `Date`, a string stays an ISO string).
|
|
155
132
|
*/
|
|
156
|
-
type?: "text" | "number" | "boolean";
|
|
133
|
+
type?: "text" | "number" | "boolean" | "date";
|
|
157
134
|
width?: number | string;
|
|
158
135
|
minWidth?: number | string;
|
|
136
|
+
/** Largest width in pixels when the user resizes the column. */
|
|
137
|
+
maxWidth?: number;
|
|
159
138
|
align?: "left" | "center" | "right";
|
|
160
|
-
/**
|
|
139
|
+
/** Click the header to sort by this column. Default false: sorting is opt-in, column by column. */
|
|
161
140
|
sortable?: boolean;
|
|
162
|
-
/**
|
|
141
|
+
/** Let the user drag the right edge of the header to change the column's width. Default false. */
|
|
142
|
+
resizable?: boolean;
|
|
143
|
+
/** Keep this column stuck to the left or right edge while the grid scrolls sideways. Pinned columns move to that edge. */
|
|
144
|
+
pinned?: "left" | "right";
|
|
145
|
+
/** Start with this column hidden. Needs `columnMenu` on the grid if users should be able to show it again. */
|
|
146
|
+
hidden?: boolean;
|
|
147
|
+
/** Set to false to keep this column out of the column menu (it can then never be hidden by the user). */
|
|
148
|
+
hideable?: boolean;
|
|
149
|
+
/** Show a filter indicator in this column's header. Default false. Clicking it opens the filter popup. */
|
|
163
150
|
filterable?: boolean;
|
|
151
|
+
/** Which filter this column gets. Defaults from `type`, see {@link FilterType}. */
|
|
152
|
+
filterType?: FilterType;
|
|
153
|
+
/** Choices for a `"select"` filter. When missing they are taken from the values in the loaded rows. */
|
|
154
|
+
filterOptions?: (string | FilterOption)[];
|
|
155
|
+
/** Placeholder of the default filter text box. */
|
|
156
|
+
filterPlaceholder?: string;
|
|
157
|
+
/** A React component drawn instead of the default dot. Receives `{ column, active, open }`. */
|
|
158
|
+
filterIndicator?: ComponentType<FilterIndicatorProps<T>>;
|
|
159
|
+
/** Classes for this column's filter indicator button (Tailwind works). */
|
|
160
|
+
filterIndicatorClassName?: string;
|
|
161
|
+
/** Inline styles for this column's filter indicator button. */
|
|
162
|
+
filterIndicatorStyle?: CSSProperties;
|
|
163
|
+
/** Classes for this column's filter popup. */
|
|
164
|
+
filterPopupClassName?: string;
|
|
165
|
+
/** Inline styles for this column's filter popup. */
|
|
166
|
+
filterPopupStyle?: CSSProperties;
|
|
167
|
+
/** A React component that replaces the filter controls inside the popup (text matching only). */
|
|
168
|
+
filterRenderer?: ComponentType<FilterRendererProps<T>>;
|
|
164
169
|
/**
|
|
165
170
|
* `true` / `false`, or a function that decides per cell. Overrides the grid-level `editable`.
|
|
166
171
|
* Example: `editable: ({ row }) => row.status !== "locked"`.
|
|
@@ -174,14 +179,26 @@ export declare interface ColumnDef<T = Record<string, any>> {
|
|
|
174
179
|
validate?: (value: unknown, row: T) => boolean;
|
|
175
180
|
/** Custom sort. Return a negative, zero or positive number. */
|
|
176
181
|
comparator?: (a: any, b: any, rowA: T, rowB: T) => number;
|
|
182
|
+
/** `type: "date"`: how the date is shown, as `Intl.DateTimeFormat` options. Default `{ year: "numeric", month: "short", day: "numeric" }`. */
|
|
183
|
+
dateFormat?: Intl.DateTimeFormatOptions;
|
|
184
|
+
/** `type: "date"`: locale for the displayed date, for example `"en-GB"`. Default is the browser's. */
|
|
185
|
+
dateLocale?: string;
|
|
186
|
+
/** `type: "date"`: earliest day the date picker accepts, as `"YYYY-MM-DD"`. */
|
|
187
|
+
dateMin?: string;
|
|
188
|
+
/** `type: "date"`: latest day the date picker accepts, as `"YYYY-MM-DD"`. */
|
|
189
|
+
dateMax?: string;
|
|
190
|
+
/** What goes into the CSV export for this column. Defaults to the displayed text (dates as `YYYY-MM-DD`). */
|
|
191
|
+
exportValue?: (value: any, row: T) => string | number | boolean | null | undefined;
|
|
177
192
|
/** A React component that renders the cell content. Define it outside render so it keeps its identity. */
|
|
178
193
|
cellRenderer?: ComponentType<CellParams<T>>;
|
|
179
|
-
/** A React component used instead of the
|
|
194
|
+
/** A React component used instead of the default editor when editing this column. */
|
|
180
195
|
cellEditor?: ComponentType<CellEditorProps<T>>;
|
|
181
|
-
/** A React component that renders the header label (the sort arrow
|
|
196
|
+
/** A React component that renders the header label (the filter indicator and sort arrow are still added). */
|
|
182
197
|
headerRenderer?: ComponentType<HeaderRendererProps<T>>;
|
|
183
|
-
/**
|
|
184
|
-
|
|
198
|
+
/** Classes for the whole column: its header cell and every body cell. Tailwind works. */
|
|
199
|
+
className?: string;
|
|
200
|
+
/** Inline styles for the whole column: its header cell and every body cell. */
|
|
201
|
+
style?: CSSProperties;
|
|
185
202
|
headerClassName?: string;
|
|
186
203
|
headerStyle?: CSSProperties;
|
|
187
204
|
cellClassName?: string | ((params: CellParams<T>) => string);
|
|
@@ -190,19 +207,34 @@ export declare interface ColumnDef<T = Record<string, any>> {
|
|
|
190
207
|
checkbox?: ColumnCheckboxOptions;
|
|
191
208
|
/**
|
|
192
209
|
* For `type: "boolean"` columns: draws a checkbox in the header, with the header name as its
|
|
193
|
-
* label. Clicking it checks every row that matches the current
|
|
194
|
-
* or unchecks them all when they are already checked. It shows a
|
|
195
|
-
* are checked. Ignored when the column has a `headerRenderer`.
|
|
210
|
+
* label (no label when the name is empty). Clicking it checks every row that matches the current
|
|
211
|
+
* search and filters (all pages), or unchecks them all when they are already checked. It shows a
|
|
212
|
+
* mixed state when only some are checked. Ignored when the column has a `headerRenderer`.
|
|
196
213
|
*/
|
|
197
214
|
headerCheckbox?: boolean;
|
|
198
215
|
}
|
|
199
216
|
|
|
200
|
-
export declare function DataGrid<T extends AnyRow = AnyRow>({ columns, rows, getRowId, editable, enterMovesDown, onCellEdit, onRowsChange,
|
|
217
|
+
export declare function DataGrid<T extends AnyRow = AnyRow>({ columns, rows, getRowId, editable, enterMovesDown, onCellEdit, onRowsChange, rowSelection, selectedRowIds, defaultSelectedRowIds, onSelectionChange, isRowSelectable, sort: sortProp, defaultSort, onSortChange, multiSort, searchable, searchPlaceholder, search: searchProp, onSearchChange, filters: filtersProp, onFiltersChange, pagination, paginationPosition, pageSize: initialPageSize, pageSizeOptions, page: pageProp, onPageChange, onPageSizeChange, serverSide, rowCount, onQueryChange, queryDebounce, loading: loadingProp, loadingRows, skeletonRow, errorMessage, columnMenu, onColumnVisibilityChange, keyboardNavigation, virtualize, rowHeight, overscan, exportable, apiRef, onRowClick, toolbar, emptyMessage, striped, stripeColors, checkboxVariant, animateRows, theme, maxHeight, className, style, classNames, styles, rowClassName, rowStyle, }: DataGridProps<T>): JSX_2.Element;
|
|
218
|
+
|
|
219
|
+
/** Methods you can call from outside by passing a ref as `apiRef`. */
|
|
220
|
+
export declare interface DataGridApi<T = Record<string, any>> {
|
|
221
|
+
/** Builds the CSV text without downloading it. */
|
|
222
|
+
getCsv: (options?: ExportOptions) => string;
|
|
223
|
+
/** Downloads a CSV file (opens the browser's save dialog). */
|
|
224
|
+
exportCsv: (options?: ExportOptions) => void;
|
|
225
|
+
getSelectedRows: () => T[];
|
|
226
|
+
getSelectedRowIds: () => (string | number)[];
|
|
227
|
+
/** Selects every selectable row that matches the search and filters. */
|
|
228
|
+
selectAll: () => void;
|
|
229
|
+
clearSelection: () => void;
|
|
230
|
+
/** Runs the last query again (`serverSide` only). Use it after your data changed on the server. */
|
|
231
|
+
refresh: () => void;
|
|
232
|
+
}
|
|
201
233
|
|
|
202
234
|
export declare interface DataGridProps<T = Record<string, any>> {
|
|
203
235
|
columns: ColumnDef<T>[];
|
|
204
236
|
rows: T[];
|
|
205
|
-
/** Stable id for each row. Defaults to the row's index in `rows`. */
|
|
237
|
+
/** Stable id for each row. Defaults to the row's index in `rows`. Row selection needs ids that do not change. */
|
|
206
238
|
getRowId?: (row: T, index: number) => string | number;
|
|
207
239
|
/** Allow editing cells (double-click, Enter/F2, or just start typing). Default false. */
|
|
208
240
|
editable?: boolean;
|
|
@@ -215,29 +247,110 @@ export declare interface DataGridProps<T = Record<string, any>> {
|
|
|
215
247
|
onCellEdit?: (event: CellEditEvent<T>) => void;
|
|
216
248
|
/** Fires with the full updated array after a cell edit. Handy for `setRows`. */
|
|
217
249
|
onRowsChange?: (rows: T[]) => void;
|
|
218
|
-
/**
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
/**
|
|
250
|
+
/**
|
|
251
|
+
* Adds a checkbox column for selecting rows. `true` or `"multiple"` allows many rows (with a
|
|
252
|
+
* select-all header and Shift+click ranges), `"single"` allows one. Default false.
|
|
253
|
+
*/
|
|
254
|
+
rowSelection?: boolean | "single" | "multiple";
|
|
255
|
+
/** Controlled selection: the ids of the selected rows. Pair it with `onSelectionChange`. */
|
|
256
|
+
selectedRowIds?: (string | number)[];
|
|
257
|
+
/** Initial selection when you do not control it. */
|
|
258
|
+
defaultSelectedRowIds?: (string | number)[];
|
|
259
|
+
/** Fires whenever the selection changes. */
|
|
260
|
+
onSelectionChange?: (selection: RowSelection<T>) => void;
|
|
261
|
+
/** Return false for rows that must not be selected (their checkbox is disabled). */
|
|
262
|
+
isRowSelectable?: (row: T) => boolean;
|
|
263
|
+
/** Controlled sort. Pair it with `onSortChange`. */
|
|
264
|
+
sort?: SortModel[];
|
|
265
|
+
/** Initial sort when you do not control it. */
|
|
266
|
+
defaultSort?: SortModel | SortModel[] | null;
|
|
267
|
+
/** Fires with the new sort list (empty when no column is sorted). */
|
|
268
|
+
onSortChange?: (sort: SortModel[]) => void;
|
|
269
|
+
/** Hold Shift while clicking headers to sort by several columns. Default false. */
|
|
270
|
+
multiSort?: boolean;
|
|
271
|
+
/** Show the global search box. Default false. */
|
|
224
272
|
searchable?: boolean;
|
|
225
273
|
searchPlaceholder?: string;
|
|
226
|
-
/**
|
|
227
|
-
|
|
228
|
-
|
|
274
|
+
/** Controlled search text. Pair it with `onSearchChange`. */
|
|
275
|
+
search?: string;
|
|
276
|
+
onSearchChange?: (search: string) => void;
|
|
277
|
+
/** Controlled filters, by field. Pair it with `onFiltersChange`. */
|
|
278
|
+
filters?: Record<string, FilterValue>;
|
|
279
|
+
onFiltersChange?: (filters: Record<string, FilterValue>) => void;
|
|
280
|
+
/** Split rows into pages and show the row count and page controls. Default false. */
|
|
229
281
|
pagination?: boolean;
|
|
230
282
|
/** Where the row count and page controls go: "bottom" (default), "top" or "both". */
|
|
231
283
|
paginationPosition?: PaginationPosition;
|
|
284
|
+
/** Initial rows per page. */
|
|
232
285
|
pageSize?: number;
|
|
233
286
|
pageSizeOptions?: number[];
|
|
287
|
+
/** Controlled page (zero-based). Pair it with `onPageChange`. */
|
|
288
|
+
page?: number;
|
|
289
|
+
onPageChange?: (page: number) => void;
|
|
290
|
+
/** Fires when the user picks another page size. */
|
|
291
|
+
onPageSizeChange?: (pageSize: number) => void;
|
|
292
|
+
/**
|
|
293
|
+
* Let your server sort, filter, search and page. The grid then shows `rows` as they are (the
|
|
294
|
+
* current page) and calls `onQueryChange` whenever the query changes. Default false.
|
|
295
|
+
*/
|
|
296
|
+
serverSide?: boolean;
|
|
297
|
+
/** Total number of rows on the server, for the page count. Needed with `serverSide` and `pagination`. */
|
|
298
|
+
rowCount?: number;
|
|
299
|
+
/**
|
|
300
|
+
* Called on mount and whenever the query changes (`serverSide` only). If it returns a promise,
|
|
301
|
+
* the grid shows the loading state until the promise settles and shows an error with a Retry
|
|
302
|
+
* button if it rejects. Update your `rows` (and `rowCount`) before the promise resolves.
|
|
303
|
+
*/
|
|
304
|
+
onQueryChange?: (query: GridQuery) => void | Promise<unknown>;
|
|
305
|
+
/** Wait this long (ms) after the last keystroke in the search box before querying. Default 250. */
|
|
306
|
+
queryDebounce?: number;
|
|
307
|
+
/**
|
|
308
|
+
* Force the loading state on or off. When you leave it out, the loading state follows the promise
|
|
309
|
+
* returned by `onQueryChange`.
|
|
310
|
+
*/
|
|
311
|
+
loading?: boolean;
|
|
312
|
+
/** How many placeholder rows to draw while loading. Default: the page size (at most 20), or 5 without pagination. */
|
|
313
|
+
loadingRows?: number;
|
|
314
|
+
/** A component that draws one placeholder row's content. Without it each cell gets a shimmering bar. */
|
|
315
|
+
skeletonRow?: ComponentType<SkeletonRowProps<T>>;
|
|
316
|
+
/** Shown (with a Retry button) when the promise from `onQueryChange` rejects. */
|
|
317
|
+
errorMessage?: ReactNode;
|
|
318
|
+
/** Show a "Columns" button that lets users show and hide columns. Default false. */
|
|
319
|
+
columnMenu?: boolean;
|
|
320
|
+
/** Fires with the fields that are hidden now. */
|
|
321
|
+
onColumnVisibilityChange?: (hiddenFields: string[]) => void;
|
|
322
|
+
/** Arrow keys, Home/End and Page Up/Down move between cells. Default false. */
|
|
323
|
+
keyboardNavigation?: boolean;
|
|
324
|
+
/**
|
|
325
|
+
* Render only the rows that are on screen, so tens of thousands of rows stay smooth. Needs a fixed
|
|
326
|
+
* `rowHeight`, and the grid scrolls inside `maxHeight` (400 when you set none). Default false.
|
|
327
|
+
*/
|
|
328
|
+
virtualize?: boolean;
|
|
329
|
+
/** Row height in pixels when `virtualize` is on. Rows must fit it. Default 40. */
|
|
330
|
+
rowHeight?: number;
|
|
331
|
+
/** Extra rows rendered above and below the visible ones when `virtualize` is on. Default 6. */
|
|
332
|
+
overscan?: number;
|
|
333
|
+
/** Show an "Export CSV" button. Pass an object to set the file name, scope and so on. Default false. */
|
|
334
|
+
exportable?: boolean | ExportOptions;
|
|
335
|
+
/** Pass a ref to call methods such as `exportCsv()` or `getSelectedRows()` from outside. */
|
|
336
|
+
apiRef?: MutableRefObject<DataGridApi<T> | null>;
|
|
234
337
|
onRowClick?: (row: T, rowIndex: number) => void;
|
|
235
338
|
/** Extra content on the right side of the toolbar. */
|
|
236
339
|
toolbar?: ReactNode;
|
|
237
340
|
emptyMessage?: ReactNode;
|
|
341
|
+
/** Alternate row shading. Default false. */
|
|
238
342
|
striped?: boolean;
|
|
239
|
-
/**
|
|
343
|
+
/** Two colours for the alternating rows, for example `["#ffffff", "#f1f5f9"]`. Implies `striped`. */
|
|
344
|
+
stripeColors?: [string, string];
|
|
345
|
+
/** Checkbox style for `type: "boolean"` columns and the selection column: "button", "tick" or "native" (default). */
|
|
240
346
|
checkboxVariant?: CheckboxVariant;
|
|
347
|
+
/** Rows slide in smoothly when they render (new page, sort, search). Default true. Respects "reduce motion". */
|
|
348
|
+
animateRows?: boolean;
|
|
349
|
+
/**
|
|
350
|
+
* Name of a theme. Nothing changes unless you pass one: "ocean", "midnight", "sunset", "forest",
|
|
351
|
+
* "lavender", "coffee", "graphite" or "aurora", or the name of your own `[data-rk-theme="..."]` CSS.
|
|
352
|
+
*/
|
|
353
|
+
theme?: GridTheme | (string & {});
|
|
241
354
|
/** Makes the body scroll with a sticky header, e.g. 400 or "60vh". */
|
|
242
355
|
maxHeight?: number | string;
|
|
243
356
|
/** Tailwind or any CSS classes for the root element. */
|
|
@@ -252,45 +365,138 @@ export declare interface DataGridProps<T = Record<string, any>> {
|
|
|
252
365
|
rowStyle?: CSSProperties | ((row: T, rowIndex: number) => CSSProperties);
|
|
253
366
|
}
|
|
254
367
|
|
|
255
|
-
/**
|
|
368
|
+
/** Value of a `"date"` filter: ISO days (`"2026-11-05"`), both ends included. */
|
|
369
|
+
export declare interface DateRangeFilter {
|
|
370
|
+
from?: string;
|
|
371
|
+
to?: string;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
export declare interface ExportOptions {
|
|
375
|
+
/** File name without the extension. Default `"export"`. */
|
|
376
|
+
filename?: string;
|
|
377
|
+
/**
|
|
378
|
+
* Which rows to export.
|
|
379
|
+
* - `"filtered"` (default): every row matching the search and filters, across all pages
|
|
380
|
+
* - `"page"` : only the rows on the current page
|
|
381
|
+
* - `"selected"`: only the selected rows
|
|
382
|
+
* With `serverSide`, "filtered" means the rows currently loaded.
|
|
383
|
+
*/
|
|
384
|
+
scope?: "filtered" | "page" | "selected";
|
|
385
|
+
/** Also export columns the user has hidden. Default false. */
|
|
386
|
+
includeHidden?: boolean;
|
|
387
|
+
/** Add an apostrophe in front of text that starts with `= + - @`, so spreadsheets do not run it as a formula. Default true. */
|
|
388
|
+
sanitize?: boolean;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* Every field a column can point at: top-level keys, plus dot paths into nested objects
|
|
393
|
+
* (`"contact.phone"`). Goes up to 5 levels deep. Arrays are treated as plain values.
|
|
394
|
+
*/
|
|
395
|
+
export declare type FieldPath<T, D extends number = 5> = [D] extends [never] ? never : T extends Primitive | readonly unknown[] ? never : {
|
|
396
|
+
[K in keyof T & string]: NonNullable<T[K]> extends Primitive | readonly unknown[] ? K : K | `${K}.${FieldPath<NonNullable<T[K]>, Prev[D]>}`;
|
|
397
|
+
}[keyof T & string];
|
|
398
|
+
|
|
399
|
+
/** Props received by a column's `filterIndicator` component. */
|
|
400
|
+
export declare interface FilterIndicatorProps<T = Record<string, any>> {
|
|
401
|
+
column: ColumnDef<T>;
|
|
402
|
+
/** True while a filter is set for this column. */
|
|
403
|
+
active: boolean;
|
|
404
|
+
/** True while the filter popup is open. */
|
|
405
|
+
open: boolean;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
/** An entry in a `"select"` filter's list. A plain string is shorthand for `{ value }`. */
|
|
409
|
+
export declare interface FilterOption {
|
|
410
|
+
value: string;
|
|
411
|
+
/** Text shown in the list. Defaults to `value`. */
|
|
412
|
+
label?: string;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* Props received by a column's `filterRenderer` component (shown inside the filter popup).
|
|
417
|
+
* A column with a `filterRenderer` always filters with a text "contains" match.
|
|
418
|
+
*/
|
|
256
419
|
export declare interface FilterRendererProps<T = Record<string, any>> {
|
|
257
420
|
column: ColumnDef<T>;
|
|
258
421
|
value: string;
|
|
259
422
|
onChange: (value: string) => void;
|
|
260
423
|
}
|
|
261
424
|
|
|
262
|
-
|
|
425
|
+
/**
|
|
426
|
+
* Which kind of filter a column gets in its popup.
|
|
427
|
+
* - `"text"` : "contains" match on the displayed text (default for text columns)
|
|
428
|
+
* - `"exact"` : the displayed text must equal what was typed (ignoring case)
|
|
429
|
+
* - `"number"` : a min / max range (default for `type: "number"` columns)
|
|
430
|
+
* - `"date"` : a from / to range (default for `type: "date"` columns)
|
|
431
|
+
* - `"select"` : pick one or more values from a list (default for `type: "boolean"` columns)
|
|
432
|
+
*/
|
|
433
|
+
export declare type FilterType = "text" | "exact" | "number" | "date" | "select";
|
|
434
|
+
|
|
435
|
+
/** What a column's filter currently holds. The shape depends on the column's `FilterType`. */
|
|
436
|
+
export declare type FilterValue = string | NumberRangeFilter | DateRangeFilter | string[];
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* Everything the grid wants from your server in `serverSide` mode. It is sent to `onQueryChange`
|
|
440
|
+
* on mount and whenever the sort, search, a filter, the page or the page size changes.
|
|
441
|
+
*/
|
|
442
|
+
export declare interface GridQuery {
|
|
443
|
+
/** Sorted columns, in priority order. Only sortable columns are included. */
|
|
444
|
+
sort: SortModel[];
|
|
445
|
+
/** Active filters by field. A filter that is empty is left out. Values depend on each column's `filterType`. */
|
|
446
|
+
filters: Record<string, FilterValue>;
|
|
447
|
+
/** The global search text (trimmed). */
|
|
448
|
+
search: string;
|
|
449
|
+
/** Zero-based page index. */
|
|
450
|
+
page: number;
|
|
451
|
+
pageSize: number;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
export declare type GridSlot = "root" | "toolbar" | "search" | "scroll" | "table" | "thead" | "headerRow" | "headerCell" | "filterIndicator" | "filterPopup" | "filterInput" | "tbody" | "row" | "cell" | "editor" | "empty" | "footer" | "rowCount" | "pageInfo" | "pageSize" | "pagination" | "pageButton" | "checkbox" | "checkboxControl" | "checkboxIndicator" | "toolButton" | "skeleton";
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* Built-in themes. A theme only applies when you pass its name to `<DataGrid theme="..." />`.
|
|
458
|
+
* Any other string works too if you define `[data-rk-theme="name"]` CSS variables yourself.
|
|
459
|
+
*/
|
|
460
|
+
export declare type GridTheme = "ocean" | "midnight" | "sunset" | "forest" | "lavender" | "coffee" | "graphite" | "aurora";
|
|
263
461
|
|
|
264
462
|
/** Props received by a column's `headerRenderer` component. */
|
|
265
463
|
export declare interface HeaderRendererProps<T = Record<string, any>> {
|
|
266
464
|
column: ColumnDef<T>;
|
|
465
|
+
/** Direction this column is sorted in, or null when it is not sorted. */
|
|
267
466
|
sortDirection: SortDirection | null;
|
|
268
467
|
}
|
|
269
468
|
|
|
270
|
-
export declare
|
|
469
|
+
export declare type MoveDirection = "down" | "up" | "left" | "right" | "none";
|
|
271
470
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
471
|
+
/** Value of a `"number"` filter. Either bound may be missing. */
|
|
472
|
+
export declare interface NumberRangeFilter {
|
|
473
|
+
min?: number;
|
|
474
|
+
max?: number;
|
|
276
475
|
}
|
|
277
476
|
|
|
278
|
-
export declare
|
|
477
|
+
export declare type PaginationPosition = "bottom" | "top" | "both";
|
|
279
478
|
|
|
280
|
-
|
|
281
|
-
open: boolean;
|
|
282
|
-
onClose: () => void;
|
|
283
|
-
title?: ReactNode;
|
|
284
|
-
footer?: ReactNode;
|
|
285
|
-
children?: ReactNode;
|
|
286
|
-
}
|
|
479
|
+
declare type Prev = [never, 0, 1, 2, 3, 4, 5];
|
|
287
480
|
|
|
288
|
-
|
|
481
|
+
declare type Primitive = string | number | boolean | bigint | symbol | null | undefined | Date | ((...args: any[]) => any);
|
|
289
482
|
|
|
290
|
-
|
|
483
|
+
/** The selected rows. `rows` only holds rows that are loaded in the grid right now (matters with `serverSide`). */
|
|
484
|
+
export declare interface RowSelection<T> {
|
|
485
|
+
ids: (string | number)[];
|
|
486
|
+
rows: T[];
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
/** Props received by the `skeletonRow` component, which draws one placeholder row while loading. */
|
|
490
|
+
export declare interface SkeletonRowProps<T = Record<string, any>> {
|
|
491
|
+
/** Position of this placeholder row (0, 1, 2 ...). */
|
|
492
|
+
rowIndex: number;
|
|
493
|
+
/** The columns that are currently visible. */
|
|
494
|
+
columns: ColumnDef<T>[];
|
|
495
|
+
}
|
|
291
496
|
|
|
292
497
|
export declare type SortDirection = "asc" | "desc";
|
|
293
498
|
|
|
499
|
+
/** One sorted column. The grid keeps a list of these (more than one only with `multiSort`). */
|
|
294
500
|
export declare interface SortModel {
|
|
295
501
|
field: string;
|
|
296
502
|
direction: SortDirection;
|