@hexclave/dashboard-ui-components 1.0.3 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/alert.js +4 -4
- package/dist/components/alert.js.map +1 -1
- package/dist/components/badge.js +1 -1
- package/dist/components/badge.js.map +1 -1
- package/dist/components/button.d.ts +4 -4
- package/dist/components/button.js +3 -3
- package/dist/components/button.js.map +1 -1
- package/dist/components/data-grid/data-grid-toolbar.js +5 -5
- package/dist/components/data-grid/data-grid-toolbar.js.map +1 -1
- package/dist/components/data-grid/data-grid.d.ts.map +1 -1
- package/dist/components/data-grid/data-grid.js +11 -5
- package/dist/components/data-grid/data-grid.js.map +1 -1
- package/dist/components/data-grid/data-grid.test.js +34 -1
- package/dist/components/data-grid/data-grid.test.js.map +1 -1
- package/dist/components/dialog.d.ts +6 -2
- package/dist/components/dialog.d.ts.map +1 -1
- package/dist/components/dialog.js +14 -10
- package/dist/components/dialog.js.map +1 -1
- package/dist/components/input.js +12 -9
- package/dist/components/input.js.map +1 -1
- package/dist/components/pill-toggle.js +3 -3
- package/dist/components/pill-toggle.js.map +1 -1
- package/dist/components/tabs.js +2 -2
- package/dist/components/tabs.js.map +1 -1
- package/dist/dashboard-ui-components.global.js +15639 -17400
- package/dist/dashboard-ui-components.global.js.map +4 -4
- package/dist/esm/components/alert.js +4 -4
- package/dist/esm/components/alert.js.map +1 -1
- package/dist/esm/components/badge.js +1 -1
- package/dist/esm/components/badge.js.map +1 -1
- package/dist/esm/components/button.d.ts +4 -4
- package/dist/esm/components/button.js +3 -3
- package/dist/esm/components/button.js.map +1 -1
- package/dist/esm/components/data-grid/data-grid-toolbar.js +5 -5
- package/dist/esm/components/data-grid/data-grid-toolbar.js.map +1 -1
- package/dist/esm/components/data-grid/data-grid.d.ts.map +1 -1
- package/dist/esm/components/data-grid/data-grid.js +11 -5
- package/dist/esm/components/data-grid/data-grid.js.map +1 -1
- package/dist/esm/components/data-grid/data-grid.test.js +34 -1
- package/dist/esm/components/data-grid/data-grid.test.js.map +1 -1
- package/dist/esm/components/dialog.d.ts +6 -2
- package/dist/esm/components/dialog.d.ts.map +1 -1
- package/dist/esm/components/dialog.js +13 -11
- package/dist/esm/components/dialog.js.map +1 -1
- package/dist/esm/components/input.js +12 -9
- package/dist/esm/components/input.js.map +1 -1
- package/dist/esm/components/pill-toggle.js +4 -4
- package/dist/esm/components/pill-toggle.js.map +1 -1
- package/dist/esm/components/tabs.js +2 -2
- package/dist/esm/components/tabs.js.map +1 -1
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.js +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +12 -0
- package/package.json +4 -3
- package/src/components/alert.tsx +120 -0
- package/src/components/analytics-chart/analytics-chart-pie.tsx +369 -0
- package/src/components/analytics-chart/analytics-chart.tsx +1585 -0
- package/src/components/analytics-chart/default-analytics-chart-tooltip.tsx +265 -0
- package/src/components/analytics-chart/format.ts +101 -0
- package/src/components/analytics-chart/index.ts +75 -0
- package/src/components/analytics-chart/palette.ts +68 -0
- package/src/components/analytics-chart/render-data-series.tsx +169 -0
- package/src/components/analytics-chart/state.ts +165 -0
- package/src/components/analytics-chart/strings.ts +72 -0
- package/src/components/analytics-chart/types.ts +220 -0
- package/src/components/badge.tsx +108 -0
- package/src/components/button.tsx +104 -0
- package/src/components/card.tsx +263 -0
- package/src/components/chart-card.tsx +101 -0
- package/src/components/chart-container.tsx +155 -0
- package/src/components/chart-legend.tsx +65 -0
- package/src/components/chart-theme.tsx +52 -0
- package/src/components/chart-tooltip.tsx +165 -0
- package/src/components/cursor-blast-effect.tsx +334 -0
- package/src/components/data-grid/data-grid-sizing.ts +51 -0
- package/src/components/data-grid/data-grid-toolbar.tsx +373 -0
- package/src/components/data-grid/data-grid.test.tsx +407 -0
- package/src/components/data-grid/data-grid.tsx +1231 -0
- package/src/components/data-grid/index.ts +64 -0
- package/src/components/data-grid/state.ts +235 -0
- package/src/components/data-grid/strings.ts +45 -0
- package/src/components/data-grid/types.ts +401 -0
- package/src/components/data-grid/use-data-source.ts +413 -0
- package/src/components/data-grid/use-url-state.test.tsx +88 -0
- package/src/components/data-grid/use-url-state.ts +298 -0
- package/src/components/dialog.tsx +218 -0
- package/src/components/edit-mode.tsx +17 -0
- package/src/components/empty-state.tsx +64 -0
- package/src/components/input.tsx +97 -0
- package/src/components/metric-card.tsx +142 -0
- package/src/components/pill-toggle.tsx +159 -0
- package/src/components/progress-bar.tsx +82 -0
- package/src/components/separator.tsx +36 -0
- package/src/components/skeleton.tsx +30 -0
- package/src/components/table.tsx +113 -0
- package/src/components/tabs.tsx +217 -0
- package/src/index.ts +71 -0
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
// ─── Row identity ────────────────────────────────────────────────────
|
|
4
|
+
/** Every row must be uniquely identifiable. The grid resolves identity
|
|
5
|
+
* through the top-level `getRowId` prop. */
|
|
6
|
+
export type RowId = string;
|
|
7
|
+
|
|
8
|
+
// ─── Column definition ──────────────────────────────────────────────
|
|
9
|
+
export type DataGridColumnType =
|
|
10
|
+
| "string"
|
|
11
|
+
| "number"
|
|
12
|
+
| "date"
|
|
13
|
+
| "dateTime"
|
|
14
|
+
| "boolean"
|
|
15
|
+
| "singleSelect"
|
|
16
|
+
| "custom";
|
|
17
|
+
|
|
18
|
+
export type DataGridColumnAlign = "left" | "center" | "right";
|
|
19
|
+
|
|
20
|
+
export type DataGridColumnPin = "left" | "right" | false;
|
|
21
|
+
|
|
22
|
+
/** How `date` / `dateTime` cells render their value. `"relative"` shows
|
|
23
|
+
* "1 day ago"–style text with the full datetime in a tooltip; `"absolute"`
|
|
24
|
+
* shows the full datetime inline. */
|
|
25
|
+
export type DataGridDateDisplay = "relative" | "absolute";
|
|
26
|
+
|
|
27
|
+
/** Per-column overrides for how a `date` / `dateTime` cell is formatted.
|
|
28
|
+
* If either function is omitted the grid falls back to its default
|
|
29
|
+
* (Intl.RelativeTimeFormat + `toLocaleString()`). */
|
|
30
|
+
export type DataGridDateFormat = {
|
|
31
|
+
relative?: (date: Date) => string;
|
|
32
|
+
absolute?: (date: Date) => string;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/** Context passed to `renderCell`. */
|
|
36
|
+
export type DataGridCellContext<TRow> = {
|
|
37
|
+
row: TRow;
|
|
38
|
+
rowId: RowId;
|
|
39
|
+
rowIndex: number;
|
|
40
|
+
value: unknown;
|
|
41
|
+
columnId: string;
|
|
42
|
+
isSelected: boolean;
|
|
43
|
+
/** Current date display mode — consumers writing custom `renderCell`
|
|
44
|
+
* for `date` / `dateTime` columns should branch on this to match the
|
|
45
|
+
* grid's built-in behaviour. */
|
|
46
|
+
dateDisplay: DataGridDateDisplay;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/** Context passed to `renderHeader`. */
|
|
50
|
+
export type DataGridHeaderContext<TRow> = {
|
|
51
|
+
columnId: string;
|
|
52
|
+
columnDef: DataGridColumnDef<TRow>;
|
|
53
|
+
isSorted: false | "asc" | "desc";
|
|
54
|
+
sortIndex: number | null;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/** A single column's full configuration. Generic over the row type. */
|
|
58
|
+
export type DataGridColumnDef<TRow> = {
|
|
59
|
+
/** Unique identifier for this column. */
|
|
60
|
+
id: string;
|
|
61
|
+
|
|
62
|
+
/** Display label. If a function is given it receives the header context. */
|
|
63
|
+
header: string | ((ctx: DataGridHeaderContext<TRow>) => ReactNode);
|
|
64
|
+
|
|
65
|
+
/** Accessor — either a key of TRow or a function. If omitted, `id` is
|
|
66
|
+
* used as the key. */
|
|
67
|
+
accessor?: keyof TRow | ((row: TRow) => unknown);
|
|
68
|
+
|
|
69
|
+
/** Custom cell renderer. Falls back to plain text of the resolved value. */
|
|
70
|
+
renderCell?: (ctx: DataGridCellContext<TRow>) => ReactNode;
|
|
71
|
+
|
|
72
|
+
// ── Sizing ──────────────────────────────────────────────────
|
|
73
|
+
/** Initial width in pixels. Defaults to 150. */
|
|
74
|
+
width?: number;
|
|
75
|
+
/** Minimum width during resize. Defaults to 50. */
|
|
76
|
+
minWidth?: number;
|
|
77
|
+
/** Maximum width during resize. Defaults to 800. */
|
|
78
|
+
maxWidth?: number;
|
|
79
|
+
/** Flex grow factor. When set, remaining space is distributed among flex
|
|
80
|
+
* columns proportionally. */
|
|
81
|
+
flex?: number;
|
|
82
|
+
|
|
83
|
+
// ── Feature flags ──────────────────────────────────────────
|
|
84
|
+
sortable?: boolean;
|
|
85
|
+
resizable?: boolean;
|
|
86
|
+
hideable?: boolean;
|
|
87
|
+
/** Pin position. Defaults to `false` (unpinned). */
|
|
88
|
+
pin?: DataGridColumnPin;
|
|
89
|
+
|
|
90
|
+
// ── Display ──────────────────────────────────────────────────
|
|
91
|
+
align?: DataGridColumnAlign;
|
|
92
|
+
/** Column type affects default sorting. */
|
|
93
|
+
type?: DataGridColumnType;
|
|
94
|
+
/** For `singleSelect` type — available value options. */
|
|
95
|
+
valueOptions?: readonly DataGridSelectOption[];
|
|
96
|
+
|
|
97
|
+
// ── Cell overflow ──────────────────────────────────────────
|
|
98
|
+
/** How cell content handles overflow.
|
|
99
|
+
* - `"truncate"` (default): single-line with text-overflow ellipsis.
|
|
100
|
+
* - `"wrap"`: content wraps naturally. When combined with
|
|
101
|
+
* `rowHeight="auto"` on the grid, the row grows to fit. With a
|
|
102
|
+
* fixed `rowHeight`, wrapped content is clipped at the row boundary. */
|
|
103
|
+
cellOverflow?: "truncate" | "wrap";
|
|
104
|
+
|
|
105
|
+
// ── Overrides ──────────────────────────────────────────────
|
|
106
|
+
/** Custom sort comparator. Receives two resolved cell values.
|
|
107
|
+
* Return negative if a < b, positive if a > b, 0 if equal. */
|
|
108
|
+
sortComparator?: (a: unknown, b: unknown) => number;
|
|
109
|
+
/** Format a cell value to a plain string — used for export and
|
|
110
|
+
* clipboard copy. Defaults to `String(value)`. */
|
|
111
|
+
formatValue?: (value: unknown, row: TRow) => string;
|
|
112
|
+
|
|
113
|
+
// ── Date / dateTime ─────────────────────────────────────────
|
|
114
|
+
/** Parse a raw cell value into a `Date`. Only consulted when `type` is
|
|
115
|
+
* `"date"` or `"dateTime"`. Defaults to `new Date(value)` with graceful
|
|
116
|
+
* handling of `null` / `undefined` / invalid dates. Override for
|
|
117
|
+
* non-standard formats (e.g. ClickHouse's space-separated UTC strings). */
|
|
118
|
+
parseValue?: (value: unknown) => Date | null;
|
|
119
|
+
/** Per-column override for the relative / absolute date formatters. */
|
|
120
|
+
dateFormat?: DataGridDateFormat;
|
|
121
|
+
|
|
122
|
+
// ── Cell-level callbacks ──────────────────────────────────────
|
|
123
|
+
/** Fired when a cell in this column is clicked. */
|
|
124
|
+
onCellClick?: (ctx: DataGridCellContext<TRow>, event: React.MouseEvent) => void;
|
|
125
|
+
/** Fired when a cell in this column is double-clicked. */
|
|
126
|
+
onCellDoubleClick?: (ctx: DataGridCellContext<TRow>, event: React.MouseEvent) => void;
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
export type DataGridSelectOption = {
|
|
130
|
+
value: string;
|
|
131
|
+
label: string;
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
// ─── Sorting ─────────────────────────────────────────────────────────
|
|
135
|
+
export type DataGridSortItem = {
|
|
136
|
+
columnId: string;
|
|
137
|
+
direction: "asc" | "desc";
|
|
138
|
+
};
|
|
139
|
+
export type DataGridSortModel = readonly DataGridSortItem[];
|
|
140
|
+
|
|
141
|
+
// ─── Selection ───────────────────────────────────────────────────────
|
|
142
|
+
export type DataGridSelectionMode = "none" | "single" | "multiple";
|
|
143
|
+
|
|
144
|
+
export type DataGridSelectionModel = {
|
|
145
|
+
selectedIds: ReadonlySet<RowId>;
|
|
146
|
+
/** Tracks the last-clicked row for shift-range selection. */
|
|
147
|
+
anchorId: RowId | null;
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
// ─── Column visibility / pinning ─────────────────────────────────────
|
|
151
|
+
export type DataGridColumnVisibility = Record<string, boolean>;
|
|
152
|
+
|
|
153
|
+
export type DataGridColumnPinning = {
|
|
154
|
+
left: readonly string[];
|
|
155
|
+
right: readonly string[];
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
// ─── Pagination ──────────────────────────────────────────────────────
|
|
159
|
+
/** UI display mode — "paginated" shows page controls, "infinite" shows scroll sentinel. */
|
|
160
|
+
export type DataGridPaginationMode = "paginated" | "infinite";
|
|
161
|
+
|
|
162
|
+
/** Data-fetching strategy used by `useDataSource`. */
|
|
163
|
+
export type DataGridDataPaginationMode = "client" | "server" | "infinite";
|
|
164
|
+
|
|
165
|
+
export type DataGridPaginationModel = {
|
|
166
|
+
pageIndex: number;
|
|
167
|
+
pageSize: number;
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
// ─── Combined grid state ─────────────────────────────────────────────
|
|
171
|
+
export type DataGridState = {
|
|
172
|
+
sorting: DataGridSortModel;
|
|
173
|
+
columnVisibility: DataGridColumnVisibility;
|
|
174
|
+
columnWidths: Record<string, number>;
|
|
175
|
+
columnPinning: DataGridColumnPinning;
|
|
176
|
+
columnOrder: readonly string[];
|
|
177
|
+
pagination: DataGridPaginationModel;
|
|
178
|
+
selection: DataGridSelectionModel;
|
|
179
|
+
/** How `date` / `dateTime` columns render. Defaults to `"relative"`
|
|
180
|
+
* via `createDefaultDataGridState`. Toggled from the Columns popover
|
|
181
|
+
* whenever the grid has at least one date column. */
|
|
182
|
+
dateDisplay: DataGridDateDisplay;
|
|
183
|
+
/** Current quick-search text. Written by the built-in search input in
|
|
184
|
+
* the toolbar. `useDataSource` in client mode auto-filters by this
|
|
185
|
+
* value (via `applyQuickSearch`); in async mode it's passed through
|
|
186
|
+
* to the generator as `params.quickSearch`, where the consumer owns
|
|
187
|
+
* the "how do I match?" decision (typically by modifying the backend
|
|
188
|
+
* query). Defaults to `""`. */
|
|
189
|
+
quickSearch: string;
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
// ─── Data source ─────────────────────────────────────────────────────
|
|
193
|
+
/** Params sent to the async data source on each fetch. */
|
|
194
|
+
export type DataGridFetchParams = {
|
|
195
|
+
sorting: DataGridSortModel;
|
|
196
|
+
pagination: DataGridPaginationModel;
|
|
197
|
+
/** Current quick-search text. Passed through from `state.quickSearch`
|
|
198
|
+
* so the async generator can fold it into its query (e.g. a SQL WHERE
|
|
199
|
+
* clause). Empty string when the search box is empty. A change in
|
|
200
|
+
* this value triggers a refetch, same mechanism as sorting. */
|
|
201
|
+
quickSearch: string;
|
|
202
|
+
/** For cursor-based: the last row of the previous page. */
|
|
203
|
+
cursor: unknown;
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
/** Return type from a data source fetch. */
|
|
207
|
+
export type DataGridFetchResult<TRow> = {
|
|
208
|
+
rows: TRow[];
|
|
209
|
+
/** Total row count if known. `-1` or `undefined` for unknown (infinite). */
|
|
210
|
+
totalRowCount?: number;
|
|
211
|
+
/** Cursor for the next page (for cursor-based pagination). */
|
|
212
|
+
nextCursor?: unknown;
|
|
213
|
+
/** If `false`, there are no more pages. */
|
|
214
|
+
hasMore?: boolean;
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
/** An async-generator data source yields pages of rows. The generator
|
|
218
|
+
* receives fetch params as its argument and yields pages. Yielding
|
|
219
|
+
* allows the grid to display partial results during loading. */
|
|
220
|
+
export type DataGridDataSource<TRow> = (
|
|
221
|
+
params: DataGridFetchParams,
|
|
222
|
+
) => AsyncGenerator<DataGridFetchResult<TRow>, void, undefined>;
|
|
223
|
+
|
|
224
|
+
// ─── Callbacks ───────────────────────────────────────────────────────
|
|
225
|
+
export type DataGridCallbacks<TRow> = {
|
|
226
|
+
onRowClick?: (row: TRow, rowId: RowId, event: React.MouseEvent) => void;
|
|
227
|
+
onRowDoubleClick?: (row: TRow, rowId: RowId, event: React.MouseEvent) => void;
|
|
228
|
+
onCellClick?: (row: TRow, columnId: string, value: unknown, event: React.MouseEvent) => void;
|
|
229
|
+
/**
|
|
230
|
+
* Fires when the selection set changes. **Page-scoped:** the header "select
|
|
231
|
+
* all" checkbox and `selectedRows` only cover the rows currently rendered
|
|
232
|
+
* (the visible page in paginated mode, or the loaded prefix in infinite
|
|
233
|
+
* mode). The grid does not load other pages to satisfy the selection — if
|
|
234
|
+
* you need cross-page selection, drive `selectedIds` from your own state
|
|
235
|
+
* and load all rows you care about up-front.
|
|
236
|
+
*/
|
|
237
|
+
onSelectionChange?: (selectedIds: ReadonlySet<RowId>, selectedRows: TRow[]) => void;
|
|
238
|
+
onSortChange?: (model: DataGridSortModel) => void;
|
|
239
|
+
onColumnResize?: (columnId: string, width: number) => void;
|
|
240
|
+
onColumnVisibilityChange?: (model: DataGridColumnVisibility) => void;
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
// ─── Main props ──────────────────────────────────────────────────────
|
|
244
|
+
export type DataGridProps<TRow> = {
|
|
245
|
+
/** Column definitions. */
|
|
246
|
+
columns: readonly DataGridColumnDef<TRow>[];
|
|
247
|
+
|
|
248
|
+
// ── Data (pre-resolved by the consumer) ────────────────────────
|
|
249
|
+
/** The rows to display. The consumer is responsible for sorting
|
|
250
|
+
* and paginating before passing them in. */
|
|
251
|
+
rows: readonly TRow[];
|
|
252
|
+
/** Extract a unique identifier from each row. */
|
|
253
|
+
getRowId: (row: TRow) => RowId;
|
|
254
|
+
/** Total row count across all pages (used for pagination UI). */
|
|
255
|
+
totalRowCount?: number;
|
|
256
|
+
/** True while the initial data load is in progress (shows skeleton). */
|
|
257
|
+
isLoading?: boolean;
|
|
258
|
+
/** True during a background refetch (shows subtle indicator, keeps rows). */
|
|
259
|
+
isRefetching?: boolean;
|
|
260
|
+
|
|
261
|
+
// ── Infinite scroll ────────────────────────────────────────────
|
|
262
|
+
/** Whether more rows can be loaded (shows infinite scroll sentinel). */
|
|
263
|
+
hasMore?: boolean;
|
|
264
|
+
/** True while loading the next page of infinite scroll. */
|
|
265
|
+
isLoadingMore?: boolean;
|
|
266
|
+
/** Called when the infinite scroll sentinel becomes visible. */
|
|
267
|
+
onLoadMore?: () => void;
|
|
268
|
+
|
|
269
|
+
// ── State (fully controlled) ───────────────────────────────────
|
|
270
|
+
state: DataGridState;
|
|
271
|
+
onChange: React.Dispatch<React.SetStateAction<DataGridState>>;
|
|
272
|
+
|
|
273
|
+
// ── Modes ──────────────────────────────────────────────────────
|
|
274
|
+
/** UI mode for pagination. "paginated" shows page controls in the
|
|
275
|
+
* footer. "infinite" shows a scroll sentinel instead. Defaults to
|
|
276
|
+
* "paginated". */
|
|
277
|
+
paginationMode?: "paginated" | "infinite";
|
|
278
|
+
/** Selection behaviour. Defaults to "none". */
|
|
279
|
+
selectionMode?: DataGridSelectionMode;
|
|
280
|
+
/** Whether columns can be resized by dragging. Defaults to true. */
|
|
281
|
+
resizable?: boolean;
|
|
282
|
+
|
|
283
|
+
// ── Layout ─────────────────────────────────────────────────────
|
|
284
|
+
/** Row height in pixels, or `"auto"` for dynamic measurement.
|
|
285
|
+
*
|
|
286
|
+
* - **number** (default `44`): every row is exactly this tall.
|
|
287
|
+
* Fast and predictable; content that overflows is clipped.
|
|
288
|
+
* - **`"auto"`**: each row is measured by the browser after render
|
|
289
|
+
* and the virtualizer adjusts positions accordingly. Columns
|
|
290
|
+
* with `cellOverflow: "wrap"` will push the row taller; columns
|
|
291
|
+
* with `cellOverflow: "truncate"` (or the default) stay
|
|
292
|
+
* single-line. Use `estimatedRowHeight` to reduce scroll-jank
|
|
293
|
+
* when rows haven't been measured yet. */
|
|
294
|
+
rowHeight?: number | "auto";
|
|
295
|
+
/** Estimated row height used by the virtualizer when
|
|
296
|
+
* `rowHeight="auto"`. Better estimates = less scroll-position
|
|
297
|
+
* jank before rows are measured. Defaults to 44. Ignored when
|
|
298
|
+
* `rowHeight` is a number. */
|
|
299
|
+
estimatedRowHeight?: number;
|
|
300
|
+
/** Header row height in pixels. Defaults to 44. */
|
|
301
|
+
headerHeight?: number;
|
|
302
|
+
/** Number of rows to render outside the visible area. Defaults to 5. */
|
|
303
|
+
overscan?: number;
|
|
304
|
+
/** Grid max height. If omitted, grid takes available space (when `fillHeight`). */
|
|
305
|
+
maxHeight?: number | string;
|
|
306
|
+
/**
|
|
307
|
+
* When `true` (default), the grid uses `h-full` and the row area scrolls inside the grid.
|
|
308
|
+
* When `false`, the grid is only as tall as toolbar + header + rows (`h-auto`), so sibling
|
|
309
|
+
* content (e.g. metadata) sits directly under the table without a large empty gap.
|
|
310
|
+
*/
|
|
311
|
+
fillHeight?: boolean;
|
|
312
|
+
/** Top offset for the sticky toolbar + header (px or CSS string). */
|
|
313
|
+
stickyTop?: number | string;
|
|
314
|
+
|
|
315
|
+
// ── Callbacks ──────────────────────────────────────────────────
|
|
316
|
+
} & DataGridCallbacks<TRow> & {
|
|
317
|
+
// ── Customisation ──────────────────────────────────────────────
|
|
318
|
+
/** Custom toolbar renderer. When `false`, toolbar is hidden entirely. */
|
|
319
|
+
toolbar?: false | ((ctx: DataGridToolbarContext<TRow>) => ReactNode);
|
|
320
|
+
/** Extra content rendered inside the default toolbar row, to the left of
|
|
321
|
+
* the built-in columns / export actions. Use this to slot in
|
|
322
|
+
* refresh buttons, custom toggles, row counts, etc. without giving up
|
|
323
|
+
* the built-in actions. Ignored if a custom `toolbar` render function
|
|
324
|
+
* is provided — that function owns the entire row. */
|
|
325
|
+
toolbarExtra?: ReactNode | ((ctx: DataGridToolbarContext<TRow>) => ReactNode);
|
|
326
|
+
/** Custom empty state. Defaults to a centered "No data" message. */
|
|
327
|
+
emptyState?: ReactNode;
|
|
328
|
+
/** Custom loading state. Defaults to skeleton rows. */
|
|
329
|
+
loadingState?: ReactNode;
|
|
330
|
+
/** Custom footer. When `false`, footer is hidden. */
|
|
331
|
+
footer?: false | ((ctx: DataGridFooterContext<TRow>) => ReactNode);
|
|
332
|
+
/** Extra content rendered to the right of the default footer info. */
|
|
333
|
+
footerExtra?: ReactNode | ((ctx: DataGridFooterContext<TRow>) => ReactNode);
|
|
334
|
+
|
|
335
|
+
/** Filename stem for CSV export (without extension). */
|
|
336
|
+
exportFilename?: string;
|
|
337
|
+
/** i18n overrides. */
|
|
338
|
+
strings?: Partial<DataGridStrings>;
|
|
339
|
+
|
|
340
|
+
className?: string;
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
// ─── Toolbar / footer context ────────────────────────────────────────
|
|
344
|
+
export type DataGridToolbarContext<TRow> = {
|
|
345
|
+
state: DataGridState;
|
|
346
|
+
onChange: React.Dispatch<React.SetStateAction<DataGridState>>;
|
|
347
|
+
columns: readonly DataGridColumnDef<TRow>[];
|
|
348
|
+
visibleColumns: readonly DataGridColumnDef<TRow>[];
|
|
349
|
+
totalRowCount: number | undefined;
|
|
350
|
+
selectedRowCount: number;
|
|
351
|
+
strings: DataGridStrings;
|
|
352
|
+
/** Trigger a CSV export. */
|
|
353
|
+
exportCsv: () => void;
|
|
354
|
+
};
|
|
355
|
+
|
|
356
|
+
export type DataGridFooterContext<TRow> = {
|
|
357
|
+
state: DataGridState;
|
|
358
|
+
totalRowCount: number | undefined;
|
|
359
|
+
visibleRowCount: number;
|
|
360
|
+
selectedRowCount: number;
|
|
361
|
+
paginationMode: DataGridPaginationMode;
|
|
362
|
+
strings: DataGridStrings;
|
|
363
|
+
};
|
|
364
|
+
|
|
365
|
+
// ─── Strings ─────────────────────────────────────────────────────────
|
|
366
|
+
export type DataGridStrings = {
|
|
367
|
+
// toolbar
|
|
368
|
+
searchPlaceholder: string;
|
|
369
|
+
columns: string;
|
|
370
|
+
export: string;
|
|
371
|
+
density: string;
|
|
372
|
+
// column manager
|
|
373
|
+
showAll: string;
|
|
374
|
+
hideAll: string;
|
|
375
|
+
resetColumns: string;
|
|
376
|
+
// date display
|
|
377
|
+
dateFormat: string;
|
|
378
|
+
dateFormatRelative: string;
|
|
379
|
+
dateFormatAbsolute: string;
|
|
380
|
+
// selection
|
|
381
|
+
rowsSelected: (count: number) => string;
|
|
382
|
+
// pagination
|
|
383
|
+
rowsPerPage: string;
|
|
384
|
+
pageOf: (page: number, total: number) => string;
|
|
385
|
+
// empty / loading
|
|
386
|
+
noData: string;
|
|
387
|
+
loading: string;
|
|
388
|
+
loadingMore: string;
|
|
389
|
+
// export
|
|
390
|
+
exportCsv: string;
|
|
391
|
+
exportCopied: string;
|
|
392
|
+
// sort
|
|
393
|
+
sortAsc: string;
|
|
394
|
+
sortDesc: string;
|
|
395
|
+
unsort: string;
|
|
396
|
+
// misc
|
|
397
|
+
pinLeft: string;
|
|
398
|
+
pinRight: string;
|
|
399
|
+
unpin: string;
|
|
400
|
+
hideColumn: string;
|
|
401
|
+
};
|