rockin 0.0.17 → 0.0.18
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/chunk-ULUHD3E2.js +389 -0
- package/dist/data-grid-C0CBtxDL.d.ts +117 -0
- package/dist/hooks/index.d.ts +57 -2
- package/dist/hooks/index.js +60 -1
- package/dist/ui/index.d.ts +1 -1
- package/dist/ui/index.js +23 -5
- package/package.json +1 -1
- package/dist/chunk-MO55ECUZ.js +0 -154
- package/dist/use-data-table-search-DY1swiC0.d.ts +0 -68
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
// src/ui/data-table/core/data-table-root.tsx
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { cn } from "cn";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
var DataTableContext = React.createContext(
|
|
6
|
+
null
|
|
7
|
+
);
|
|
8
|
+
function useDataTable() {
|
|
9
|
+
const context = React.useContext(DataTableContext);
|
|
10
|
+
if (!context) {
|
|
11
|
+
throw new Error(
|
|
12
|
+
"DataTable components must be rendered inside DataTableRoot"
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
return context;
|
|
16
|
+
}
|
|
17
|
+
function DataTableRoot({
|
|
18
|
+
data,
|
|
19
|
+
columns,
|
|
20
|
+
children,
|
|
21
|
+
isLoading = false,
|
|
22
|
+
pageSize = 10,
|
|
23
|
+
getRowId = (_, index) => String(index),
|
|
24
|
+
className
|
|
25
|
+
}) {
|
|
26
|
+
const [globalFilter, setGlobalFilterState] = React.useState("");
|
|
27
|
+
const [pageIndex, setPageIndexState] = React.useState(0);
|
|
28
|
+
const filteredData = React.useMemo(() => {
|
|
29
|
+
const query = globalFilter.trim().toLowerCase();
|
|
30
|
+
if (!query) return data;
|
|
31
|
+
return data.filter(
|
|
32
|
+
(row) => columns.some((column) => {
|
|
33
|
+
if (column.enableSearch === false) return false;
|
|
34
|
+
const value = column.accessorFn ? column.accessorFn(row) : column.accessorKey ? row[column.accessorKey] : void 0;
|
|
35
|
+
return String(value ?? "").toLowerCase().includes(query);
|
|
36
|
+
})
|
|
37
|
+
);
|
|
38
|
+
}, [columns, data, globalFilter]);
|
|
39
|
+
const safePageSize = Math.max(1, pageSize);
|
|
40
|
+
const pageCount = Math.max(1, Math.ceil(filteredData.length / safePageSize));
|
|
41
|
+
const safePageIndex = Math.min(pageIndex, pageCount - 1);
|
|
42
|
+
const pageData = filteredData.slice(
|
|
43
|
+
safePageIndex * safePageSize,
|
|
44
|
+
(safePageIndex + 1) * safePageSize
|
|
45
|
+
);
|
|
46
|
+
React.useEffect(() => {
|
|
47
|
+
setPageIndexState((current) => Math.min(current, pageCount - 1));
|
|
48
|
+
}, [pageCount]);
|
|
49
|
+
const contextValue = React.useMemo(
|
|
50
|
+
() => ({
|
|
51
|
+
data,
|
|
52
|
+
columns,
|
|
53
|
+
filteredData,
|
|
54
|
+
pageData,
|
|
55
|
+
pageIndex: safePageIndex,
|
|
56
|
+
pageSize: safePageSize,
|
|
57
|
+
pageCount,
|
|
58
|
+
globalFilter,
|
|
59
|
+
isLoading,
|
|
60
|
+
getRowId,
|
|
61
|
+
setGlobalFilter: (value) => {
|
|
62
|
+
setGlobalFilterState(value);
|
|
63
|
+
setPageIndexState(0);
|
|
64
|
+
},
|
|
65
|
+
setPageIndex: (value) => setPageIndexState(Math.max(0, Math.min(value, pageCount - 1)))
|
|
66
|
+
}),
|
|
67
|
+
[
|
|
68
|
+
columns,
|
|
69
|
+
filteredData,
|
|
70
|
+
pageCount,
|
|
71
|
+
pageData,
|
|
72
|
+
safePageIndex,
|
|
73
|
+
safePageSize,
|
|
74
|
+
globalFilter,
|
|
75
|
+
isLoading,
|
|
76
|
+
getRowId
|
|
77
|
+
]
|
|
78
|
+
);
|
|
79
|
+
return /* @__PURE__ */ jsx(DataTableContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx("div", { className: cn("w-full space-y-3", className), children }) });
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// src/ui/data-table/hooks/use-data-table-pagination.ts
|
|
83
|
+
function useDataTablePagination() {
|
|
84
|
+
const { pageIndex, pageSize, pageCount, setPageIndex } = useDataTable();
|
|
85
|
+
return {
|
|
86
|
+
pageIndex,
|
|
87
|
+
pageSize,
|
|
88
|
+
pageCount,
|
|
89
|
+
canPreviousPage: pageIndex > 0,
|
|
90
|
+
canNextPage: pageIndex < pageCount - 1,
|
|
91
|
+
goToPage: setPageIndex,
|
|
92
|
+
previousPage: () => setPageIndex(pageIndex - 1),
|
|
93
|
+
nextPage: () => setPageIndex(pageIndex + 1),
|
|
94
|
+
firstPage: () => setPageIndex(0),
|
|
95
|
+
lastPage: () => setPageIndex(pageCount - 1)
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// src/ui/data-table/hooks/use-data-table-rows.ts
|
|
100
|
+
function useDataTableRows() {
|
|
101
|
+
const { data, filteredData, pageData, isLoading } = useDataTable();
|
|
102
|
+
return {
|
|
103
|
+
data,
|
|
104
|
+
rows: pageData,
|
|
105
|
+
pageRows: pageData,
|
|
106
|
+
filteredRows: filteredData,
|
|
107
|
+
totalRows: filteredData.length,
|
|
108
|
+
isLoading
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// src/ui/data-table/hooks/use-data-table-search.ts
|
|
113
|
+
function useDataTableSearch() {
|
|
114
|
+
const { globalFilter, setGlobalFilter } = useDataTable();
|
|
115
|
+
return {
|
|
116
|
+
search: globalFilter,
|
|
117
|
+
setSearch: setGlobalFilter,
|
|
118
|
+
clearSearch: () => setGlobalFilter("")
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// src/ui/data-table/data-grid.tsx
|
|
123
|
+
import * as React2 from "react";
|
|
124
|
+
import { cn as cn2 } from "cn";
|
|
125
|
+
import { Fragment, jsx as jsx2 } from "react/jsx-runtime";
|
|
126
|
+
function useDataGrid({
|
|
127
|
+
columnIds = [],
|
|
128
|
+
columns,
|
|
129
|
+
initialRows = [],
|
|
130
|
+
getRowId = (row, index) => String(row.id ?? index)
|
|
131
|
+
} = {}) {
|
|
132
|
+
const [rows, setRows] = React2.useState(initialRows);
|
|
133
|
+
const resolvedColumns = React2.useMemo(
|
|
134
|
+
() => columns ?? columnIds.map((id) => ({
|
|
135
|
+
id,
|
|
136
|
+
accessorKey: id,
|
|
137
|
+
header: id
|
|
138
|
+
})),
|
|
139
|
+
[columnIds, columns]
|
|
140
|
+
);
|
|
141
|
+
const getRow = React2.useCallback(
|
|
142
|
+
(rowId) => rows.find((row, index) => getRowId(row, index) === rowId),
|
|
143
|
+
[getRowId, rows]
|
|
144
|
+
);
|
|
145
|
+
const getCellValue = React2.useCallback(
|
|
146
|
+
(rowId, columnId) => {
|
|
147
|
+
const row = getRow(rowId);
|
|
148
|
+
return row?.[columnId];
|
|
149
|
+
},
|
|
150
|
+
[getRow]
|
|
151
|
+
);
|
|
152
|
+
const updateCell = React2.useCallback(
|
|
153
|
+
(rowId, columnId, value) => {
|
|
154
|
+
setRows(
|
|
155
|
+
(current) => current.map(
|
|
156
|
+
(row, index) => getRowId(row, index) === rowId ? { ...row, [columnId]: value } : row
|
|
157
|
+
)
|
|
158
|
+
);
|
|
159
|
+
},
|
|
160
|
+
[getRowId]
|
|
161
|
+
);
|
|
162
|
+
const updateRows = React2.useCallback(
|
|
163
|
+
(updater) => setRows(updater),
|
|
164
|
+
[]
|
|
165
|
+
);
|
|
166
|
+
return React2.useMemo(
|
|
167
|
+
() => ({
|
|
168
|
+
rows,
|
|
169
|
+
columns: resolvedColumns,
|
|
170
|
+
getRowId,
|
|
171
|
+
getRow,
|
|
172
|
+
getCellValue,
|
|
173
|
+
updateCell,
|
|
174
|
+
updateRows
|
|
175
|
+
}),
|
|
176
|
+
[
|
|
177
|
+
getCellValue,
|
|
178
|
+
getRow,
|
|
179
|
+
getRowId,
|
|
180
|
+
resolvedColumns,
|
|
181
|
+
rows,
|
|
182
|
+
updateCell,
|
|
183
|
+
updateRows
|
|
184
|
+
]
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
var DataGridContext = React2.createContext(null);
|
|
188
|
+
function useDataGridContext() {
|
|
189
|
+
const context = React2.useContext(DataGridContext);
|
|
190
|
+
if (!context) throw new Error("DataGrid components must be inside DataGrid");
|
|
191
|
+
return context;
|
|
192
|
+
}
|
|
193
|
+
var DataGridCellContext = React2.createContext(null);
|
|
194
|
+
function DataGrid({
|
|
195
|
+
grid,
|
|
196
|
+
children,
|
|
197
|
+
className
|
|
198
|
+
}) {
|
|
199
|
+
return /* @__PURE__ */ jsx2(DataGridContext.Provider, { value: grid, children: /* @__PURE__ */ jsx2("div", { className: cn2("w-full space-y-2 outline-none", className), children }) });
|
|
200
|
+
}
|
|
201
|
+
function DataGridRow({
|
|
202
|
+
row,
|
|
203
|
+
rowId,
|
|
204
|
+
children,
|
|
205
|
+
className
|
|
206
|
+
}) {
|
|
207
|
+
const grid = useDataGridContext();
|
|
208
|
+
const resolvedRowId = rowId ?? (row ? grid.getRowId(row, 0) : "");
|
|
209
|
+
const resolvedRow = row ?? grid.getRow(resolvedRowId);
|
|
210
|
+
return /* @__PURE__ */ jsx2(
|
|
211
|
+
"div",
|
|
212
|
+
{
|
|
213
|
+
className: cn2(
|
|
214
|
+
"grid grid-cols-[repeat(var(--data-grid-columns),minmax(9rem,1fr))]",
|
|
215
|
+
className
|
|
216
|
+
),
|
|
217
|
+
children: resolvedRow && children
|
|
218
|
+
}
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
function DataGridColumn({
|
|
222
|
+
column,
|
|
223
|
+
children,
|
|
224
|
+
className
|
|
225
|
+
}) {
|
|
226
|
+
return /* @__PURE__ */ jsx2("div", { className: cn2("min-w-0", className), children: children ?? column.header });
|
|
227
|
+
}
|
|
228
|
+
function DataGridCell({
|
|
229
|
+
row,
|
|
230
|
+
rowId,
|
|
231
|
+
columnId,
|
|
232
|
+
children,
|
|
233
|
+
state = "valid",
|
|
234
|
+
className
|
|
235
|
+
}) {
|
|
236
|
+
const grid = useDataGridContext();
|
|
237
|
+
const resolvedRowId = rowId ?? (row ? grid.getRowId(row, 0) : "");
|
|
238
|
+
const value = grid.getCellValue(resolvedRowId, columnId);
|
|
239
|
+
return /* @__PURE__ */ jsx2(
|
|
240
|
+
DataGridCellContext.Provider,
|
|
241
|
+
{
|
|
242
|
+
value: { rowId: resolvedRowId, columnId, value },
|
|
243
|
+
children: /* @__PURE__ */ jsx2(
|
|
244
|
+
"div",
|
|
245
|
+
{
|
|
246
|
+
"aria-invalid": state === "invalid" || void 0,
|
|
247
|
+
className: cn2(
|
|
248
|
+
"min-h-9 border-r border-b px-2 py-1.5",
|
|
249
|
+
state === "invalid" && "border-destructive/60 bg-destructive/10",
|
|
250
|
+
state === "pending" && "opacity-70",
|
|
251
|
+
className
|
|
252
|
+
),
|
|
253
|
+
children
|
|
254
|
+
}
|
|
255
|
+
)
|
|
256
|
+
}
|
|
257
|
+
);
|
|
258
|
+
}
|
|
259
|
+
function useGridCell() {
|
|
260
|
+
const cell = React2.useContext(DataGridCellContext);
|
|
261
|
+
const grid = useDataGridContext();
|
|
262
|
+
if (!cell) throw new Error("Grid cell components must be inside DataGridCell");
|
|
263
|
+
return { ...cell, grid };
|
|
264
|
+
}
|
|
265
|
+
function GridTextCell({
|
|
266
|
+
value,
|
|
267
|
+
onChange,
|
|
268
|
+
placeholder
|
|
269
|
+
}) {
|
|
270
|
+
const cell = useGridCell();
|
|
271
|
+
const currentValue = value ?? String(cell.value ?? "");
|
|
272
|
+
return /* @__PURE__ */ jsx2(
|
|
273
|
+
"input",
|
|
274
|
+
{
|
|
275
|
+
className: "h-7 w-full min-w-0 bg-transparent text-sm outline-none placeholder:text-muted-foreground",
|
|
276
|
+
onChange: (event) => {
|
|
277
|
+
const nextValue = event.target.value;
|
|
278
|
+
onChange?.(nextValue);
|
|
279
|
+
cell.grid.updateCell(cell.rowId, cell.columnId, nextValue);
|
|
280
|
+
},
|
|
281
|
+
placeholder,
|
|
282
|
+
value: currentValue
|
|
283
|
+
}
|
|
284
|
+
);
|
|
285
|
+
}
|
|
286
|
+
function GridNumberCell({
|
|
287
|
+
value,
|
|
288
|
+
onChange
|
|
289
|
+
}) {
|
|
290
|
+
const cell = useGridCell();
|
|
291
|
+
const currentValue = value ?? (typeof cell.value === "number" ? cell.value : "");
|
|
292
|
+
return /* @__PURE__ */ jsx2(
|
|
293
|
+
"input",
|
|
294
|
+
{
|
|
295
|
+
className: "h-7 w-full min-w-0 bg-transparent text-sm outline-none",
|
|
296
|
+
onChange: (event) => {
|
|
297
|
+
const nextValue = event.target.valueAsNumber;
|
|
298
|
+
if (Number.isNaN(nextValue)) return;
|
|
299
|
+
onChange?.(nextValue);
|
|
300
|
+
cell.grid.updateCell(cell.rowId, cell.columnId, nextValue);
|
|
301
|
+
},
|
|
302
|
+
type: "number",
|
|
303
|
+
value: currentValue
|
|
304
|
+
}
|
|
305
|
+
);
|
|
306
|
+
}
|
|
307
|
+
function GridComboboxCell({
|
|
308
|
+
options,
|
|
309
|
+
value,
|
|
310
|
+
onChange
|
|
311
|
+
}) {
|
|
312
|
+
const cell = useGridCell();
|
|
313
|
+
const currentValue = value ?? String(cell.value ?? "");
|
|
314
|
+
return /* @__PURE__ */ jsx2(
|
|
315
|
+
"select",
|
|
316
|
+
{
|
|
317
|
+
className: "h-7 w-full min-w-0 bg-transparent text-sm outline-none",
|
|
318
|
+
onChange: (event) => {
|
|
319
|
+
const nextValue = event.target.value;
|
|
320
|
+
onChange?.(nextValue);
|
|
321
|
+
cell.grid.updateCell(cell.rowId, cell.columnId, nextValue);
|
|
322
|
+
},
|
|
323
|
+
value: currentValue,
|
|
324
|
+
children: options.map((option) => /* @__PURE__ */ jsx2("option", { value: option.value, children: option.label }, option.value))
|
|
325
|
+
}
|
|
326
|
+
);
|
|
327
|
+
}
|
|
328
|
+
function DataTableColumnResize() {
|
|
329
|
+
return /* @__PURE__ */ jsx2("span", { "aria-hidden": true, className: "absolute inset-y-0 right-0 w-px" });
|
|
330
|
+
}
|
|
331
|
+
function DataGridClipboard({
|
|
332
|
+
children
|
|
333
|
+
}) {
|
|
334
|
+
return /* @__PURE__ */ jsx2(Fragment, { children });
|
|
335
|
+
}
|
|
336
|
+
function DataGridFillHandle({
|
|
337
|
+
children
|
|
338
|
+
}) {
|
|
339
|
+
return /* @__PURE__ */ jsx2(Fragment, { children });
|
|
340
|
+
}
|
|
341
|
+
function DataGridMove({ children }) {
|
|
342
|
+
return /* @__PURE__ */ jsx2(Fragment, { children });
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
// src/hooks/useMediaQuery.ts
|
|
346
|
+
import { useEffect as useEffect2, useState as useState3 } from "react";
|
|
347
|
+
function useMediaQuery(query) {
|
|
348
|
+
const [matches, setMatches] = useState3(false);
|
|
349
|
+
useEffect2(() => {
|
|
350
|
+
const mediaQuery = window.matchMedia(query);
|
|
351
|
+
const handleChange = () => setMatches(mediaQuery.matches);
|
|
352
|
+
handleChange();
|
|
353
|
+
mediaQuery.addEventListener("change", handleChange);
|
|
354
|
+
return () => mediaQuery.removeEventListener("change", handleChange);
|
|
355
|
+
}, [query]);
|
|
356
|
+
return matches;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
// src/hooks/useMounted.ts
|
|
360
|
+
import { useEffect as useEffect3, useState as useState4 } from "react";
|
|
361
|
+
function useMounted() {
|
|
362
|
+
const [mounted, setMounted] = useState4(false);
|
|
363
|
+
useEffect3(() => {
|
|
364
|
+
setMounted(true);
|
|
365
|
+
}, []);
|
|
366
|
+
return { mounted };
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
export {
|
|
370
|
+
useDataTable,
|
|
371
|
+
DataTableRoot,
|
|
372
|
+
useDataTablePagination,
|
|
373
|
+
useDataTableRows,
|
|
374
|
+
useDataTableSearch,
|
|
375
|
+
useDataGrid,
|
|
376
|
+
DataGrid,
|
|
377
|
+
DataGridRow,
|
|
378
|
+
DataGridColumn,
|
|
379
|
+
DataGridCell,
|
|
380
|
+
GridTextCell,
|
|
381
|
+
GridNumberCell,
|
|
382
|
+
GridComboboxCell,
|
|
383
|
+
DataTableColumnResize,
|
|
384
|
+
DataGridClipboard,
|
|
385
|
+
DataGridFillHandle,
|
|
386
|
+
DataGridMove,
|
|
387
|
+
useMediaQuery,
|
|
388
|
+
useMounted
|
|
389
|
+
};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
type DataTableColumn<TData> = {
|
|
5
|
+
id?: string;
|
|
6
|
+
accessorKey?: keyof TData & string;
|
|
7
|
+
accessorFn?: (row: TData) => unknown;
|
|
8
|
+
header: ReactNode | ((column: DataTableColumn<TData>) => ReactNode);
|
|
9
|
+
cell?: (value: unknown, row: TData, rowIndex: number) => ReactNode;
|
|
10
|
+
enableSearch?: boolean;
|
|
11
|
+
};
|
|
12
|
+
type DataTableColumnDef<TData> = DataTableColumn<TData>;
|
|
13
|
+
type DataTableRootProps<TData> = {
|
|
14
|
+
data: TData[];
|
|
15
|
+
columns: DataTableColumn<TData>[];
|
|
16
|
+
children: ReactNode;
|
|
17
|
+
isLoading?: boolean;
|
|
18
|
+
pageSize?: number;
|
|
19
|
+
getRowId?: (row: TData, index: number) => string;
|
|
20
|
+
className?: string;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
type DataTableContextValue<TData> = {
|
|
24
|
+
data: TData[];
|
|
25
|
+
columns: DataTableColumn<TData>[];
|
|
26
|
+
filteredData: TData[];
|
|
27
|
+
pageData: TData[];
|
|
28
|
+
pageIndex: number;
|
|
29
|
+
pageSize: number;
|
|
30
|
+
pageCount: number;
|
|
31
|
+
globalFilter: string;
|
|
32
|
+
isLoading: boolean;
|
|
33
|
+
getRowId: (row: TData, index: number) => string;
|
|
34
|
+
setGlobalFilter: (value: string) => void;
|
|
35
|
+
setPageIndex: (value: number) => void;
|
|
36
|
+
};
|
|
37
|
+
declare function useDataTable<TData>(): DataTableContextValue<TData>;
|
|
38
|
+
declare function DataTableRoot<TData>({ data, columns, children, isLoading, pageSize, getRowId, className, }: DataTableRootProps<TData>): React.JSX.Element;
|
|
39
|
+
|
|
40
|
+
type CellState = "valid" | "invalid" | "pending";
|
|
41
|
+
type DataGridValue = string | number | boolean | null | undefined;
|
|
42
|
+
type DataGridApi<TData extends Record<string, unknown>> = {
|
|
43
|
+
rows: TData[];
|
|
44
|
+
columns: DataGridColumn<TData>[];
|
|
45
|
+
getRowId: (row: TData, index: number) => string;
|
|
46
|
+
getRow: (rowId: string) => TData | undefined;
|
|
47
|
+
getCellValue: (rowId: string, columnId: string) => DataGridValue;
|
|
48
|
+
updateCell: (rowId: string, columnId: string, value: DataGridValue) => void;
|
|
49
|
+
updateRows: (updater: (rows: TData[]) => TData[]) => void;
|
|
50
|
+
};
|
|
51
|
+
type UseDataGridOptions<TData extends Record<string, unknown>> = {
|
|
52
|
+
columnIds?: string[];
|
|
53
|
+
columns?: DataGridColumn<TData>[];
|
|
54
|
+
initialRows?: TData[];
|
|
55
|
+
createEmptyRow?: () => TData;
|
|
56
|
+
getRowId?: (row: TData, index: number) => string;
|
|
57
|
+
};
|
|
58
|
+
declare function useDataGrid<TData extends Record<string, unknown>>({ columnIds, columns, initialRows, getRowId, }?: UseDataGridOptions<TData>): DataGridApi<TData>;
|
|
59
|
+
declare function DataGrid<TData extends Record<string, unknown>>({ grid, children, className, }: {
|
|
60
|
+
grid: DataGridApi<TData>;
|
|
61
|
+
children?: React.ReactNode;
|
|
62
|
+
className?: string;
|
|
63
|
+
}): React.JSX.Element;
|
|
64
|
+
declare function DataGridRow({ row, rowId, children, className, }: {
|
|
65
|
+
row?: Record<string, unknown>;
|
|
66
|
+
rowId?: string;
|
|
67
|
+
children?: React.ReactNode;
|
|
68
|
+
className?: string;
|
|
69
|
+
}): React.JSX.Element;
|
|
70
|
+
type DataGridColumn<TData = Record<string, unknown>> = {
|
|
71
|
+
id: string;
|
|
72
|
+
header?: React.ReactNode;
|
|
73
|
+
accessorKey?: keyof TData & string;
|
|
74
|
+
width?: number;
|
|
75
|
+
};
|
|
76
|
+
declare function DataGridColumn({ column, children, className, }: {
|
|
77
|
+
column: DataGridColumn;
|
|
78
|
+
children?: React.ReactNode;
|
|
79
|
+
className?: string;
|
|
80
|
+
}): React.JSX.Element;
|
|
81
|
+
declare function DataGridCell({ row, rowId, columnId, children, state, className, }: {
|
|
82
|
+
row?: Record<string, unknown>;
|
|
83
|
+
rowId?: string;
|
|
84
|
+
columnId: string;
|
|
85
|
+
children?: React.ReactNode;
|
|
86
|
+
state?: CellState;
|
|
87
|
+
className?: string;
|
|
88
|
+
}): React.JSX.Element;
|
|
89
|
+
declare function GridTextCell({ value, onChange, placeholder, }: {
|
|
90
|
+
value?: string;
|
|
91
|
+
onChange?: (value: string) => void;
|
|
92
|
+
placeholder?: string;
|
|
93
|
+
}): React.JSX.Element;
|
|
94
|
+
declare function GridNumberCell({ value, onChange, }: {
|
|
95
|
+
value?: number;
|
|
96
|
+
onChange?: (value: number) => void;
|
|
97
|
+
}): React.JSX.Element;
|
|
98
|
+
declare function GridComboboxCell({ options, value, onChange, }: {
|
|
99
|
+
options: {
|
|
100
|
+
label: string;
|
|
101
|
+
value: string;
|
|
102
|
+
}[];
|
|
103
|
+
value?: string;
|
|
104
|
+
onChange?: (value: string) => void;
|
|
105
|
+
}): React.JSX.Element;
|
|
106
|
+
declare function DataTableColumnResize(): React.JSX.Element;
|
|
107
|
+
declare function DataGridClipboard({ children, }: {
|
|
108
|
+
children?: React.ReactNode;
|
|
109
|
+
}): React.JSX.Element;
|
|
110
|
+
declare function DataGridFillHandle({ children, }: {
|
|
111
|
+
children?: React.ReactNode;
|
|
112
|
+
}): React.JSX.Element;
|
|
113
|
+
declare function DataGridMove({ children }: {
|
|
114
|
+
children?: React.ReactNode;
|
|
115
|
+
}): React.JSX.Element;
|
|
116
|
+
|
|
117
|
+
export { type CellState as C, type DataGridApi as D, GridComboboxCell as G, type UseDataGridOptions as U, useDataTable as a, DataGrid as b, DataGridCell as c, DataGridClipboard as d, DataGridColumn as e, DataGridFillHandle as f, DataGridMove as g, DataGridRow as h, type DataTableColumn as i, type DataTableColumnDef as j, DataTableColumnResize as k, DataTableRoot as l, type DataTableRootProps as m, GridNumberCell as n, GridTextCell as o, useDataGrid as u };
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { D as DataGridApi } from '../data-grid-C0CBtxDL.js';
|
|
2
|
+
export { u as useDataGrid, a as useDataTable } from '../data-grid-C0CBtxDL.js';
|
|
2
3
|
export { NuqsAdapter } from 'nuqs/adapters/next/app';
|
|
3
4
|
import 'react';
|
|
4
5
|
|
|
@@ -56,4 +57,58 @@ declare function useSearchParams(): {
|
|
|
56
57
|
transactionPage: number;
|
|
57
58
|
};
|
|
58
59
|
|
|
59
|
-
|
|
60
|
+
declare function useDataTablePagination(): {
|
|
61
|
+
pageIndex: number;
|
|
62
|
+
pageSize: number;
|
|
63
|
+
pageCount: number;
|
|
64
|
+
canPreviousPage: boolean;
|
|
65
|
+
canNextPage: boolean;
|
|
66
|
+
goToPage: (value: number) => void;
|
|
67
|
+
previousPage: () => void;
|
|
68
|
+
nextPage: () => void;
|
|
69
|
+
firstPage: () => void;
|
|
70
|
+
lastPage: () => void;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
declare function useDataTableRows<TData>(): {
|
|
74
|
+
data: TData[];
|
|
75
|
+
rows: TData[];
|
|
76
|
+
pageRows: TData[];
|
|
77
|
+
filteredRows: TData[];
|
|
78
|
+
totalRows: number;
|
|
79
|
+
isLoading: boolean;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
declare function useDataTableSearch(): {
|
|
83
|
+
search: string;
|
|
84
|
+
setSearch: (value: string) => void;
|
|
85
|
+
clearSearch: () => void;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
declare function useDataGridClipboard(): {
|
|
89
|
+
copy: (value: string) => Promise<void>;
|
|
90
|
+
read: () => Promise<string>;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
declare function useDataGridFillHandle(): {
|
|
94
|
+
enabled: boolean;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
declare function useDataGridMove(): {
|
|
98
|
+
enabled: boolean;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
declare function useGridChanges<TData extends Record<string, unknown>>(grid: DataGridApi<TData>, options?: {
|
|
102
|
+
initialRows?: TData[];
|
|
103
|
+
}): {
|
|
104
|
+
dirtyRowIds: Set<string>;
|
|
105
|
+
updateCell: (rowId: string, columnId: string, value: unknown) => void;
|
|
106
|
+
getChangeSet: () => {
|
|
107
|
+
created: TData[];
|
|
108
|
+
updated: TData[];
|
|
109
|
+
deleted: TData[];
|
|
110
|
+
};
|
|
111
|
+
reset: () => void;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
export { searchFocus, useDataGridClipboard, useDataGridFillHandle, useDataGridMove, useDataTablePagination, useDataTableRows, useDataTableSearch, useFullscreen, useGridChanges, useMediaQuery, useMounted, useNative, useSearchParams };
|
package/dist/hooks/index.js
CHANGED
|
@@ -10,13 +10,14 @@ import {
|
|
|
10
10
|
useNative
|
|
11
11
|
} from "../chunk-RT2YVQ2Y.js";
|
|
12
12
|
import {
|
|
13
|
+
useDataGrid,
|
|
13
14
|
useDataTable,
|
|
14
15
|
useDataTablePagination,
|
|
15
16
|
useDataTableRows,
|
|
16
17
|
useDataTableSearch,
|
|
17
18
|
useMediaQuery,
|
|
18
19
|
useMounted
|
|
19
|
-
} from "../chunk-
|
|
20
|
+
} from "../chunk-ULUHD3E2.js";
|
|
20
21
|
import "../chunk-ATPUW3SQ.js";
|
|
21
22
|
|
|
22
23
|
// src/hooks/useSearchParams.ts
|
|
@@ -258,14 +259,72 @@ function useSearchParams() {
|
|
|
258
259
|
)
|
|
259
260
|
};
|
|
260
261
|
}
|
|
262
|
+
|
|
263
|
+
// src/ui/data-table/hooks/use-data-grid-clipboard.ts
|
|
264
|
+
function useDataGridClipboard() {
|
|
265
|
+
return {
|
|
266
|
+
copy: async (value) => navigator.clipboard?.writeText(value),
|
|
267
|
+
read: async () => navigator.clipboard?.readText() ?? ""
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// src/ui/data-table/hooks/use-data-grid-fill-handle.ts
|
|
272
|
+
function useDataGridFillHandle() {
|
|
273
|
+
return { enabled: true };
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
// src/ui/data-table/hooks/use-data-grid-move.ts
|
|
277
|
+
function useDataGridMove() {
|
|
278
|
+
return { enabled: true };
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
// src/ui/data-table/hooks/use-grid-changes.ts
|
|
282
|
+
import * as React2 from "react";
|
|
283
|
+
function useGridChanges(grid, options = {}) {
|
|
284
|
+
const initialRows = options.initialRows ?? [];
|
|
285
|
+
const [dirtyRowIds, setDirtyRowIds] = React2.useState(/* @__PURE__ */ new Set());
|
|
286
|
+
const updateCell = React2.useCallback(
|
|
287
|
+
(rowId, columnId, value) => {
|
|
288
|
+
grid.updateCell(rowId, columnId, value);
|
|
289
|
+
setDirtyRowIds((current) => new Set(current).add(rowId));
|
|
290
|
+
},
|
|
291
|
+
[grid]
|
|
292
|
+
);
|
|
293
|
+
const getChangeSet = React2.useCallback(() => {
|
|
294
|
+
const created = [];
|
|
295
|
+
const updated = [];
|
|
296
|
+
const initialById = new Map(
|
|
297
|
+
initialRows.map((row, index) => [grid.getRowId(row, index), row])
|
|
298
|
+
);
|
|
299
|
+
for (const row of grid.rows) {
|
|
300
|
+
const rowId = grid.getRowId(row, grid.rows.indexOf(row));
|
|
301
|
+
if (!dirtyRowIds.has(rowId)) continue;
|
|
302
|
+
if (initialById.has(rowId)) updated.push(row);
|
|
303
|
+
else created.push(row);
|
|
304
|
+
}
|
|
305
|
+
return { created, updated, deleted: [] };
|
|
306
|
+
}, [dirtyRowIds, grid, initialRows]);
|
|
307
|
+
const reset = React2.useCallback(() => setDirtyRowIds(/* @__PURE__ */ new Set()), []);
|
|
308
|
+
return {
|
|
309
|
+
dirtyRowIds,
|
|
310
|
+
updateCell,
|
|
311
|
+
getChangeSet,
|
|
312
|
+
reset
|
|
313
|
+
};
|
|
314
|
+
}
|
|
261
315
|
export {
|
|
262
316
|
NuqsAdapter,
|
|
263
317
|
searchFocus,
|
|
318
|
+
useDataGrid,
|
|
319
|
+
useDataGridClipboard,
|
|
320
|
+
useDataGridFillHandle,
|
|
321
|
+
useDataGridMove,
|
|
264
322
|
useDataTable,
|
|
265
323
|
useDataTablePagination,
|
|
266
324
|
useDataTableRows,
|
|
267
325
|
useDataTableSearch,
|
|
268
326
|
useFullscreen,
|
|
327
|
+
useGridChanges,
|
|
269
328
|
useMediaQuery,
|
|
270
329
|
useMounted,
|
|
271
330
|
useNative,
|
package/dist/ui/index.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ import { Combobox as Combobox$1 } from '@base-ui/react';
|
|
|
21
21
|
import { Command as Command$1 } from 'cmdk';
|
|
22
22
|
export { useCommandState } from 'cmdk';
|
|
23
23
|
import { Dialog as Dialog$1 } from '@base-ui/react/dialog';
|
|
24
|
-
export { D as
|
|
24
|
+
export { C as CellState, b as DataGrid, D as DataGridApi, c as DataGridCell, d as DataGridClipboard, e as DataGridColumn, e as DataGridColumnDef, f as DataGridFillHandle, g as DataGridMove, h as DataGridRow, i as DataTableColumn, j as DataTableColumnDef, k as DataTableColumnResize, l as DataTableRoot, m as DataTableRootProps, G as GridComboboxCell, n as GridNumberCell, o as GridTextCell, U as UseDataGridOptions } from '../data-grid-C0CBtxDL.js';
|
|
25
25
|
import { LucideIcon } from 'lucide-react';
|
|
26
26
|
import { Drawer as Drawer$1 } from '@base-ui/react/drawer';
|
|
27
27
|
import { Menu } from '@base-ui/react/menu';
|
package/dist/ui/index.js
CHANGED
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
|
+
DataGrid,
|
|
4
|
+
DataGridCell,
|
|
5
|
+
DataGridClipboard,
|
|
6
|
+
DataGridColumn,
|
|
7
|
+
DataGridFillHandle,
|
|
8
|
+
DataGridMove,
|
|
9
|
+
DataGridRow,
|
|
10
|
+
DataTableColumnResize,
|
|
3
11
|
DataTableRoot,
|
|
12
|
+
GridComboboxCell,
|
|
13
|
+
GridNumberCell,
|
|
14
|
+
GridTextCell,
|
|
4
15
|
useDataTable,
|
|
5
16
|
useDataTablePagination,
|
|
6
17
|
useDataTableRows,
|
|
7
18
|
useDataTableSearch,
|
|
8
19
|
useMediaQuery,
|
|
9
20
|
useMounted
|
|
10
|
-
} from "../chunk-
|
|
21
|
+
} from "../chunk-ULUHD3E2.js";
|
|
11
22
|
import {
|
|
12
23
|
Tooltip,
|
|
13
24
|
TooltipContent,
|
|
@@ -8709,9 +8720,17 @@ export {
|
|
|
8709
8720
|
DEFAULT_I18N,
|
|
8710
8721
|
DEFAULT_OPERATORS,
|
|
8711
8722
|
DashedSeparator,
|
|
8723
|
+
DataGrid,
|
|
8724
|
+
DataGridCell,
|
|
8725
|
+
DataGridClipboard,
|
|
8726
|
+
DataGridColumn,
|
|
8727
|
+
DataGridFillHandle,
|
|
8728
|
+
DataGridMove,
|
|
8729
|
+
DataGridRow,
|
|
8712
8730
|
DataTable,
|
|
8713
8731
|
DataTableBody,
|
|
8714
8732
|
DataTableCell,
|
|
8733
|
+
DataTableColumnResize,
|
|
8715
8734
|
DataTableEmptyBody,
|
|
8716
8735
|
DataTableHeader,
|
|
8717
8736
|
DataTablePagination,
|
|
@@ -8780,6 +8799,9 @@ export {
|
|
|
8780
8799
|
FieldTitle,
|
|
8781
8800
|
Filters,
|
|
8782
8801
|
FiltersContent,
|
|
8802
|
+
GridComboboxCell,
|
|
8803
|
+
GridNumberCell,
|
|
8804
|
+
GridTextCell,
|
|
8783
8805
|
Image,
|
|
8784
8806
|
Input,
|
|
8785
8807
|
InputGroup,
|
|
@@ -8915,10 +8937,6 @@ export {
|
|
|
8915
8937
|
useCarousel,
|
|
8916
8938
|
useComboboxAnchor,
|
|
8917
8939
|
useCommandState,
|
|
8918
|
-
useDataTable,
|
|
8919
|
-
useDataTablePagination,
|
|
8920
|
-
useDataTableRows,
|
|
8921
|
-
useDataTableSearch,
|
|
8922
8940
|
useJellyMood,
|
|
8923
8941
|
useMessageScroller,
|
|
8924
8942
|
useMessageScrollerScrollable,
|
package/package.json
CHANGED
package/dist/chunk-MO55ECUZ.js
DELETED
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
// src/ui/data-table/core/data-table-root.tsx
|
|
2
|
-
import * as React from "react";
|
|
3
|
-
import { cn } from "cn";
|
|
4
|
-
import { jsx } from "react/jsx-runtime";
|
|
5
|
-
var DataTableContext = React.createContext(
|
|
6
|
-
null
|
|
7
|
-
);
|
|
8
|
-
function useDataTable() {
|
|
9
|
-
const context = React.useContext(DataTableContext);
|
|
10
|
-
if (!context) {
|
|
11
|
-
throw new Error(
|
|
12
|
-
"DataTable components must be rendered inside DataTableRoot"
|
|
13
|
-
);
|
|
14
|
-
}
|
|
15
|
-
return context;
|
|
16
|
-
}
|
|
17
|
-
function DataTableRoot({
|
|
18
|
-
data,
|
|
19
|
-
columns,
|
|
20
|
-
children,
|
|
21
|
-
isLoading = false,
|
|
22
|
-
pageSize = 10,
|
|
23
|
-
getRowId = (_, index) => String(index),
|
|
24
|
-
className
|
|
25
|
-
}) {
|
|
26
|
-
const [globalFilter, setGlobalFilterState] = React.useState("");
|
|
27
|
-
const [pageIndex, setPageIndexState] = React.useState(0);
|
|
28
|
-
const filteredData = React.useMemo(() => {
|
|
29
|
-
const query = globalFilter.trim().toLowerCase();
|
|
30
|
-
if (!query) return data;
|
|
31
|
-
return data.filter(
|
|
32
|
-
(row) => columns.some((column) => {
|
|
33
|
-
if (column.enableSearch === false) return false;
|
|
34
|
-
const value = column.accessorFn ? column.accessorFn(row) : column.accessorKey ? row[column.accessorKey] : void 0;
|
|
35
|
-
return String(value ?? "").toLowerCase().includes(query);
|
|
36
|
-
})
|
|
37
|
-
);
|
|
38
|
-
}, [columns, data, globalFilter]);
|
|
39
|
-
const safePageSize = Math.max(1, pageSize);
|
|
40
|
-
const pageCount = Math.max(1, Math.ceil(filteredData.length / safePageSize));
|
|
41
|
-
const safePageIndex = Math.min(pageIndex, pageCount - 1);
|
|
42
|
-
const pageData = filteredData.slice(
|
|
43
|
-
safePageIndex * safePageSize,
|
|
44
|
-
(safePageIndex + 1) * safePageSize
|
|
45
|
-
);
|
|
46
|
-
React.useEffect(() => {
|
|
47
|
-
setPageIndexState((current) => Math.min(current, pageCount - 1));
|
|
48
|
-
}, [pageCount]);
|
|
49
|
-
const contextValue = React.useMemo(
|
|
50
|
-
() => ({
|
|
51
|
-
data,
|
|
52
|
-
columns,
|
|
53
|
-
filteredData,
|
|
54
|
-
pageData,
|
|
55
|
-
pageIndex: safePageIndex,
|
|
56
|
-
pageSize: safePageSize,
|
|
57
|
-
pageCount,
|
|
58
|
-
globalFilter,
|
|
59
|
-
isLoading,
|
|
60
|
-
getRowId,
|
|
61
|
-
setGlobalFilter: (value) => {
|
|
62
|
-
setGlobalFilterState(value);
|
|
63
|
-
setPageIndexState(0);
|
|
64
|
-
},
|
|
65
|
-
setPageIndex: (value) => setPageIndexState(Math.max(0, Math.min(value, pageCount - 1)))
|
|
66
|
-
}),
|
|
67
|
-
[
|
|
68
|
-
columns,
|
|
69
|
-
filteredData,
|
|
70
|
-
pageCount,
|
|
71
|
-
pageData,
|
|
72
|
-
safePageIndex,
|
|
73
|
-
safePageSize,
|
|
74
|
-
globalFilter,
|
|
75
|
-
isLoading,
|
|
76
|
-
getRowId
|
|
77
|
-
]
|
|
78
|
-
);
|
|
79
|
-
return /* @__PURE__ */ jsx(DataTableContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx("div", { className: cn("w-full space-y-3", className), children }) });
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// src/ui/data-table/hooks/use-data-table-pagination.ts
|
|
83
|
-
function useDataTablePagination() {
|
|
84
|
-
const { pageIndex, pageSize, pageCount, setPageIndex } = useDataTable();
|
|
85
|
-
return {
|
|
86
|
-
pageIndex,
|
|
87
|
-
pageSize,
|
|
88
|
-
pageCount,
|
|
89
|
-
canPreviousPage: pageIndex > 0,
|
|
90
|
-
canNextPage: pageIndex < pageCount - 1,
|
|
91
|
-
goToPage: setPageIndex,
|
|
92
|
-
previousPage: () => setPageIndex(pageIndex - 1),
|
|
93
|
-
nextPage: () => setPageIndex(pageIndex + 1),
|
|
94
|
-
firstPage: () => setPageIndex(0),
|
|
95
|
-
lastPage: () => setPageIndex(pageCount - 1)
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
// src/ui/data-table/hooks/use-data-table-rows.ts
|
|
100
|
-
function useDataTableRows() {
|
|
101
|
-
const { data, filteredData, pageData, isLoading } = useDataTable();
|
|
102
|
-
return {
|
|
103
|
-
data,
|
|
104
|
-
rows: pageData,
|
|
105
|
-
pageRows: pageData,
|
|
106
|
-
filteredRows: filteredData,
|
|
107
|
-
totalRows: filteredData.length,
|
|
108
|
-
isLoading
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
// src/ui/data-table/hooks/use-data-table-search.ts
|
|
113
|
-
function useDataTableSearch() {
|
|
114
|
-
const { globalFilter, setGlobalFilter } = useDataTable();
|
|
115
|
-
return {
|
|
116
|
-
search: globalFilter,
|
|
117
|
-
setSearch: setGlobalFilter,
|
|
118
|
-
clearSearch: () => setGlobalFilter("")
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// src/hooks/useMediaQuery.ts
|
|
123
|
-
import { useEffect as useEffect2, useState as useState2 } from "react";
|
|
124
|
-
function useMediaQuery(query) {
|
|
125
|
-
const [matches, setMatches] = useState2(false);
|
|
126
|
-
useEffect2(() => {
|
|
127
|
-
const mediaQuery = window.matchMedia(query);
|
|
128
|
-
const handleChange = () => setMatches(mediaQuery.matches);
|
|
129
|
-
handleChange();
|
|
130
|
-
mediaQuery.addEventListener("change", handleChange);
|
|
131
|
-
return () => mediaQuery.removeEventListener("change", handleChange);
|
|
132
|
-
}, [query]);
|
|
133
|
-
return matches;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// src/hooks/useMounted.ts
|
|
137
|
-
import { useEffect as useEffect3, useState as useState3 } from "react";
|
|
138
|
-
function useMounted() {
|
|
139
|
-
const [mounted, setMounted] = useState3(false);
|
|
140
|
-
useEffect3(() => {
|
|
141
|
-
setMounted(true);
|
|
142
|
-
}, []);
|
|
143
|
-
return { mounted };
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
export {
|
|
147
|
-
useDataTable,
|
|
148
|
-
DataTableRoot,
|
|
149
|
-
useDataTablePagination,
|
|
150
|
-
useDataTableRows,
|
|
151
|
-
useDataTableSearch,
|
|
152
|
-
useMediaQuery,
|
|
153
|
-
useMounted
|
|
154
|
-
};
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { ReactNode } from 'react';
|
|
3
|
-
|
|
4
|
-
type DataTableColumn<TData> = {
|
|
5
|
-
id?: string;
|
|
6
|
-
accessorKey?: keyof TData & string;
|
|
7
|
-
accessorFn?: (row: TData) => unknown;
|
|
8
|
-
header: ReactNode | ((column: DataTableColumn<TData>) => ReactNode);
|
|
9
|
-
cell?: (value: unknown, row: TData, rowIndex: number) => ReactNode;
|
|
10
|
-
enableSearch?: boolean;
|
|
11
|
-
};
|
|
12
|
-
type DataTableColumnDef<TData> = DataTableColumn<TData>;
|
|
13
|
-
type DataTableRootProps<TData> = {
|
|
14
|
-
data: TData[];
|
|
15
|
-
columns: DataTableColumn<TData>[];
|
|
16
|
-
children: ReactNode;
|
|
17
|
-
isLoading?: boolean;
|
|
18
|
-
pageSize?: number;
|
|
19
|
-
getRowId?: (row: TData, index: number) => string;
|
|
20
|
-
className?: string;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
type DataTableContextValue<TData> = {
|
|
24
|
-
data: TData[];
|
|
25
|
-
columns: DataTableColumn<TData>[];
|
|
26
|
-
filteredData: TData[];
|
|
27
|
-
pageData: TData[];
|
|
28
|
-
pageIndex: number;
|
|
29
|
-
pageSize: number;
|
|
30
|
-
pageCount: number;
|
|
31
|
-
globalFilter: string;
|
|
32
|
-
isLoading: boolean;
|
|
33
|
-
getRowId: (row: TData, index: number) => string;
|
|
34
|
-
setGlobalFilter: (value: string) => void;
|
|
35
|
-
setPageIndex: (value: number) => void;
|
|
36
|
-
};
|
|
37
|
-
declare function useDataTable<TData>(): DataTableContextValue<TData>;
|
|
38
|
-
declare function DataTableRoot<TData>({ data, columns, children, isLoading, pageSize, getRowId, className, }: DataTableRootProps<TData>): React.JSX.Element;
|
|
39
|
-
|
|
40
|
-
declare function useDataTablePagination(): {
|
|
41
|
-
pageIndex: number;
|
|
42
|
-
pageSize: number;
|
|
43
|
-
pageCount: number;
|
|
44
|
-
canPreviousPage: boolean;
|
|
45
|
-
canNextPage: boolean;
|
|
46
|
-
goToPage: (value: number) => void;
|
|
47
|
-
previousPage: () => void;
|
|
48
|
-
nextPage: () => void;
|
|
49
|
-
firstPage: () => void;
|
|
50
|
-
lastPage: () => void;
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
declare function useDataTableRows<TData>(): {
|
|
54
|
-
data: TData[];
|
|
55
|
-
rows: TData[];
|
|
56
|
-
pageRows: TData[];
|
|
57
|
-
filteredRows: TData[];
|
|
58
|
-
totalRows: number;
|
|
59
|
-
isLoading: boolean;
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
declare function useDataTableSearch(): {
|
|
63
|
-
search: string;
|
|
64
|
-
setSearch: (value: string) => void;
|
|
65
|
-
clearSearch: () => void;
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
export { type DataTableColumn as D, useDataTablePagination as a, useDataTableRows as b, useDataTableSearch as c, type DataTableColumnDef as d, DataTableRoot as e, type DataTableRootProps as f, useDataTable as u };
|