@opencorestack/opengridx 0.1.5 → 0.1.7

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.
Files changed (130) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/README.md +9 -0
  3. package/dist/index.d.ts +6 -0
  4. package/dist/opengridx.css +1 -1
  5. package/dist/opengridx.es.js +319 -319
  6. package/dist/opengridx.es.js.map +1 -1
  7. package/dist/opengridx.umd.js +7 -7
  8. package/dist/opengridx.umd.js.map +1 -1
  9. package/docs/API_REFERENCE.md +177 -0
  10. package/docs/README.md +60 -0
  11. package/docs/components/cell.md +44 -0
  12. package/docs/components/column-group-header.md +57 -0
  13. package/docs/components/column-resize.md +63 -0
  14. package/docs/components/column-visibility.md +61 -0
  15. package/docs/components/datagrid.md +70 -0
  16. package/docs/components/filter-panel.md +26 -0
  17. package/docs/components/header.md +39 -0
  18. package/docs/components/pagination.md +34 -0
  19. package/docs/components/row.md +31 -0
  20. package/docs/components/toolbar.md +40 -0
  21. package/docs/components/tooltip.md +68 -0
  22. package/docs/customization/slots-api.md +227 -0
  23. package/docs/customization/theming.md +293 -0
  24. package/docs/features/aggregation-pivot.md +79 -0
  25. package/docs/features/cell-spanning.md +520 -0
  26. package/docs/features/clipboard.md +76 -0
  27. package/docs/features/custom-pagination.md +143 -0
  28. package/docs/features/data-source.md +72 -0
  29. package/docs/features/editing-reordering.md +99 -0
  30. package/docs/features/export-guide.md +434 -0
  31. package/docs/features/filtering.md +83 -0
  32. package/docs/features/infinite-scroll.md +87 -0
  33. package/docs/features/list-view.md +65 -0
  34. package/docs/features/loading-states.md +68 -0
  35. package/docs/features/master-detail.md +46 -0
  36. package/docs/features/pinning.md +67 -0
  37. package/docs/features/selection.md +70 -0
  38. package/docs/features/sorting-pagination.md +66 -0
  39. package/docs/features/state-persistence.md +67 -0
  40. package/docs/features/tree-data-grouping.md +67 -0
  41. package/docs/features/virtualization.md +188 -0
  42. package/docs/roadmap.md +71 -0
  43. package/lib/components/Cell/Cell.css +119 -0
  44. package/lib/components/Cell/Cell.tsx +264 -0
  45. package/lib/components/Cell/GridEditInputCell.css +62 -0
  46. package/lib/components/Cell/GridEditInputCell.tsx +152 -0
  47. package/lib/components/ColumnGroupHeader/ColumnGroupHeader.css +67 -0
  48. package/lib/components/ColumnGroupHeader/ColumnGroupHeader.tsx +220 -0
  49. package/lib/components/ColumnResizeHandle/ColumnResizeHandle.css +31 -0
  50. package/lib/components/ColumnResizeHandle/ColumnResizeHandle.tsx +85 -0
  51. package/lib/components/ColumnVisibilityPanel/ColumnVisibilityPanel.css +137 -0
  52. package/lib/components/ColumnVisibilityPanel/ColumnVisibilityPanel.tsx +190 -0
  53. package/lib/components/DataGrid/DataGrid.css +224 -0
  54. package/lib/components/DataGrid/DataGrid.tsx +2253 -0
  55. package/lib/components/DetailPanel/DetailPanel.css +36 -0
  56. package/lib/components/DetailPanel/DetailPanel.tsx +34 -0
  57. package/lib/components/FilterPanel/FilterPanel.css +196 -0
  58. package/lib/components/FilterPanel/FilterPanel.tsx +183 -0
  59. package/lib/components/FilterPanel/index.ts +1 -0
  60. package/lib/components/Header/ColumnMenu.css +68 -0
  61. package/lib/components/Header/ColumnMenu.tsx +249 -0
  62. package/lib/components/Header/Header.css +224 -0
  63. package/lib/components/Header/Header.tsx +516 -0
  64. package/lib/components/ListView/ListView.css +112 -0
  65. package/lib/components/ListView/ListViewRow.tsx +63 -0
  66. package/lib/components/Pagination/Pagination.css +91 -0
  67. package/lib/components/Pagination/Pagination.tsx +151 -0
  68. package/lib/components/QuickFilter/QuickFilter.css +23 -0
  69. package/lib/components/QuickFilter/QuickFilter.tsx +79 -0
  70. package/lib/components/Row/Row.css +126 -0
  71. package/lib/components/Row/Row.tsx +377 -0
  72. package/lib/components/Skeleton/Skeleton.css +55 -0
  73. package/lib/components/Skeleton/Skeleton.tsx +22 -0
  74. package/lib/components/SkeletonRow/SkeletonRow.css +32 -0
  75. package/lib/components/SkeletonRow/SkeletonRow.tsx +89 -0
  76. package/lib/components/SkeletonRow/index.ts +1 -0
  77. package/lib/components/Toolbar/GlobalSearch.css +113 -0
  78. package/lib/components/Toolbar/GlobalSearch.tsx +120 -0
  79. package/lib/components/Toolbar/GridToolbar.css +204 -0
  80. package/lib/components/Toolbar/GridToolbar.tsx +647 -0
  81. package/lib/components/Toolbar/PivotPanel.css +212 -0
  82. package/lib/components/Toolbar/PivotPanel.tsx +239 -0
  83. package/lib/components/Tooltip/Tooltip.css +59 -0
  84. package/lib/components/Tooltip/Tooltip.tsx +106 -0
  85. package/lib/components/ui/Button.css +89 -0
  86. package/lib/components/ui/Button.tsx +39 -0
  87. package/lib/components/ui/Checkbox.css +71 -0
  88. package/lib/components/ui/Checkbox.tsx +66 -0
  89. package/lib/components/ui/DragHandleIcon.css +19 -0
  90. package/lib/components/ui/DragHandleIcon.tsx +18 -0
  91. package/lib/components/ui/ExpandIcon.css +38 -0
  92. package/lib/components/ui/ExpandIcon.tsx +75 -0
  93. package/lib/components/ui/Input.css +59 -0
  94. package/lib/components/ui/Input.tsx +45 -0
  95. package/lib/components/ui/index.ts +15 -0
  96. package/lib/hooks/core/useDataGrid.ts +392 -0
  97. package/lib/hooks/core/useGridApiRef.ts +10 -0
  98. package/lib/hooks/features/useAggregation.ts +143 -0
  99. package/lib/hooks/features/useGridClipboard.ts +133 -0
  100. package/lib/hooks/features/useGridDataSource.ts +190 -0
  101. package/lib/hooks/features/useGridEditing.ts +100 -0
  102. package/lib/hooks/features/useGridSpanning.ts +349 -0
  103. package/lib/hooks/features/usePivot.ts +149 -0
  104. package/lib/hooks/useColumnReorder.ts +114 -0
  105. package/lib/hooks/useRowGrouping.ts +302 -0
  106. package/lib/hooks/useRowReorder.ts +83 -0
  107. package/lib/hooks/useTreeData.ts +323 -0
  108. package/lib/index.ts +106 -0
  109. package/lib/state/index.ts +17 -0
  110. package/lib/state/types.ts +48 -0
  111. package/lib/state/useGridStateStorage.ts +113 -0
  112. package/lib/styles/base/reset.css +21 -0
  113. package/lib/styles/base/variables.css +161 -0
  114. package/lib/styles/opengridx.css +27 -0
  115. package/lib/styles/opengridx.css.d.ts +4 -0
  116. package/lib/theme/DataGridThemeProvider.tsx +276 -0
  117. package/lib/theme/defaultStyles.ts +0 -0
  118. package/lib/theme/index.ts +21 -0
  119. package/lib/theme/presets.ts +148 -0
  120. package/lib/theme/types.ts +155 -0
  121. package/lib/types/index.ts +764 -0
  122. package/lib/utils/export/exportToExcelAdvanced.ts +516 -0
  123. package/lib/utils/export/index.ts +550 -0
  124. package/lib/utils/filtering/index.ts +240 -0
  125. package/lib/utils/pinning/index.ts +282 -0
  126. package/lib/utils/sorting/index.ts +55 -0
  127. package/lib/utils/virtualization/index.ts +106 -0
  128. package/lib/vite-env.d.ts +1 -0
  129. package/llms.txt +12 -2
  130. package/package.json +13 -4
@@ -0,0 +1,143 @@
1
+ # Custom Pagination with Ant Design
2
+
3
+ This guide shows how to use Ant Design (or any other UI library) components with the DataGrid.
4
+
5
+ ## Using Ant Design Select for Page Size
6
+
7
+ ```tsx
8
+ import { Select } from 'antd';
9
+ import { DataGrid } from '@opencorestack/opengridx';
10
+
11
+ function AntdPaginationComponent(props) {
12
+ const {
13
+ page,
14
+ pageSize,
15
+ rowCount,
16
+ pageSizeOptions,
17
+ onPageChange,
18
+ onPageSizeChange
19
+ } = props;
20
+
21
+ const pageCount = Math.max(1, Math.ceil(rowCount / pageSize));
22
+ const currentPage = Math.min(page, pageCount - 1);
23
+ const firstRowIndex = currentPage * pageSize;
24
+ const lastRowIndex = Math.min(firstRowIndex + pageSize, rowCount);
25
+
26
+ return (
27
+ <div style={{
28
+ display: 'flex',
29
+ alignItems: 'center',
30
+ justifyContent: 'flex-end',
31
+ gap: '16px',
32
+ padding: '12px 16px',
33
+ borderTop: '1px solid #f0f0f0'
34
+ }}>
35
+ {/* Ant Design Select for page size */}
36
+ <div style={{ display: 'flex', alignItems: 'center', gap: '8px' }}>
37
+ <span>Rows per page:</span>
38
+ <Select
39
+ value={pageSize}
40
+ onChange={onPageSizeChange}
41
+ options={pageSizeOptions.map(size => ({
42
+ value: size,
43
+ label: size
44
+ }))}
45
+ style={{ width: 80 }}
46
+ />
47
+ </div>
48
+
49
+ {/* Row count */}
50
+ <span>{firstRowIndex + 1}–{lastRowIndex} of {rowCount}</span>
51
+
52
+ {/* Ant Design Pagination */}
53
+ <Pagination
54
+ current={currentPage + 1}
55
+ total={rowCount}
56
+ pageSize={pageSize}
57
+ onChange={(page) => onPageChange(page - 1)}
58
+ showSizeChanger={false}
59
+ simple
60
+ />
61
+ </div>
62
+ );
63
+ }
64
+
65
+ // Usage in your app
66
+ function MyApp() {
67
+ return (
68
+ <DataGrid
69
+ rows={rows}
70
+ columns={columns}
71
+ pagination
72
+ slots={{
73
+ pagination: AntdPaginationComponent
74
+ }}
75
+ slotProps={{
76
+ pagination: {
77
+ // Any custom props for your component
78
+ }
79
+ }}
80
+ />
81
+ );
82
+ }
83
+ ```
84
+
85
+ ## Using MUI Select
86
+
87
+ ```tsx
88
+ import { Select, MenuItem } from '@mui/material';
89
+
90
+ function MuiPaginationComponent(props) {
91
+ const { pageSize, pageSizeOptions, onPageSizeChange } = props;
92
+
93
+ return (
94
+ <div>
95
+ <Select
96
+ value={pageSize}
97
+ onChange={(e) => onPageSizeChange(e.target.value)}
98
+ >
99
+ {pageSizeOptions.map(size => (
100
+ <MenuItem key={size} value={size}>
101
+ {size}
102
+ </MenuItem>
103
+ ))}
104
+ </Select>
105
+ </div>
106
+ );
107
+ }
108
+ ```
109
+
110
+ ## Available Props
111
+
112
+ Your custom pagination component will receive these props:
113
+
114
+ - `page`: Current page index (0-based)
115
+ - `pageSize`: Current page size
116
+ - `rowCount`: Total number of rows
117
+ - `pageSizeOptions`: Array of available page sizes
118
+ - `onPageChange(newPage: number)`: Callback to change page
119
+ - `onPageSizeChange(newPageSize: number)`: Callback to change page size
120
+ - Any additional props from `slotProps.pagination`
121
+
122
+ ## Other Customizable Slots
123
+
124
+ ```tsx
125
+ <DataGrid
126
+ slots={{
127
+ pagination: CustomPaginationComponent,
128
+ noRowsOverlay: CustomNoRowsComponent,
129
+ loadingOverlay: CustomLoadingComponent,
130
+ footer: CustomFooterComponent
131
+ }}
132
+ slotProps={{
133
+ pagination: { /* custom props */ },
134
+ noRowsOverlay: { /* custom props */ },
135
+ loadingOverlay: { /* custom props */ },
136
+ footer: { /* custom props */ }
137
+ }}
138
+ />
139
+ ```
140
+
141
+ ## Complete Example
142
+
143
+ See `demo/examples/CustomPagination.tsx` for a complete working example.
@@ -0,0 +1,72 @@
1
+ # 🌐 Server-Side Data Source
2
+
3
+ Handle millions of rows by connecting OpenGridX directly to your backend API.
4
+
5
+ ---
6
+
7
+ ## 📑 The `GridDataSource` Interface
8
+
9
+ The `dataSource` prop is the gateway to server-side operations. When provided, the grid becomes a "thin client" that requests only the data it needs to render the current viewport.
10
+
11
+ ### Implementation
12
+ ```tsx
13
+ const myDataSource: GridDataSource = {
14
+ getRows: async (params) => {
15
+ const { startRow, endRow, sortModel, filterModel } = params;
16
+
17
+ const response = await fetch('/api/data', {
18
+ method: 'POST',
19
+ body: JSON.stringify({ startRow, endRow, sortModel, filterModel })
20
+ });
21
+
22
+ const data = await response.json();
23
+
24
+ return {
25
+ rows: data.items,
26
+ rowCount: data.totalCount // Required for stable pagination
27
+ };
28
+ }
29
+ };
30
+
31
+ <DataGrid dataSource={myDataSource} />
32
+ ```
33
+
34
+ ---
35
+
36
+ ## ⚙️ Request Parameters (`GridGetRowsParams`)
37
+
38
+ | Parameter | Type | Description |
39
+ | :--- | :--- | :--- |
40
+ | `startRow` | `number` | The starting index of the requested range. |
41
+ | `endRow` | `number` | The ending index (exclusive). |
42
+ | `sortModel` | `GridSortItem[]` | Current sorting configuration. |
43
+ | `filterModel` | `GridFilterModel` | Current filtering configuration. |
44
+ | `groupKeys` | `string[]` | Active expansion path (used for server-side tree data). |
45
+
46
+ ---
47
+
48
+ ## 🔄 Modes of Operation
49
+
50
+ ### 1. Server-Side Pagination
51
+ Set `paginationMode="server"`. The grid will request fresh data every time the page changes.
52
+
53
+ ### 2. Infinite Loading
54
+ Set `paginationMode="infinite"`. The grid will request the next "chunk" of data as the user scrolls near the bottom of the list.
55
+
56
+ ### 3. Server-Side Tree Data
57
+ When `treeData` is enabled with a `dataSource`, OpenGridX will call `getRows` with `groupKeys`. You should return the children for that specific parent path.
58
+
59
+ ---
60
+
61
+ ## 🛠️ Error Handling
62
+ If your API call fails, you should throw an error or return a rejected promise. OpenGridX will automatically display the **Error Overlay** with a "Retry" button.
63
+
64
+ ```typescript
65
+ getRows: async () => {
66
+ try {
67
+ return await apiCall();
68
+ } catch (err) {
69
+ throw new Error("Failed to connect to database");
70
+ }
71
+ }
72
+ ```
@@ -0,0 +1,99 @@
1
+ # ✏️ Editing & ↕️ Reordering
2
+
3
+ Capture user input directly in the grid and rearrange data with intuitive drag-and-drop interactions.
4
+
5
+ ---
6
+
7
+ ## 🏗️ Cell Editing
8
+
9
+ OpenGridX supports inline cell editing. For a column to be editable, you must set `editable: true` in its definition.
10
+
11
+ ### Basic Setup
12
+ ```tsx
13
+ const columns = [
14
+ { field: 'name', editable: true },
15
+ { field: 'role', editable: true, type: 'singleSelect', valueOptions: ['Admin', 'Editor'] }
16
+ ];
17
+ ```
18
+
19
+ ### Persistence
20
+ When a cell edit is committed, the `processRowUpdate` callback is triggered.
21
+
22
+ ```tsx
23
+ <DataGrid
24
+ processRowUpdate={(newRow, oldRow) => {
25
+ // Save to your database/state here
26
+ const updatedRows = rows.map(r => r.id === newRow.id ? newRow : r);
27
+ setRows(updatedRows);
28
+ return newRow; // Return the new row to confirm saving
29
+ }}
30
+ onProcessRowUpdateError={(error) => {
31
+ console.error('Update failed:', error);
32
+ }}
33
+ />
34
+ ```
35
+
36
+ ---
37
+
38
+ ## ↕️ Row Reordering
39
+
40
+ Allows users to rearrange rows by dragging a handle.
41
+
42
+ ### Enable
43
+ 1. Set `rowReordering={true}` on the grid.
44
+ 2. Handle the `onRowOrderChange` callback.
45
+
46
+ ```tsx
47
+ <DataGrid
48
+ rowReordering={true}
49
+ onRowOrderChange={(params) => {
50
+ const { oldIndex, targetIndex } = params;
51
+ // Move logic
52
+ const newRows = [...rows];
53
+ const [moved] = newRows.splice(oldIndex, 1);
54
+ newRows.splice(targetIndex, 0, moved);
55
+ setRows(newRows);
56
+ }}
57
+ />
58
+ ```
59
+
60
+ > [!IMPORTANT]
61
+ > Row reordering is usually disabled when sorting or filtering is active to prevent index confusion.
62
+
63
+ ---
64
+
65
+ ## ↔️ Column Reordering
66
+
67
+ Users can drag column headers to change their horizontal order. This is enabled by default.
68
+
69
+ ### Enable / Disable
70
+ Use the `disableColumnReorder` prop to control this feature globally.
71
+
72
+ ```tsx
73
+ <DataGrid disableColumnReorder={true} />
74
+ ```
75
+
76
+ ### Controlled Column Order
77
+ You can manage the column order state explicitly using `columnOrder` and `onColumnOrderChange`.
78
+
79
+ ```tsx
80
+ const [colOrder, setColOrder] = useState(['id', 'name', 'status']);
81
+
82
+ <DataGrid
83
+ columnOrder={colOrder}
84
+ onColumnOrderChange={(params) => {
85
+ // params.newOrder is the updated array of field strings
86
+ setColOrder(params.newOrder);
87
+ }}
88
+ />
89
+ ```
90
+
91
+ ### Non-Reorderable Columns
92
+ To prevent a specific column from being moved, set `reorderable: false` in its definition.
93
+
94
+ ```tsx
95
+ const columns = [
96
+ { field: 'id', reorderable: false }, // Stay pinned at start
97
+ { field: 'name' }
98
+ ];
99
+ ```