rockin 0.0.17 → 0.0.19
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-J2SGPPFU.js +1016 -0
- package/dist/data-grid-CUn4qqSF.d.ts +127 -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 +907 -1372
- 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,127 @@
|
|
|
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 GridComboboxOption = {
|
|
42
|
+
label: string;
|
|
43
|
+
value: string;
|
|
44
|
+
};
|
|
45
|
+
type GridAsyncComboboxCellProps = {
|
|
46
|
+
value?: string;
|
|
47
|
+
onChange?: (value: string, option?: GridComboboxOption) => void;
|
|
48
|
+
loadOptions: (query: string) => Promise<GridComboboxOption[]>;
|
|
49
|
+
placeholder?: string;
|
|
50
|
+
minQueryLength?: number;
|
|
51
|
+
debounceMs?: number;
|
|
52
|
+
};
|
|
53
|
+
type DataGridValue = string | number | boolean | null | undefined;
|
|
54
|
+
type DataGridApi<TData extends Record<string, unknown>> = {
|
|
55
|
+
rows: TData[];
|
|
56
|
+
columns: DataGridColumn<TData>[];
|
|
57
|
+
getRowId: (row: TData, index: number) => string;
|
|
58
|
+
getRow: (rowId: string) => TData | undefined;
|
|
59
|
+
getCellValue: (rowId: string, columnId: string) => DataGridValue;
|
|
60
|
+
updateCell: (rowId: string, columnId: string, value: DataGridValue) => void;
|
|
61
|
+
updateRows: (updater: (rows: TData[]) => TData[]) => void;
|
|
62
|
+
};
|
|
63
|
+
type UseDataGridOptions<TData extends Record<string, unknown>> = {
|
|
64
|
+
columnIds?: string[];
|
|
65
|
+
columns?: DataGridColumn<TData>[];
|
|
66
|
+
initialRows?: TData[];
|
|
67
|
+
createEmptyRow?: () => TData;
|
|
68
|
+
getRowId?: (row: TData, index: number) => string;
|
|
69
|
+
};
|
|
70
|
+
declare function useDataGrid<TData extends Record<string, unknown>>({ columnIds, columns, initialRows, getRowId, }?: UseDataGridOptions<TData>): DataGridApi<TData>;
|
|
71
|
+
declare function DataGrid<TData extends Record<string, unknown>>({ grid, children, className, }: {
|
|
72
|
+
grid: DataGridApi<TData>;
|
|
73
|
+
children?: React.ReactNode;
|
|
74
|
+
className?: string;
|
|
75
|
+
}): React.JSX.Element;
|
|
76
|
+
declare function DataGridRow({ row, rowId, children, className, }: {
|
|
77
|
+
row?: Record<string, unknown>;
|
|
78
|
+
rowId?: string;
|
|
79
|
+
children?: React.ReactNode;
|
|
80
|
+
className?: string;
|
|
81
|
+
}): React.JSX.Element;
|
|
82
|
+
type DataGridColumn<TData = Record<string, unknown>> = {
|
|
83
|
+
id: string;
|
|
84
|
+
header?: React.ReactNode;
|
|
85
|
+
accessorKey?: keyof TData & string;
|
|
86
|
+
width?: number;
|
|
87
|
+
};
|
|
88
|
+
declare function DataGridColumn({ column, children, className, }: {
|
|
89
|
+
column: DataGridColumn;
|
|
90
|
+
children?: React.ReactNode;
|
|
91
|
+
className?: string;
|
|
92
|
+
}): React.JSX.Element;
|
|
93
|
+
declare function DataGridCell({ row, rowId, columnId, children, state, className, }: {
|
|
94
|
+
row?: Record<string, unknown>;
|
|
95
|
+
rowId?: string;
|
|
96
|
+
columnId: string;
|
|
97
|
+
children?: React.ReactNode;
|
|
98
|
+
state?: CellState;
|
|
99
|
+
className?: string;
|
|
100
|
+
}): React.JSX.Element;
|
|
101
|
+
declare function GridTextCell({ value, onChange, placeholder, }: {
|
|
102
|
+
value?: string;
|
|
103
|
+
onChange?: (value: string) => void;
|
|
104
|
+
placeholder?: string;
|
|
105
|
+
}): React.JSX.Element;
|
|
106
|
+
declare function GridNumberCell({ value, onChange, }: {
|
|
107
|
+
value?: number;
|
|
108
|
+
onChange?: (value: number) => void;
|
|
109
|
+
}): React.JSX.Element;
|
|
110
|
+
declare function GridComboboxCell({ options, value, onChange, }: {
|
|
111
|
+
options: GridComboboxOption[];
|
|
112
|
+
value?: string;
|
|
113
|
+
onChange?: (value: string) => void;
|
|
114
|
+
}): React.JSX.Element;
|
|
115
|
+
declare function GridAsyncComboboxCell({ value, onChange, loadOptions, placeholder, minQueryLength, debounceMs, }: GridAsyncComboboxCellProps): React.JSX.Element;
|
|
116
|
+
declare function DataTableColumnResize(): React.JSX.Element;
|
|
117
|
+
declare function DataGridClipboard({ children, }: {
|
|
118
|
+
children?: React.ReactNode;
|
|
119
|
+
}): React.JSX.Element;
|
|
120
|
+
declare function DataGridFillHandle({ children, }: {
|
|
121
|
+
children?: React.ReactNode;
|
|
122
|
+
}): React.JSX.Element;
|
|
123
|
+
declare function DataGridMove({ children }: {
|
|
124
|
+
children?: React.ReactNode;
|
|
125
|
+
}): React.JSX.Element;
|
|
126
|
+
|
|
127
|
+
export { type CellState as C, type DataGridApi as D, GridAsyncComboboxCell 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, type GridAsyncComboboxCellProps as n, GridComboboxCell as o, type GridComboboxOption as p, GridNumberCell as q, GridTextCell as r, useDataGrid as u };
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { D as DataGridApi } from '../data-grid-CUn4qqSF.js';
|
|
2
|
+
export { u as useDataGrid, a as useDataTable } from '../data-grid-CUn4qqSF.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-J2SGPPFU.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 GridAsyncComboboxCell, n as GridAsyncComboboxCellProps, o as GridComboboxCell, p as GridComboboxOption, q as GridNumberCell, r as GridTextCell, U as UseDataGridOptions } from '../data-grid-CUn4qqSF.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';
|