react-kd-grid 1.0.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.md +270 -0
- package/dist/CustomGrid.d.ts +3 -0
- package/dist/components/ColumnFilterSelector.d.ts +18 -0
- package/dist/components/CustomSelect.d.ts +14 -0
- package/dist/components/FooterAggregate.d.ts +16 -0
- package/dist/components/GridHeader.d.ts +33 -0
- package/dist/components/GridRows.d.ts +49 -0
- package/dist/components/GroupBar.d.ts +12 -0
- package/dist/components/GroupHeader.d.ts +29 -0
- package/dist/components/NoDataMessage.d.ts +7 -0
- package/dist/components/PaginationControls.d.ts +15 -0
- package/dist/components/Popover.d.ts +17 -0
- package/dist/components/RowContextMenu.d.ts +22 -0
- package/dist/components/SearchToolbar.d.ts +79 -0
- package/dist/components/filters/BooleanFilter.d.ts +7 -0
- package/dist/components/filters/DateFilter.d.ts +9 -0
- package/dist/components/filters/FilterContent.d.ts +9 -0
- package/dist/components/filters/FilterPopup.d.ts +2 -0
- package/dist/components/filters/MultiselectFilter.d.ts +10 -0
- package/dist/components/filters/NumberFilter.d.ts +9 -0
- package/dist/components/filters/TextFilter.d.ts +8 -0
- package/dist/components/filters/index.d.ts +6 -0
- package/dist/components/ui/DatePicker.d.ts +10 -0
- package/dist/constants.d.ts +1 -0
- package/dist/hooks/useAdvancedFiltering.d.ts +16 -0
- package/dist/hooks/useDataWorker.d.ts +10 -0
- package/dist/hooks/useExport.d.ts +15 -0
- package/dist/hooks/useFilteringAndSorting.d.ts +16 -0
- package/dist/hooks/useGrouping.d.ts +28 -0
- package/dist/hooks/usePagination.d.ts +28 -0
- package/dist/hooks/useSelection.d.ts +13 -0
- package/dist/hooks/useVirtualization.d.ts +17 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.esm.js +10776 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +10776 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +421 -0
- package/dist/utils/highlightText.d.ts +15 -0
- package/dist/workers/dataWorker.d.ts +16 -0
- package/package.json +90 -0
package/README.md
ADDED
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
# React KD Grid
|
|
2
|
+
|
|
3
|
+
A feature-rich, performant React data grid component with virtualization, grouping, filtering, sorting, and export capabilities.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Virtualization**: Efficiently render large datasets with both vertical and horizontal virtualization
|
|
8
|
+
- **Grouping**: Multi-level grouping with expandable/collapsible groups
|
|
9
|
+
- **Filtering**: Global and column-specific filtering with multiple filter types
|
|
10
|
+
- **Sorting**: Multi-column sorting with customizable sort functions
|
|
11
|
+
- **Pagination**: Client and server-side pagination support
|
|
12
|
+
- **Export**: Export data to CSV, JSON, and Excel formats
|
|
13
|
+
- **Selection**: Row and cell selection with keyboard navigation
|
|
14
|
+
- **Responsive**: Flexible column sizing with flex support
|
|
15
|
+
- **Accessibility**: Full keyboard navigation and screen reader support
|
|
16
|
+
- **TypeScript**: Built with TypeScript for excellent type safety
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install react-kd-grid
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Basic Usage
|
|
25
|
+
|
|
26
|
+
```tsx
|
|
27
|
+
import React from 'react';
|
|
28
|
+
import { CustomDataGrid } from 'react-kd-grid';
|
|
29
|
+
|
|
30
|
+
const columns = [
|
|
31
|
+
{ key: 'id', header: 'ID', width: 80 },
|
|
32
|
+
{ key: 'name', header: 'Name', width: 200, sortable: true },
|
|
33
|
+
{ key: 'email', header: 'Email', width: 300, sortable: true },
|
|
34
|
+
{ key: 'department', header: 'Department', width: 150, sortable: true },
|
|
35
|
+
{ key: 'salary', header: 'Salary', width: 120, sortable: true, aggregate: 'avg' }
|
|
36
|
+
];
|
|
37
|
+
|
|
38
|
+
const data = [
|
|
39
|
+
{ id: 1, name: 'John Doe', email: 'john@example.com', department: 'Engineering', salary: 75000 },
|
|
40
|
+
{ id: 2, name: 'Jane Smith', email: 'jane@example.com', department: 'Marketing', salary: 65000 },
|
|
41
|
+
// ... more data
|
|
42
|
+
];
|
|
43
|
+
|
|
44
|
+
function App() {
|
|
45
|
+
return (
|
|
46
|
+
<div style={{ height: 600 }}>
|
|
47
|
+
<CustomDataGrid
|
|
48
|
+
data={data}
|
|
49
|
+
columns={columns}
|
|
50
|
+
getRowId={(row) => row.id}
|
|
51
|
+
height={600}
|
|
52
|
+
filterable={true}
|
|
53
|
+
sortable={true}
|
|
54
|
+
groupable={true}
|
|
55
|
+
virtualized={true}
|
|
56
|
+
pagination={{
|
|
57
|
+
enabled: true,
|
|
58
|
+
mode: 'client',
|
|
59
|
+
pageSize: 20
|
|
60
|
+
}}
|
|
61
|
+
/>
|
|
62
|
+
</div>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Advanced Features
|
|
68
|
+
|
|
69
|
+
### Column Configuration
|
|
70
|
+
|
|
71
|
+
```tsx
|
|
72
|
+
const columns = [
|
|
73
|
+
{
|
|
74
|
+
key: 'status',
|
|
75
|
+
header: 'Status',
|
|
76
|
+
width: 120,
|
|
77
|
+
filterable: {
|
|
78
|
+
type: 'multiselect',
|
|
79
|
+
options: [
|
|
80
|
+
{ label: 'Active', value: 'active' },
|
|
81
|
+
{ label: 'Inactive', value: 'inactive' },
|
|
82
|
+
{ label: 'Pending', value: 'pending' }
|
|
83
|
+
]
|
|
84
|
+
},
|
|
85
|
+
formatter: (value) => value.toUpperCase(),
|
|
86
|
+
aggregate: 'count'
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
key: 'createdAt',
|
|
90
|
+
header: 'Created',
|
|
91
|
+
width: 150,
|
|
92
|
+
filterable: {
|
|
93
|
+
type: 'date',
|
|
94
|
+
placeholder: 'Filter by date...'
|
|
95
|
+
},
|
|
96
|
+
formatter: (value) => new Date(value).toLocaleDateString()
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
key: 'actions',
|
|
100
|
+
header: 'Actions',
|
|
101
|
+
width: 100,
|
|
102
|
+
cellRenderer: (value, row) => (
|
|
103
|
+
<button onClick={() => handleEdit(row)}>Edit</button>
|
|
104
|
+
)
|
|
105
|
+
}
|
|
106
|
+
];
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Server-Side Operations
|
|
110
|
+
|
|
111
|
+
```tsx
|
|
112
|
+
function ServerGrid() {
|
|
113
|
+
const [data, setData] = useState([]);
|
|
114
|
+
const [loading, setLoading] = useState(false);
|
|
115
|
+
const [pagination, setPagination] = useState({
|
|
116
|
+
page: 1,
|
|
117
|
+
pageSize: 20,
|
|
118
|
+
total: 0
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
const handleServerPagination = async (page: number, pageSize: number) => {
|
|
122
|
+
setLoading(true);
|
|
123
|
+
const result = await fetchServerData(page, pageSize);
|
|
124
|
+
setData(result.data);
|
|
125
|
+
setPagination(prev => ({ ...prev, page, pageSize, total: result.total }));
|
|
126
|
+
setLoading(false);
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
const handleServerFilter = async (filters: any) => {
|
|
130
|
+
setLoading(true);
|
|
131
|
+
const result = await fetchFilteredData(filters);
|
|
132
|
+
setData(result.data);
|
|
133
|
+
setLoading(false);
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
return (
|
|
137
|
+
<CustomDataGrid
|
|
138
|
+
data={data}
|
|
139
|
+
columns={columns}
|
|
140
|
+
pagination={{
|
|
141
|
+
enabled: true,
|
|
142
|
+
mode: 'server',
|
|
143
|
+
pageSize: pagination.pageSize,
|
|
144
|
+
serverConfig: {
|
|
145
|
+
onPageChange: handleServerPagination,
|
|
146
|
+
loading: loading,
|
|
147
|
+
totalRows: pagination.total
|
|
148
|
+
}
|
|
149
|
+
}}
|
|
150
|
+
onFilterChange={handleServerFilter}
|
|
151
|
+
isLoading={loading}
|
|
152
|
+
/>
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Custom Styling
|
|
158
|
+
|
|
159
|
+
```tsx
|
|
160
|
+
const customRowStyle = (row) => ({
|
|
161
|
+
backgroundColor: row.status === 'active' ? '#f0fff4' : '#fff5f5'
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
const customCellStyle = (value, row) => ({
|
|
165
|
+
color: row.priority === 'high' ? '#dc2626' : '#1f2937'
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
<CustomDataGrid
|
|
169
|
+
// ... other props
|
|
170
|
+
rowStyle={customRowStyle}
|
|
171
|
+
columns={columns.map(col => ({
|
|
172
|
+
...col,
|
|
173
|
+
cellStyle: customCellStyle
|
|
174
|
+
}))}
|
|
175
|
+
/>
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### Event Handling
|
|
179
|
+
|
|
180
|
+
```tsx
|
|
181
|
+
const handleRowClick = (row, event) => {
|
|
182
|
+
console.log('Row clicked:', row);
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
const handleCellClick = ({ row, column, value, event }) => {
|
|
186
|
+
console.log('Cell clicked:', { row, column, value });
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
const handleSelectionChange = (selectedRows) => {
|
|
190
|
+
console.log('Selected rows:', Array.from(selectedRows));
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
const handleSort = (columnKey, direction) => {
|
|
194
|
+
console.log('Sort changed:', { columnKey, direction });
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
<CustomDataGrid
|
|
198
|
+
// ... other props
|
|
199
|
+
onRowClick={handleRowClick}
|
|
200
|
+
onCellClick={handleCellClick}
|
|
201
|
+
onSelectedRowsChange={handleSelectionChange}
|
|
202
|
+
onSort={handleSort}
|
|
203
|
+
selectable={true}
|
|
204
|
+
/>
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## API Reference
|
|
208
|
+
|
|
209
|
+
### CustomDataGrid Props
|
|
210
|
+
|
|
211
|
+
| Prop | Type | Default | Description |
|
|
212
|
+
|------|------|---------|-------------|
|
|
213
|
+
| `data` | `GridRow[]` | Required | Array of data rows to display |
|
|
214
|
+
| `columns` | `GridColumn[]` | Required | Array of column definitions |
|
|
215
|
+
| `getRowId` | `(row: GridRow) => string \| number` | Optional | Function to extract unique ID from row |
|
|
216
|
+
| `height` | `number` | 400 | Grid height in pixels |
|
|
217
|
+
| `density` | `'sm' \| 'md' \| 'lg'` | `'md'` | Row density (affects row height) |
|
|
218
|
+
| `selectable` | `boolean` | `false` | Enable row selection |
|
|
219
|
+
| `filterable` | `boolean` | `true` | Enable filtering |
|
|
220
|
+
| `sortable` | `boolean` | `true` | Enable sorting |
|
|
221
|
+
| `groupable` | `boolean` | `false` | Enable grouping |
|
|
222
|
+
| `virtualized` | `boolean` | `true` | Enable virtualization |
|
|
223
|
+
| `pagination` | `PaginationConfig` | `{ enabled: false }` | Pagination configuration |
|
|
224
|
+
| `isLoading` | `boolean` | `false` | Show loading state |
|
|
225
|
+
| `onRowSelect` | `(row: GridRow) => void` | Optional | Row selection callback |
|
|
226
|
+
| `onSelectedRowsChange` | `(selectedRows: Set<string \| number>) => void` | Optional | Selection change callback |
|
|
227
|
+
| `onFilterChange` | `(filters: FilterChangePayload) => void` | Optional | Filter change callback |
|
|
228
|
+
| `onSort` | `(columnKey: string, direction: 'asc' \| 'desc') => void` | Optional | Sort change callback |
|
|
229
|
+
|
|
230
|
+
### Column Definition
|
|
231
|
+
|
|
232
|
+
| Property | Type | Default | Description |
|
|
233
|
+
|----------|------|---------|-------------|
|
|
234
|
+
| `key` | `string` | Required | Unique column identifier |
|
|
235
|
+
| `header` | `string` | Required | Column header text |
|
|
236
|
+
| `width` | `number` | 100 | Column width in pixels |
|
|
237
|
+
| `flex` | `boolean \| number` | `false` | Flexible column sizing |
|
|
238
|
+
| `sortable` | `boolean` | `true` | Enable column sorting |
|
|
239
|
+
| `filterable` | `boolean \| ColumnFilter` | `false` | Enable column filtering |
|
|
240
|
+
| `formatter` | `(value: any) => string` | Optional | Custom value formatter |
|
|
241
|
+
| `cellRenderer` | `(value: any, row: GridRow) => ReactNode` | Optional | Custom cell renderer |
|
|
242
|
+
| `aggregate` | `'sum' \| 'avg' \| 'min' \| 'max' \| function` | Optional | Group aggregate function |
|
|
243
|
+
| `footer_aggregate` | `'count' \| 'sum' \| 'avg' \| 'min' \| 'max' \| function` | Optional | Footer aggregate function |
|
|
244
|
+
|
|
245
|
+
## Performance Tips
|
|
246
|
+
|
|
247
|
+
1. **Enable Virtualization**: For datasets with > 1000 rows, always enable virtualization
|
|
248
|
+
2. **Use Server-Side Operations**: For very large datasets, use server-side pagination and filtering
|
|
249
|
+
3. **Optimize Renderers**: Avoid creating new objects/functions in cell renderers
|
|
250
|
+
4. **Limit Column Count**: Horizontal virtualization kicks in at 50+ columns
|
|
251
|
+
5. **Use Memoization**: Memoize expensive calculations in formatters and renderers
|
|
252
|
+
|
|
253
|
+
## Browser Support
|
|
254
|
+
|
|
255
|
+
- Chrome 80+
|
|
256
|
+
- Firefox 75+
|
|
257
|
+
- Safari 13+
|
|
258
|
+
- Edge 80+
|
|
259
|
+
|
|
260
|
+
## License
|
|
261
|
+
|
|
262
|
+
MIT License - see LICENSE file for details.
|
|
263
|
+
|
|
264
|
+
## Contributing
|
|
265
|
+
|
|
266
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
267
|
+
|
|
268
|
+
## Support
|
|
269
|
+
|
|
270
|
+
If you encounter any issues or have questions, please [open an issue](https://github.com/yourusername/react-kd-grid/issues) on GitHub.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
interface ColumnFilterSelectorProps {
|
|
2
|
+
columns: Array<{
|
|
3
|
+
key: string;
|
|
4
|
+
header: string;
|
|
5
|
+
filterable?: {
|
|
6
|
+
type?: string;
|
|
7
|
+
options?: Array<{
|
|
8
|
+
label: string;
|
|
9
|
+
value: string | number;
|
|
10
|
+
}>;
|
|
11
|
+
placeholder?: string;
|
|
12
|
+
};
|
|
13
|
+
}>;
|
|
14
|
+
columnFilters: Record<string, any>;
|
|
15
|
+
onColumnFilter?: (columnKey: string, filter: any) => void;
|
|
16
|
+
}
|
|
17
|
+
export declare const ColumnFilterSelector: ({ columns, columnFilters, onColumnFilter, }: ColumnFilterSelectorProps) => import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
interface Option {
|
|
2
|
+
label: string;
|
|
3
|
+
value: string;
|
|
4
|
+
}
|
|
5
|
+
interface CustomSelectProps {
|
|
6
|
+
options: Option[];
|
|
7
|
+
value?: string;
|
|
8
|
+
placeholder?: string;
|
|
9
|
+
onChange: (value: string) => void;
|
|
10
|
+
searchable?: boolean;
|
|
11
|
+
className?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare const CustomSelect: ({ options, value, placeholder, onChange, searchable, className, }: CustomSelectProps) => import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { GridColumn, GridRow } from "../types";
|
|
3
|
+
interface FooterAggregateProps {
|
|
4
|
+
columns: (GridColumn & {
|
|
5
|
+
width: number;
|
|
6
|
+
})[];
|
|
7
|
+
data: GridRow[];
|
|
8
|
+
selectable: boolean;
|
|
9
|
+
/** Resolved row height so footer matches density */
|
|
10
|
+
rowHeight: number;
|
|
11
|
+
/** Pinned columns (same semantics as grid body) */
|
|
12
|
+
pinnedColumns?: Set<string>;
|
|
13
|
+
getRowId?: (row: GridRow) => string | number;
|
|
14
|
+
}
|
|
15
|
+
export declare const FooterAggregate: React.NamedExoticComponent<FooterAggregateProps>;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { GridColumn, SortConfig, ActiveFilters, ColumnFilterValue, GridRow } from "../types";
|
|
2
|
+
interface GridHeaderProps {
|
|
3
|
+
pinnedColumns: GridColumn[];
|
|
4
|
+
unpinnedColumns: GridColumn[];
|
|
5
|
+
hvPadLeft?: number;
|
|
6
|
+
hvPadRight?: number;
|
|
7
|
+
headerHeight: number;
|
|
8
|
+
sortConfig: SortConfig;
|
|
9
|
+
columnFilters: ActiveFilters;
|
|
10
|
+
selectable: boolean;
|
|
11
|
+
selectedRows: Set<string | number>;
|
|
12
|
+
totalRows: number;
|
|
13
|
+
data: GridRow[];
|
|
14
|
+
onSort: (key: string) => void;
|
|
15
|
+
onColumnFilter: (key: string, filter: ColumnFilterValue | null) => void;
|
|
16
|
+
onSelectAll: () => void;
|
|
17
|
+
onColumnResize?: (columnKey: string, width: number) => void;
|
|
18
|
+
pinnedKeySet?: Set<string>;
|
|
19
|
+
onColumnPin?: (columnKey: string, pinned: boolean) => void;
|
|
20
|
+
groupable?: boolean;
|
|
21
|
+
groupedByColumn?: string | null;
|
|
22
|
+
onGroupBy?: (columnKey: string | null) => void;
|
|
23
|
+
groupedByColumns?: string[];
|
|
24
|
+
onGroupToggle?: (columnKey: string, nextGrouped: boolean) => void;
|
|
25
|
+
onAutosizeColumn?: (columnKey: string) => void;
|
|
26
|
+
onAutosizeAllColumns?: () => void;
|
|
27
|
+
onResetColumns?: () => void;
|
|
28
|
+
columnOrder: string[];
|
|
29
|
+
onColumnOrderChange: (order: string[]) => void;
|
|
30
|
+
paginationMode?: "client" | "server" | null;
|
|
31
|
+
}
|
|
32
|
+
export declare const GridHeader: ({ pinnedColumns, unpinnedColumns, hvPadLeft, hvPadRight, headerHeight, sortConfig, columnFilters, selectable, selectedRows, totalRows, data, onSort, onColumnFilter, onSelectAll, onColumnResize, pinnedKeySet, onColumnPin, groupable, groupedByColumn, onGroupBy, groupedByColumns, onGroupToggle, onAutosizeColumn, onAutosizeAllColumns, onResetColumns, columnOrder, onColumnOrderChange, paginationMode, }: GridHeaderProps) => import("react/jsx-runtime").JSX.Element;
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { CSSProperties, MouseEvent } from "react";
|
|
2
|
+
import { GridRow, GridColumn, VirtualizedRange } from "../types";
|
|
3
|
+
interface GridRowsProps {
|
|
4
|
+
data: GridRow[];
|
|
5
|
+
columns: GridColumn[];
|
|
6
|
+
selectedRows: Set<string | number>;
|
|
7
|
+
virtualized: boolean;
|
|
8
|
+
virtualizedRange: VirtualizedRange;
|
|
9
|
+
rowHeight: number;
|
|
10
|
+
selectable: boolean;
|
|
11
|
+
isRowSelectable?: (row: GridRow) => boolean;
|
|
12
|
+
onRowSelect: (rowId: string | number, isSelected: boolean) => void;
|
|
13
|
+
pinnedColumns?: Set<string>;
|
|
14
|
+
hvPadLeft?: number;
|
|
15
|
+
hvPadRight?: number;
|
|
16
|
+
rowStyle?: (row: GridRow) => CSSProperties | undefined;
|
|
17
|
+
globalFilter?: string;
|
|
18
|
+
onContextMenu?: (row: GridRow, event: MouseEvent) => void;
|
|
19
|
+
onRowDoubleClick?: (row: GridRow, event: MouseEvent) => void;
|
|
20
|
+
onRowClick?: (row: GridRow, event: MouseEvent) => void;
|
|
21
|
+
onCellClick?: (args: {
|
|
22
|
+
row: GridRow;
|
|
23
|
+
column: GridColumn;
|
|
24
|
+
value: any;
|
|
25
|
+
event: MouseEvent;
|
|
26
|
+
}) => void;
|
|
27
|
+
isCellFocused?: (rowId: string | number, columnKey: string) => boolean;
|
|
28
|
+
isCellSelected?: (rowId: string | number, columnKey: string) => boolean;
|
|
29
|
+
onCellContextMenu?: (args: {
|
|
30
|
+
row: GridRow;
|
|
31
|
+
column: GridColumn;
|
|
32
|
+
value: any;
|
|
33
|
+
displayValue: string;
|
|
34
|
+
event: MouseEvent;
|
|
35
|
+
}) => void;
|
|
36
|
+
onCellMouseDown?: (args: {
|
|
37
|
+
row: GridRow;
|
|
38
|
+
column: GridColumn;
|
|
39
|
+
event: MouseEvent;
|
|
40
|
+
}) => void;
|
|
41
|
+
onCellMouseEnter?: (args: {
|
|
42
|
+
row: GridRow;
|
|
43
|
+
column: GridColumn;
|
|
44
|
+
event: MouseEvent;
|
|
45
|
+
}) => void;
|
|
46
|
+
getRowId?: (row: GridRow) => string | number;
|
|
47
|
+
}
|
|
48
|
+
export declare const GridRows: import("react").MemoExoticComponent<({ data, columns, selectedRows, virtualized, virtualizedRange, rowHeight, selectable, isRowSelectable, onRowSelect, pinnedColumns, hvPadLeft, hvPadRight, rowStyle, globalFilter, onContextMenu, onRowDoubleClick, onRowClick, onCellClick, isCellFocused, isCellSelected, onCellContextMenu, onCellMouseDown, onCellMouseEnter, getRowId, }: GridRowsProps) => import("react/jsx-runtime").JSX.Element>;
|
|
49
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { GridColumn } from "../types";
|
|
2
|
+
interface GroupBarProps {
|
|
3
|
+
columns: GridColumn[];
|
|
4
|
+
groupedKeys: string[];
|
|
5
|
+
onRemove: (columnKey: string) => void;
|
|
6
|
+
onReorder: (newOrder: string[]) => void;
|
|
7
|
+
onDropColumnKey: (columnKey: string) => void;
|
|
8
|
+
onToggleExpandAll?: () => void;
|
|
9
|
+
isAnyExpanded?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare const GroupBar: ({ columns, groupedKeys, onRemove, onReorder, onDropColumnKey, onToggleExpandAll, isAnyExpanded, }: GroupBarProps) => import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { GridRow, CustomDataGridProps } from "../types";
|
|
2
|
+
interface GroupHeaderProps {
|
|
3
|
+
row: GridRow & {
|
|
4
|
+
_isGroupHeader?: boolean;
|
|
5
|
+
_groupKey?: string;
|
|
6
|
+
_groupCount?: number;
|
|
7
|
+
};
|
|
8
|
+
isExpanded: boolean;
|
|
9
|
+
onToggle: (groupKey: string) => void;
|
|
10
|
+
viewportWidth: number;
|
|
11
|
+
selectable: boolean;
|
|
12
|
+
rowHeight?: number;
|
|
13
|
+
/**
|
|
14
|
+
* Optional function to map a column key to its display label (header).
|
|
15
|
+
* If not provided, the raw column key will be used as a fallback.
|
|
16
|
+
*/
|
|
17
|
+
getHeaderLabel?: (columnKey: string) => string;
|
|
18
|
+
/**
|
|
19
|
+
* Optional function to map a column key and raw group value to a display label.
|
|
20
|
+
* Useful to apply the column's formatter for group headers.
|
|
21
|
+
*/
|
|
22
|
+
getValueLabel?: (columnKey: string, rawValue: any) => string;
|
|
23
|
+
/**
|
|
24
|
+
* Optional custom renderer for actions on grouped rows.
|
|
25
|
+
*/
|
|
26
|
+
renderGroupActions?: CustomDataGridProps["renderGroupActions"];
|
|
27
|
+
}
|
|
28
|
+
export declare const GroupHeader: import("react").MemoExoticComponent<({ row, isExpanded, onToggle, viewportWidth, selectable, rowHeight, getHeaderLabel, getValueLabel, renderGroupActions, }: GroupHeaderProps) => import("react/jsx-runtime").JSX.Element>;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { PaginationConfig } from "../types";
|
|
2
|
+
interface PaginationControlsProps {
|
|
3
|
+
paginationConfig: PaginationConfig;
|
|
4
|
+
currentPage: number;
|
|
5
|
+
isServerLoading: boolean;
|
|
6
|
+
selectedRowsCount: number;
|
|
7
|
+
totalDataLength: number;
|
|
8
|
+
filteredDataLength?: number;
|
|
9
|
+
paginationMode?: "client" | "server";
|
|
10
|
+
onPageChange: (page: number, pageSize: number) => void;
|
|
11
|
+
onPageSizeChange: (pageSize: number) => void;
|
|
12
|
+
showNoDataMessage?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare const PaginationControls: ({ paginationConfig, currentPage, isServerLoading, selectedRowsCount, totalDataLength, filteredDataLength, paginationMode, onPageChange, onPageSizeChange, }: PaginationControlsProps) => import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { type Placement } from "@floating-ui/react";
|
|
3
|
+
interface PopoverProps {
|
|
4
|
+
open: boolean;
|
|
5
|
+
anchorEl: HTMLElement | null;
|
|
6
|
+
onClose: () => void;
|
|
7
|
+
placement?: Placement;
|
|
8
|
+
offset?: number;
|
|
9
|
+
sameWidth?: boolean;
|
|
10
|
+
maxHeight?: number | string;
|
|
11
|
+
zIndex?: number;
|
|
12
|
+
className?: string;
|
|
13
|
+
children: React.ReactNode;
|
|
14
|
+
shouldIgnoreClose?: (target: Node) => boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare const Popover: React.FC<PopoverProps>;
|
|
17
|
+
export default Popover;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import { GridRow } from "../types";
|
|
3
|
+
export interface ContextMenuItem {
|
|
4
|
+
id: string;
|
|
5
|
+
label: string;
|
|
6
|
+
icon?: ReactNode;
|
|
7
|
+
onClick: (row: GridRow) => void;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
separator?: boolean;
|
|
10
|
+
}
|
|
11
|
+
interface RowContextMenuProps {
|
|
12
|
+
row: GridRow;
|
|
13
|
+
position: {
|
|
14
|
+
x: number;
|
|
15
|
+
y: number;
|
|
16
|
+
};
|
|
17
|
+
isVisible: boolean;
|
|
18
|
+
onClose: () => void;
|
|
19
|
+
menuItems?: ContextMenuItem[];
|
|
20
|
+
}
|
|
21
|
+
export declare const RowContextMenu: ({ row, position, isVisible, onClose, menuItems, }: RowContextMenuProps) => import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { ReactNode, ChangeEvent } from "react";
|
|
2
|
+
import type { Density } from "../types";
|
|
3
|
+
export type ExportFormat = "csv" | "json" | "xlsx";
|
|
4
|
+
export type BulkAction = "delete" | "archive" | "copy" | "edit" | "export";
|
|
5
|
+
export interface BulkActionOption {
|
|
6
|
+
id: BulkAction;
|
|
7
|
+
label: string;
|
|
8
|
+
icon: ReactNode;
|
|
9
|
+
onClick: (selectedRows: Set<string | number>) => void;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
destructive?: boolean;
|
|
12
|
+
}
|
|
13
|
+
interface ColumnVisibility {
|
|
14
|
+
[columnKey: string]: boolean;
|
|
15
|
+
}
|
|
16
|
+
interface SavedFilter {
|
|
17
|
+
id: string;
|
|
18
|
+
name: string;
|
|
19
|
+
globalFilter: string;
|
|
20
|
+
columnFilters: Record<string, any>;
|
|
21
|
+
}
|
|
22
|
+
interface SearchToolbarProps {
|
|
23
|
+
globalFilter: string;
|
|
24
|
+
filteredDataLength: number;
|
|
25
|
+
totalDataLength: number;
|
|
26
|
+
paginationMode?: "client" | "server";
|
|
27
|
+
totalRows?: number;
|
|
28
|
+
selectedRowsCount?: number;
|
|
29
|
+
selectedRows?: Set<string | number>;
|
|
30
|
+
showExport?: boolean;
|
|
31
|
+
showRefresh?: boolean;
|
|
32
|
+
showColumnToggle?: boolean;
|
|
33
|
+
showBulkActions?: boolean;
|
|
34
|
+
showSavedFilters?: boolean;
|
|
35
|
+
columns?: Array<{
|
|
36
|
+
key: string;
|
|
37
|
+
header: string;
|
|
38
|
+
visible?: boolean;
|
|
39
|
+
filterOptions?: Array<{
|
|
40
|
+
label: string;
|
|
41
|
+
value: string | number;
|
|
42
|
+
}>;
|
|
43
|
+
filterType?: "text" | "select" | "multiselect";
|
|
44
|
+
filterable?: any;
|
|
45
|
+
}>;
|
|
46
|
+
columnVisibility?: ColumnVisibility;
|
|
47
|
+
columnFilters?: Record<string, any>;
|
|
48
|
+
savedFilters?: SavedFilter[];
|
|
49
|
+
bulkActions?: BulkActionOption[];
|
|
50
|
+
isLoading?: boolean;
|
|
51
|
+
exportOptions?: {
|
|
52
|
+
enabled: boolean;
|
|
53
|
+
formats?: ExportFormat[];
|
|
54
|
+
filename?: string;
|
|
55
|
+
onExport?: (format: ExportFormat, exportSelected: boolean) => void;
|
|
56
|
+
};
|
|
57
|
+
onGlobalFilterChange: (e: ChangeEvent<HTMLInputElement>) => void;
|
|
58
|
+
onClearFilters?: () => void;
|
|
59
|
+
onRefresh?: () => void;
|
|
60
|
+
onColumnVisibilityChange?: (columnKey: string, visible: boolean) => void;
|
|
61
|
+
onColumnFilter?: (columnKey: string, filter: any) => void;
|
|
62
|
+
onSaveFilter?: (filter: Omit<SavedFilter, "id">) => void;
|
|
63
|
+
onLoadFilter?: (filter: SavedFilter) => void;
|
|
64
|
+
onDeleteFilter?: (filterId: string) => void;
|
|
65
|
+
onRowSelect?: (selectedRows: number[]) => void;
|
|
66
|
+
onToggleFilters?: (show: boolean) => void;
|
|
67
|
+
onResetColumns?: () => void;
|
|
68
|
+
columnOrder?: string[];
|
|
69
|
+
onColumnOrderChange?: (order: string[]) => void;
|
|
70
|
+
pinnedColumns?: Set<string>;
|
|
71
|
+
onScrollToColumn?: (columnKey: string) => void;
|
|
72
|
+
density?: Density;
|
|
73
|
+
onDensityChange?: (density: Density) => void;
|
|
74
|
+
showDensityControl?: boolean;
|
|
75
|
+
customLeftContent?: ReactNode;
|
|
76
|
+
customRightContent?: ReactNode;
|
|
77
|
+
}
|
|
78
|
+
export declare const SearchToolbar: ({ globalFilter, filteredDataLength, selectedRowsCount, selectedRows, showExport, showColumnToggle, showBulkActions, columns, columnVisibility, columnFilters, bulkActions, exportOptions, onGlobalFilterChange, onClearFilters, onColumnVisibilityChange, onColumnFilter, onResetColumns, columnOrder, onColumnOrderChange, pinnedColumns, onScrollToColumn, density, onDensityChange, showDensityControl, customLeftContent, customRightContent, }: SearchToolbarProps) => import("react/jsx-runtime").JSX.Element;
|
|
79
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ColumnFilterValue } from "../../types";
|
|
2
|
+
interface BooleanFilterProps {
|
|
3
|
+
value: ColumnFilterValue | null;
|
|
4
|
+
onChange: (value: ColumnFilterValue | null) => void;
|
|
5
|
+
}
|
|
6
|
+
export declare const BooleanFilter: ({ value, onChange }: BooleanFilterProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ColumnFilterValue } from "../../types";
|
|
2
|
+
interface DateFilterProps {
|
|
3
|
+
value: ColumnFilterValue | null;
|
|
4
|
+
onChange: (value: ColumnFilterValue | null) => void;
|
|
5
|
+
min?: number;
|
|
6
|
+
max?: number;
|
|
7
|
+
}
|
|
8
|
+
export declare const DateFilter: ({ value, onChange, min, max }: DateFilterProps) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ColumnFilterValue, GridColumn, GridRow } from "../../types";
|
|
2
|
+
interface FilterContentProps {
|
|
3
|
+
column: GridColumn;
|
|
4
|
+
data: GridRow[];
|
|
5
|
+
value: ColumnFilterValue | null;
|
|
6
|
+
onChange: (val: ColumnFilterValue | null) => void;
|
|
7
|
+
}
|
|
8
|
+
export declare const FilterContent: ({ column, data, value, onChange }: FilterContentProps) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ColumnFilterValue, FilterOption, GridRow } from "../../types";
|
|
2
|
+
interface MultiselectFilterProps {
|
|
3
|
+
value: ColumnFilterValue | null;
|
|
4
|
+
onChange: (value: ColumnFilterValue | null) => void;
|
|
5
|
+
options?: FilterOption[];
|
|
6
|
+
data: GridRow[];
|
|
7
|
+
columnKey: string;
|
|
8
|
+
}
|
|
9
|
+
export declare const MultiselectFilter: ({ value, onChange, options, data, columnKey, }: MultiselectFilterProps) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ColumnFilterValue } from "../../types";
|
|
2
|
+
interface NumberFilterProps {
|
|
3
|
+
value: ColumnFilterValue | null;
|
|
4
|
+
onChange: (value: ColumnFilterValue | null) => void;
|
|
5
|
+
min?: number;
|
|
6
|
+
max?: number;
|
|
7
|
+
}
|
|
8
|
+
export declare const NumberFilter: ({ value, onChange, min, max, }: NumberFilterProps) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ColumnFilterValue } from "../../types";
|
|
2
|
+
interface TextFilterProps {
|
|
3
|
+
value: ColumnFilterValue | null;
|
|
4
|
+
onChange: (value: ColumnFilterValue | null) => void;
|
|
5
|
+
placeholder?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const TextFilter: ({ value, onChange, placeholder, }: TextFilterProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { TextFilter } from './TextFilter';
|
|
2
|
+
export { NumberFilter } from './NumberFilter';
|
|
3
|
+
export { DateFilter } from './DateFilter';
|
|
4
|
+
export { MultiselectFilter } from './MultiselectFilter';
|
|
5
|
+
export { BooleanFilter } from './BooleanFilter';
|
|
6
|
+
export { FilterPopup } from './FilterPopup';
|