@opencorestack/opengridx 3.5.1 → 3.7.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.
Files changed (114) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/README.md +2 -0
  3. package/dist/ai.cjs +4 -2
  4. package/dist/ai.cjs.map +1 -1
  5. package/dist/ai.d.ts +2 -2
  6. package/dist/ai.es.js +4 -2
  7. package/dist/ai.es.js.map +1 -1
  8. package/dist/index.d.ts +62 -0
  9. package/dist/opengridx.css +1 -1
  10. package/dist/opengridx.es.js +9643 -9024
  11. package/dist/opengridx.es.js.map +1 -1
  12. package/dist/opengridx.umd.js +16 -16
  13. package/dist/opengridx.umd.js.map +1 -1
  14. package/docs/API_REFERENCE.md +17 -3
  15. package/docs/README.md +2 -0
  16. package/docs/architecture/datagrid-orchestration.md +46 -29
  17. package/docs/architecture/grid-row-meta.md +1 -1
  18. package/docs/customization/slots-api.md +1 -1
  19. package/docs/customization/theming.md +43 -0
  20. package/docs/features/ai-toolkit.md +2 -2
  21. package/docs/features/export-guide.md +2 -0
  22. package/docs/features/header-filters.md +34 -0
  23. package/docs/features/keyboard-navigation.md +2 -0
  24. package/docs/features/nextjs.md +241 -0
  25. package/docs/features/pdf-export.md +2 -0
  26. package/docs/features/pinning.md +2 -0
  27. package/docs/features/rtl.md +58 -0
  28. package/docs/features/virtualization.md +16 -2
  29. package/docs/performance.md +89 -119
  30. package/docs/roadmap.md +4 -2
  31. package/lib/ai/promptHandler.ts +12 -8
  32. package/lib/ai/validate.ts +5 -2
  33. package/lib/components/AiAssistant/GridAiAssistantPanel.css +4 -2
  34. package/lib/components/Cell/Cell.css +31 -9
  35. package/lib/components/Cell/Cell.tsx +2 -2
  36. package/lib/components/ColumnGroupHeader/ColumnGroupHeader.css +4 -4
  37. package/lib/components/ColumnResizeHandle/ColumnResizeHandle.css +3 -3
  38. package/lib/components/ColumnResizeHandle/ColumnResizeHandle.tsx +18 -2
  39. package/lib/components/ColumnVisibilityPanel/ColumnVisibilityPanel.css +3 -1
  40. package/lib/components/DataGrid/DataGrid.css +19 -13
  41. package/lib/components/DataGrid/DataGrid.tsx +163 -670
  42. package/lib/components/DataGrid/GridAggregationFooter.tsx +3 -3
  43. package/lib/components/DataGrid/GridListView.tsx +3 -1
  44. package/lib/components/DataGrid/GridRoot.tsx +239 -0
  45. package/lib/components/DataGrid/GridViewport.tsx +314 -0
  46. package/lib/components/FilterPanel/FilterPanel.css +9 -8
  47. package/lib/components/Header/ColumnMenu.css +5 -4
  48. package/lib/components/Header/ColumnMenu.tsx +14 -6
  49. package/lib/components/Header/Header.css +23 -14
  50. package/lib/components/Header/Header.tsx +16 -9
  51. package/lib/components/Header/headerColumnStyle.ts +3 -2
  52. package/lib/components/HeaderFilter/HeaderFilter.css +9 -3
  53. package/lib/components/HeaderFilter/HeaderFilterCell.tsx +21 -18
  54. package/lib/components/HeaderFilter/HeaderFilterOperatorMenu.tsx +5 -4
  55. package/lib/components/HeaderFilter/HeaderFilterRow.tsx +9 -3
  56. package/lib/components/ListView/ListViewRow.tsx +1 -1
  57. package/lib/components/Pagination/Pagination.css +5 -1
  58. package/lib/components/Pagination/Pagination.tsx +4 -4
  59. package/lib/components/Row/Row.css +2 -2
  60. package/lib/components/Row/Row.tsx +3 -3
  61. package/lib/components/SkeletonRow/SkeletonRow.tsx +2 -2
  62. package/lib/components/Toolbar/GridToolbar.css +8 -7
  63. package/lib/components/Toolbar/GridToolbar.tsx +8 -28
  64. package/lib/components/Toolbar/PivotPanel.css +3 -3
  65. package/lib/components/Toolbar/PivotPanel.tsx +4 -7
  66. package/lib/components/ui/ExpandIcon.css +13 -0
  67. package/lib/components/ui/ExpandIcon.tsx +2 -4
  68. package/lib/hooks/core/useGridCellSelection.ts +20 -5
  69. package/lib/hooks/core/useGridColumns.tsx +2 -2
  70. package/lib/hooks/core/useGridDevWarnings.ts +3 -1
  71. package/lib/hooks/core/useGridEditPipeline.ts +55 -0
  72. package/lib/hooks/core/useGridKeyboardNavigation.ts +7 -4
  73. package/lib/hooks/core/useGridRangeEditing.ts +129 -0
  74. package/lib/hooks/core/useGridRenderWindow.ts +66 -0
  75. package/lib/hooks/core/useGridScrollSync.ts +28 -5
  76. package/lib/hooks/core/useGridScrollViewport.ts +42 -0
  77. package/lib/hooks/core/useGridSelectionAndStateApi.ts +61 -0
  78. package/lib/hooks/core/useGridToolbarStack.ts +49 -0
  79. package/lib/hooks/core/useGridViewApis.ts +46 -0
  80. package/lib/hooks/core/useLayout.ts +13 -6
  81. package/lib/hooks/useRowGrouping.ts +9 -9
  82. package/lib/styles/base/variables.css +12 -0
  83. package/lib/theme/DataGridThemeProvider.tsx +15 -0
  84. package/lib/theme/__baseline__/default-theme.darwin.chromium.json +1503 -0
  85. package/lib/theme/__baseline__/default-theme.darwin.firefox.json +1503 -0
  86. package/lib/theme/__baseline__/default-theme.darwin.webkit.json +1503 -0
  87. package/lib/theme/types.ts +31 -0
  88. package/lib/types/ai.ts +109 -0
  89. package/lib/types/api.ts +169 -0
  90. package/lib/types/columns.ts +341 -0
  91. package/lib/types/dataSource.ts +40 -0
  92. package/lib/types/editing.ts +77 -0
  93. package/lib/types/export.ts +164 -0
  94. package/lib/types/filtering.ts +52 -0
  95. package/lib/types/grouping.ts +27 -0
  96. package/lib/types/index.ts +18 -1672
  97. package/lib/types/locale.ts +51 -0
  98. package/lib/types/props.ts +405 -0
  99. package/lib/types/rows.ts +132 -0
  100. package/lib/types/selection.ts +66 -0
  101. package/lib/types/slots.ts +56 -0
  102. package/lib/types/sorting.ts +25 -0
  103. package/lib/types/state.ts +35 -0
  104. package/lib/utils/aggregation/index.ts +56 -1
  105. package/lib/utils/direction.ts +52 -0
  106. package/lib/utils/export/exportToExcelAdvanced.ts +9 -2
  107. package/lib/utils/export/exportToPdf.ts +2 -1
  108. package/lib/utils/filtering/index.ts +58 -6
  109. package/lib/utils/headerFilterLocale.ts +37 -0
  110. package/lib/utils/scroll/index.ts +5 -3
  111. package/lib/utils/sorting/index.ts +141 -26
  112. package/lib/utils/values.ts +10 -6
  113. package/llms.txt +4 -2
  114. package/package.json +4 -2
@@ -0,0 +1,40 @@
1
+ import type { GridRowModel, GridValidRowModel } from './rows';
2
+ import type { GridSortItem } from './sorting';
3
+ import type { GridFilterModel } from './filtering';
4
+ import type { GridAggregationModel } from './grouping';
5
+
6
+ export interface GridGetRowsParams {
7
+ startRow: number;
8
+ endRow: number;
9
+ sortModel: GridSortItem[];
10
+ filterModel: GridFilterModel;
11
+ groupKeys: string[];
12
+ aggregationModel?: GridAggregationModel;
13
+ }
14
+
15
+ export interface GridGetRowsResponse<R extends GridValidRowModel = GridRowModel> {
16
+ rows: R[];
17
+ rowCount?: number;
18
+ aggregationResults?: Record<string, unknown>;
19
+ }
20
+
21
+ /**
22
+ * Interface for providing data to the grid from a remote source.
23
+ * Enables server-side sorting, filtering, and pagination.
24
+ */
25
+ export interface GridDataSource<R extends GridValidRowModel = GridRowModel> {
26
+ /**
27
+ * Fetches a chunk of rows based on current grid state.
28
+ * @param params Sorting, filtering, and range parameters.
29
+ */
30
+ getRows: (params: GridGetRowsParams) => Promise<GridGetRowsResponse<R>>;
31
+ /**
32
+ * Optional: Fetches aggregation results for the entire dataset.
33
+ */
34
+ getAggregations?: (params: Omit<GridGetRowsParams, 'startRow' | 'endRow'>) => Promise<Record<string, unknown>>;
35
+ }
36
+
37
+ export interface GridPaginationModel {
38
+ page: number;
39
+ pageSize: number;
40
+ }
@@ -0,0 +1,77 @@
1
+ import type { GridRowId, GridRowModel, GridValidRowModel } from './rows';
2
+ import type { GridColDef } from './columns';
3
+ import type { GridCellCoordinates } from './selection';
4
+
5
+ /** The way a fill extends the cell range. @since v3.5 */
6
+ export type GridFillDirection = 'down' | 'up' | 'right' | 'left';
7
+
8
+ /** Parameters passed to `GridColDef.fillValue`. @since v3.5 */
9
+ export interface GridFillValueParams<R extends GridValidRowModel = GridRowModel> {
10
+ /** The row of the cell being filled, as stored now. */
11
+ row: R;
12
+ id: GridRowId;
13
+ field: string;
14
+ colDef: GridColDef<R>;
15
+ direction: GridFillDirection;
16
+ /** The source cells' values in fill order: the value next to the first filled cell is last. */
17
+ sourceValues: unknown[];
18
+ /** Position of this cell among the filled cells of its line, from 0 (next to the source). */
19
+ index: number;
20
+ /** What the grid would write: the continued series, the repeated pattern or a copy. */
21
+ value: unknown;
22
+ /** Whether a copy was asked for (Alt held at release, or the keyboard shortcuts), so no series. */
23
+ copy: boolean;
24
+ }
25
+
26
+ /** `onFill` details: the batch edit result plus the direction of the fill. @since v3.5 */
27
+ export interface GridFillResult extends GridBatchEditResult {
28
+ direction: GridFillDirection;
29
+ }
30
+
31
+ /**
32
+ * Why a cell of a batch edit (paste, range clear, undo, redo) was not written:
33
+ * - `'notEditable'`: the column is not `editable`, `isCellEditable` returned false, or the row is a
34
+ * synthetic row (group header, subtotal, tree auto-parent, pivot Grand Total);
35
+ * - `'invalidValue'`: the pasted text does not parse for the column type (or `valueParser` rejected it);
36
+ * - `'changed'`: undo/redo only, the cell no longer holds the value the history recorded;
37
+ * - `'missing'`: undo/redo only, the row is gone.
38
+ * @since v3.4
39
+ */
40
+ export type GridEditSkipReason = 'notEditable' | 'invalidValue' | 'changed' | 'missing';
41
+
42
+ /** What a batch edit (paste, range clear, undo, redo) did. @since v3.4 */
43
+ export interface GridBatchEditResult {
44
+ /** Rows whose `processRowUpdate` succeeded and that were stored, in the order they were first touched. */
45
+ updated: GridRowId[];
46
+ /** Rows whose `valueSetter` or `processRowUpdate` threw or rejected (also reported to `onProcessRowUpdateError`). */
47
+ failed: { id: GridRowId; error: unknown }[];
48
+ /** Cells that were not written, with the reason. */
49
+ skipped: { id: GridRowId; field: string; reason: GridEditSkipReason }[];
50
+ }
51
+
52
+ /** `onClipboardPaste` details: the batch edit result plus the text that was pasted. @since v3.4 */
53
+ export interface GridClipboardPasteResult extends GridBatchEditResult {
54
+ text: string;
55
+ }
56
+
57
+ /** `onBeforeClipboardPaste` params. @since v3.4 */
58
+ export interface GridBeforeClipboardPasteParams {
59
+ /** The clipboard text (`text/plain`). */
60
+ text: string;
61
+ /** The cell the paste starts from (the range's top-left cell, or the focused cell). */
62
+ anchor: GridCellCoordinates | null;
63
+ }
64
+
65
+ /** `onHistoryChange` params. @since v3.4 */
66
+ export interface GridHistoryChangeParams {
67
+ canUndo: boolean;
68
+ canRedo: boolean;
69
+ /** Number of actions that can be undone. */
70
+ size: number;
71
+ }
72
+
73
+ /** `undoRedo` options. @since v3.4 */
74
+ export interface GridUndoRedoOptions {
75
+ /** How many actions are kept; the oldest is dropped beyond it. Default: 100. */
76
+ limit?: number;
77
+ }
@@ -0,0 +1,164 @@
1
+ import type { GridRowId, GridRowModel, GridValidRowModel } from './rows';
2
+ import type { GridFilterModel } from './filtering';
3
+ import type { GridAggregationModel } from './grouping';
4
+
5
+ /**
6
+ * Configuration options for exporting the DataGrid to PDF format.
7
+ * Requires jspdf and jspdf-autotable peer dependencies.
8
+ */
9
+ export interface PdfExportOptions<R extends GridValidRowModel = GridRowModel> {
10
+ /**
11
+ * Output filename without extension. Default: 'export'
12
+ */
13
+ fileName?: string;
14
+
15
+ /**
16
+ * Title text displayed in the document header.
17
+ * When omitted, no header block is rendered.
18
+ */
19
+ title?: string;
20
+
21
+ /**
22
+ * URL or data URI of a logo image rendered left of the title.
23
+ * Only used when `title` is also set. Default: none
24
+ */
25
+ logoUrl?: string;
26
+
27
+ /**
28
+ * Page orientation. Default: 'landscape'
29
+ */
30
+ orientation?: 'portrait' | 'landscape';
31
+
32
+ /**
33
+ * If provided, only rows whose id is in this array are exported. A non-empty selection takes
34
+ * precedence over `groupedRows` (the selected rows are exported flat), and the footer totals
35
+ * are recomputed over the selected rows.
36
+ */
37
+ selectedRows?: (string | number)[];
38
+
39
+ /**
40
+ * The grid's `getRowId`, when it has one: `selectedRows` holds those ids, and the grid does not
41
+ * copy them onto `row.id` (v3.0+). Defaults to `row.id`.
42
+ */
43
+ getRowId?: (row: R) => GridRowId;
44
+
45
+ /**
46
+ * Aggregation result from apiRef.current.getAggregationResult().
47
+ * When provided alongside aggregationModel, appends a footer row.
48
+ */
49
+ aggregationResult?: Record<string, unknown> | null;
50
+
51
+ /**
52
+ * Aggregation model from apiRef.current.getAggregationModel().
53
+ */
54
+ aggregationModel?: GridAggregationModel | null;
55
+
56
+ /**
57
+ * Active filter model. When provided, a filter summary is shown in the header.
58
+ */
59
+ filterModel?: GridFilterModel | null;
60
+
61
+ /**
62
+ * Whether to apply alternating row shading. Default: true
63
+ */
64
+ alternateRowColor?: boolean;
65
+
66
+ /**
67
+ * Column header background color (hex). Default: '#4f46e5'
68
+ */
69
+ headerBackgroundColor?: string;
70
+
71
+ /**
72
+ * Column header text color (hex). Default: '#ffffff'
73
+ */
74
+ headerTextColor?: string;
75
+
76
+ /**
77
+ * Base font size in points for table body. Default: 9
78
+ */
79
+ fontSize?: number;
80
+
81
+ /**
82
+ * A TrueType font for the whole document. The built-in Helvetica font only covers Latin-1 and
83
+ * WinAnsi punctuation (é, ü, €, “ ”, •). Without this option other characters (₹, Greek,
84
+ * Cyrillic, CJK, Devanagari, U+202F used by some locales as a thousands separator) are
85
+ * replaced with `?` (spaces and minus signs with their ASCII forms) and a warning is logged.
86
+ * `data` is the `.ttf` file as a base64 string; `boldData` is an optional bold face for the
87
+ * title, header and totals (the regular face is used when omitted). jsPDF does not shape
88
+ * complex scripts, so Devanagari or Arabic ligatures may not join.
89
+ * @since v3.0
90
+ */
91
+ font?: {
92
+ /** Font family name, e.g. 'NotoSans'. */
93
+ name: string;
94
+ /** Base64-encoded .ttf file. */
95
+ data: string;
96
+ /** Base64-encoded bold .ttf file. Default: `data`. */
97
+ boldData?: string;
98
+ };
99
+
100
+ /**
101
+ * Pre-built grouped export rows from `apiRef.current.getGroupedExportRows()`.
102
+ * When provided, the PDF table reflects the grouping structure (group headers,
103
+ * leaf rows, per-group subtotals, grand total) instead of a flat row list.
104
+ * Has no effect when the grid has no active `rowGroupingModel`, or when `selectedRows` is non-empty.
105
+ */
106
+ groupedRows?: GridGroupedExportRow[];
107
+
108
+ /**
109
+ * Called as the export advances: `prepare` (formatting rows; `total` = source rows or grouped
110
+ * entries), `render` (drawing table rows; `total` = table body rows) and `save` (`0/1` before the
111
+ * file is written, `1/1` after). `done` never decreases within a phase and ends at `total`.
112
+ * @since v3.2
113
+ */
114
+ onProgress?: (progress: PdfExportProgress) => void;
115
+
116
+ /**
117
+ * Cancels the export. When aborted, the returned promise rejects with a `DOMException` named
118
+ * `'AbortError'` and no file is saved. Checked between slices of work, so cancellation takes
119
+ * effect within one slice; the final save step cannot be interrupted once started.
120
+ * @since v3.2
121
+ */
122
+ signal?: AbortSignal;
123
+
124
+ /**
125
+ * Table-row count above which a development-mode warning recommends `exportToCsv` or
126
+ * `exportToExcelAdvanced`. The export still runs (nothing is thrown). Pass `Infinity` to silence it.
127
+ * Default: 20000
128
+ * @since v3.2
129
+ */
130
+ maxRows?: number;
131
+ }
132
+
133
+ /** Progress reported by `PdfExportOptions.onProgress`. @since v3.2 */
134
+ export interface PdfExportProgress {
135
+ phase: 'prepare' | 'render' | 'save';
136
+ done: number;
137
+ total: number;
138
+ }
139
+
140
+ /**
141
+ * A single entry in the ordered list returned by `GridApi.getGroupedExportRows()`.
142
+ * Traverse in array order to reproduce the on-screen grouping structure.
143
+ */
144
+ export interface GridGroupedExportRow {
145
+ /** Discriminator: the kind of row this entry represents. */
146
+ type: 'group-header' | 'leaf' | 'group-subtotal' | 'grand-total';
147
+ /** Nesting depth (0 = top-level group, 1 = nested group, etc.). */
148
+ depth: number;
149
+ /** The grouping field for this level (absent on 'leaf' and 'grand-total'). */
150
+ groupField?: string;
151
+ /** The raw grouping value for this level (absent on 'leaf' and 'grand-total'). */
152
+ groupValue?: unknown;
153
+ /**
154
+ * The group label exactly as the grid shows it (from `groupingValueFormatter`, else `"field: value"`),
155
+ * on 'group-header' and 'group-subtotal' entries from `getGroupedExportRows()`. Exporters use it for
156
+ * group-header rows; when absent they apply the column's `groupingValueFormatter` themselves.
157
+ * @since v3.0
158
+ */
159
+ groupLabel?: string;
160
+ /** Per-group aggregation results (present on 'group-subtotal' and 'grand-total'). */
161
+ aggregatedValues?: Record<string, unknown>;
162
+ /** The original data row (only present when `type === 'leaf'`). */
163
+ row?: GridRowModel;
164
+ }
@@ -0,0 +1,52 @@
1
+ export type GridFilterOperator =
2
+ | 'contains'
3
+ | 'equals'
4
+ | 'startsWith'
5
+ | 'endsWith'
6
+ | 'isEmpty'
7
+ | 'isNotEmpty'
8
+ | 'isAnyOf'
9
+ | '='
10
+ | '>'
11
+ | '>='
12
+ | '<'
13
+ | '<='
14
+ | '!='
15
+ | 'is'
16
+ | 'not'
17
+ | 'after'
18
+ | 'onOrAfter'
19
+ | 'before'
20
+ | 'onOrBefore';
21
+
22
+ /** Describes a filter condition for a specific column. */
23
+ export interface GridFilterItem {
24
+ /** Optional ID for the filter item. */
25
+ id?: string | number;
26
+ /** The field name to filter. */
27
+ field: string;
28
+ /** The comparison operator. */
29
+ operator: GridFilterOperator;
30
+ /** The value to compare against. */
31
+ value?: unknown;
32
+ }
33
+
34
+ /** Describes a group of filters combined with a logical operator. */
35
+ export interface GridFilterGroup {
36
+ /** Optional ID for the group. */
37
+ id?: string | number;
38
+ /** Logical operator to join child items ('and' | 'or'). */
39
+ logicOperator: 'and' | 'or';
40
+ /** Array of child filter items or groups. */
41
+ items: (GridFilterItem | GridFilterGroup)[];
42
+ }
43
+
44
+ /** The overall state of grid filtering. */
45
+ export interface GridFilterModel {
46
+ /** Root-level filter items or groups. */
47
+ items?: (GridFilterItem | GridFilterGroup)[];
48
+ /** Global logical operator (defaults to 'and'). */
49
+ logicOperator?: 'and' | 'or';
50
+ /** Array of strings used for the quick search feature across all columns. */
51
+ quickFilterValues?: string[];
52
+ }
@@ -0,0 +1,27 @@
1
+ export type GridRowGroupingModel = string[];
2
+
3
+ export interface GridAggregationModel {
4
+ [field: string]: string;
5
+ }
6
+
7
+ export type GridAggregationResult = Record<string, unknown>;
8
+
9
+ /**
10
+ * Where a group's aggregates are shown, as returned by `getAggregationPosition`: `'inline'` on the group row,
11
+ * `'footer'` on a subtotal row after the group's children, `null` hidden.
12
+ */
13
+ export type GridAggregationPosition = 'inline' | 'footer' | null;
14
+
15
+ export type GridPivotAggFn = 'sum' | 'avg' | 'count' | 'min' | 'max';
16
+
17
+ export interface GridPivotValueField {
18
+ field: string;
19
+ aggFn: GridPivotAggFn;
20
+ headerName?: string;
21
+ }
22
+
23
+ export interface GridPivotModel {
24
+ rowFields: string[];
25
+ columnFields: string[];
26
+ valueFields: GridPivotValueField[];
27
+ }