@quickbuilder.io/data-grid 0.0.0-stage → 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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Quick Builder contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,309 @@
1
- # Temporary Holding Version
1
+ # @quickbuilder.io/data-grid
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Quick Builder Advanced Components data grid package.
4
+
5
+ Import framework-neutral package metadata and capabilities from `@quickbuilder.io/data-grid`. Import `DataGrid`, its React hooks, and React-owned types from `@quickbuilder.io/data-grid/react`.
6
+
7
+ `DataGrid` is a separate advanced component because it owns product-level data behavior: typed rows, stable row identity, sorting, row selection, keyboard navigation, and future server-data workflows.
8
+
9
+ It is not a replacement for the design-system `Table`. `Table` remains the primitive for table presentation. `DataGrid` follows the WAI-ARIA grid pattern and renders an interactive composite widget with `role="grid"`, `columnheader`, `row`, and `gridcell` semantics. Virtualization and keyboard navigation are core rendering concerns.
10
+
11
+ The package still depends on `@quickbuilder.io/design-system` for design tokens, CSS variables, theming conventions, Storybook standards, and builder metadata.
12
+
13
+ ## Enterprise customization
14
+
15
+ The grid exposes typed customization at the business-data boundaries instead of requiring DOM selectors or wrapper overrides:
16
+
17
+ ```tsx
18
+ <DataGrid
19
+ columns={[
20
+ {
21
+ field: 'account',
22
+ renderHeader: ({ column }) => <AccountHeader field={column.field} />,
23
+ headerClassName: 'account-header',
24
+ cellClassName: ({ row }) => row.risk === 'high' ? 'high-risk-cell' : '',
25
+ },
26
+ {
27
+ field: 'status',
28
+ disableColumnMenu: true,
29
+ filterable: false,
30
+ hideable: false,
31
+ },
32
+ ]}
33
+ getRowClassName={({ row }) => row.requiresReview ? 'requires-review' : ''}
34
+ getCellClassName={({ field }) => `field-${field}`}
35
+ onCellClick={({ id, field }) => auditCellAccess(id, field)}
36
+ rows={rows}
37
+ />
38
+ ```
39
+
40
+ `renderHeader`, row/cell/header class resolvers, and typed row/cell/header event callbacks receive stable row IDs, source row indexes, fields, values, and column definitions. `disableColumnMenu`, `filterable`, and `hideable` enforce feature permissions in the built-in UI. The community toolbar contains only implemented community workflows; advanced Pivot, Charts, AI, grouping, aggregation, and saved-view controls belong to their real Pro integrations.
41
+
42
+ Columns can set `cellPadding` and `headerPadding` independently using CSS padding
43
+ values. Use `0` for an edge-to-edge timeline, chart or other owned graphic. This
44
+ does not change row sizing, keyboard behavior or the density's editor padding;
45
+ inline form controls retain their normal usable area. `styleOverrides.pinnedColumnShadow`
46
+ controls the frozen-column shadow independently of its divider, and frozen body
47
+ cells respect `bodyCellBorderBottom`. Omitted values retain the
48
+ grid density and standard header spacing.
49
+
50
+ Row click and double-click callbacks activate ordinary row content. Selection
51
+ checkboxes, reorder/detail/action cells, embedded links and form controls, editable
52
+ hosts, and portal menu events do not activate the row. This lets a row open a
53
+ record without navigating away when a user selects it or opens its action menu.
54
+
55
+ ## Localization
56
+
57
+ Pass `localeText` to override any community-grid label without replacing the toolbar, panels, menu, overlays, header filters, or pagination footer:
58
+
59
+ ```tsx
60
+ <DataGrid
61
+ localeText={{
62
+ columnsLabel: 'Felder',
63
+ filtersLabel: 'Filter',
64
+ quickFilterLabel: 'Konten suchen',
65
+ quickFilterPlaceholder: 'Suchen…',
66
+ }}
67
+ columns={columns}
68
+ rows={rows}
69
+ showToolbar
70
+ />
71
+ ```
72
+
73
+ `defaultDataGridLocaleText` is exported for locale packs that need to extend the complete English contract.
74
+
75
+ ## State presets
76
+
77
+ `DataGrid` exposes storage-agnostic state presets through the controller API. Applications can persist the returned object in their own workspace, account, or local storage layer.
78
+
79
+ ```tsx
80
+ const apiRef = useDataGridApiRef<CustomerRow>();
81
+
82
+ const preset = apiRef.current?.exportPreset({
83
+ id: 'finance-review',
84
+ name: 'Finance review',
85
+ });
86
+
87
+ apiRef.current?.restorePreset(preset);
88
+ ```
89
+
90
+ Presets include cell selection, column order, pinned columns, column visibility, column widths, density, filters, pagination, row edit model, row selection, and sorting. `onPresetChange` emits the current preset whenever grid preset state changes.
91
+
92
+ ## Spreadsheet selection and clipboard
93
+
94
+ Enable `cellSelection` when a grid needs spreadsheet-style cell ranges. The model is controlled or uncontrolled through `cellSelectionModel`, `defaultCellSelectionModel`, and `onCellSelectionModelChange`.
95
+
96
+ ```tsx
97
+ const apiRef = useDataGridApiRef<CustomerRow>();
98
+
99
+ <DataGrid
100
+ apiRef={apiRef}
101
+ cellSelection
102
+ columns={editableColumns}
103
+ defaultCellSelectionModel={{
104
+ ranges: [{
105
+ start: { id: 'northwind', field: 'name' },
106
+ end: { id: 'contoso', field: 'revenue' },
107
+ }],
108
+ }}
109
+ rows={rows}
110
+ />
111
+
112
+ apiRef.current?.copySelectionToClipboard({ includeHeaders: true });
113
+ apiRef.current?.getSelectedCellMatrix();
114
+ apiRef.current?.setSelectedCellValues('Needs review');
115
+ apiRef.current?.pasteFromClipboard('Northwind Global\tActive\t22900');
116
+ apiRef.current?.undo();
117
+ ```
118
+
119
+ Cell ranges use stable row ids and column fields, so applications can persist or audit them without depending on rendered indexes. Users can create disjoint ranges with Ctrl/Cmd-click, extend the active range with Shift+Arrow, select the visible cell region with Ctrl/Cmd+A, and clear selected editable cells with Delete/Backspace. `copySelectionToClipboard()` prefers selected cell ranges, then selected rows, then the focused cell. `getSelectedCellMatrix()` returns a range-preserving matrix for charts, analysis panels, or future 3D data surfaces. Paste and `setSelectedCellValues()` start from the selection contract and still respect editable columns, `isCellEditable`, value parsers, validation, transactions, undo, and redo.
120
+
121
+ ## Server-side data
122
+
123
+ For application-owned cursor pagination, set `hideFooter` and render the continuation controls in the application. Server row counts, selection and export remain available; the built-in footer is hidden. `hideFooter` defaults to `false` and accepts only a boolean.
124
+
125
+ For simple server windows, pass `dataSourceMode="server"`, `rows`, and `rowCount`. The grid treats `rows` as the loaded page and emits filter, sort, and pagination changes for the host application to fetch.
126
+
127
+ For enterprise async loading, pass `dataSource`. The grid owns the request lifecycle, aborts superseded requests, ignores stale responses, and exposes loading/error state through both UI overlays and the public API.
128
+
129
+ ```tsx
130
+ const apiRef = useDataGridApiRef<CustomerRow>();
131
+
132
+ <DataGrid
133
+ apiRef={apiRef}
134
+ columns={columns}
135
+ dataSource={{
136
+ async getRows(request) {
137
+ const response = await fetch('/api/customers/search', {
138
+ method: 'POST',
139
+ body: JSON.stringify({
140
+ columns: request.visibleColumnFields,
141
+ filters: request.filterModel,
142
+ page: request.paginationModel.page,
143
+ pageSize: request.paginationModel.pageSize,
144
+ sort: request.sortModel,
145
+ }),
146
+ signal: request.signal,
147
+ });
148
+
149
+ return response.json();
150
+ },
151
+ }}
152
+ rows={[]}
153
+ showToolbar
154
+ />
155
+
156
+ apiRef.current?.reloadDataSource();
157
+ ```
158
+
159
+ `DataGridDataSourceRequest` includes pagination, filters, sort model, rendered column order, visible column fields, column visibility, an abort signal, and a monotonically increasing `requestId`. `DataGridDataSourceResponse` returns `rows` and `rowCount`. Use `onDataSourceRequest`, `onDataSourceResponse`, and `onDataSourceError` for audit logging, telemetry, or cache integration.
160
+
161
+ ## Virtualization
162
+
163
+ Use `virtualization` for large row sets and `columnVirtualization` with `horizontalScroll` for wide grids. Row virtualization keeps the full row state available through selectors and export APIs while rendering only the scroll window. Column virtualization keeps the full logical column model intact, preserves `aria-colindex`, keeps pinned columns mounted, and collapses offscreen columns into measured spacer tracks.
164
+
165
+ ```tsx
166
+ <DataGrid
167
+ columnVirtualization
168
+ columns={columns}
169
+ defaultPinnedColumns={{ left: ['account'], right: ['total'] }}
170
+ horizontalScroll
171
+ overscanColumnCount={2}
172
+ overscanRowCount={4}
173
+ rows={rows}
174
+ scrollViewportHeight={520}
175
+ virtualization
176
+ />
177
+ ```
178
+
179
+ `getVirtualizationState()` exposes both row and column windows for telemetry and integration tests. `scrollViewportWidth` is available when a host application needs deterministic server-rendered or test-rendered column windows before browser measurement is available.
180
+
181
+ ## Server-side export
182
+
183
+ For large datasets, pass `exportDataSource` instead of exporting the currently loaded rows in the browser. The grid owns export loading state, normalizes CSV or `Blob` results, and passes the same enterprise state envelope used by server-side data.
184
+
185
+ ```tsx
186
+ <DataGrid
187
+ columns={columns}
188
+ exportDataSource={{
189
+ async exportData(request) {
190
+ const response = await fetch('/api/customers/export', {
191
+ method: 'POST',
192
+ body: JSON.stringify({
193
+ columns: request.visibleColumnFields,
194
+ filters: request.filterModel,
195
+ selectedRowIds: request.selectedRowIds,
196
+ sort: request.sortModel,
197
+ scope: request.options.scope,
198
+ }),
199
+ signal: request.signal,
200
+ });
201
+
202
+ return {
203
+ data: await response.blob(),
204
+ fileName: 'customers.csv',
205
+ mimeType: 'text/csv;charset=utf-8',
206
+ };
207
+ },
208
+ }}
209
+ rows={[]}
210
+ showToolbar
211
+ />
212
+ ```
213
+
214
+ `DataGridExportRequest` includes selected row ids, row count, pagination, filters, sort model, rendered column order, visible column fields, column visibility, normalized export options, an abort signal, and a `requestId`. Use `onExportRequest`, `onExportSuccess`, and `onExportError` for audit logs, background-job telemetry, or download-service integration.
215
+
216
+ The full product capability plan is tracked in `docs/design-system/DATA_GRID_PRODUCT_CAPABILITY_PLAN.md` and exported from the package as `dataGridCapabilityFeatures`.
217
+
218
+ ## Standard application contract
219
+
220
+ Use `QuickBuilderDesignSystemProvider` or `ThemeProvider` around the grid, as with Button and Input. Grid surfaces, text, borders, selection, and focus consume the same semantic CSS variables. The grid requires modern browser APIs including `ResizeObserver`; it does not provide a legacy renderer or browser compatibility path.
221
+
222
+ - Every row needs a stable, non-empty `id` (string or finite number), or an explicit `getRowId`. Array positions, `_id`, and `key` are not inferred. IDs must be unique after string conversion because selection and editing use those keys. For another domain key, pass `getRowId={(row) => row.accountId}`.
223
+ - `paginationModel` uses a zero-based non-negative integer `page` and a positive integer `pageSize`. `pageSizeOptions` configures the footer selector. Changing size resets the page. Filtering notifies controlled pagination owners to return to page zero. Shrinking client data clamps the displayed page.
224
+ - The header checkbox selects eligible rows on the current page. Selecting or deselecting a page preserves selections elsewhere. `isRowSelectable` applies to page selection, individual checkboxes, and API selection. `clearSelection()` and the toolbar clear action clear the whole selection. In server mode, selection IDs can include unloaded rows; `getSelectedRows()` contains loaded row objects only. In Pro hierarchy mode, `isRowSelectable` receives original business rows and excludes synthetic group rows.
225
+ - Sorting cycles ascending, descending, then unsorted. Use `Manage View` to change density or save/reset a view. The built-in saved view lasts for the mounted grid; durable persistence uses the exported preset and application storage.
226
+ - Enter or F2 starts an editable cell; Enter saves and Escape cancels. While a save is processing it cannot be cancelled or edited again. Rejected saves retain the draft and display the error. `processRowUpdate` must preserve row identity. New authoritative row objects replace the local accepted-value overlay.
227
+ - Custom `renderEditCell` controls receive `autoFocus` for the cell that initiated editing. Forward it to the design-system control so row editing focuses only that editor. Use small Input/Dropdown controls at full cell width; editing padding accommodates their standard height. The account Status examples display a Chip and edit through a Dropdown, including keyboard selection and cancellation.
228
+ - Arrow keys, Home/End, and Page Up/Down navigate cells. Enter on a sortable header cycles sorting; Ctrl/Cmd+Enter opens its menu. F2 enters the header's controls, where Tab moves between sorting, the menu and resizing. The resize handle accepts Left/Right, Shift+Left/Right for larger steps, and Home/End for width limits. Enter opens embedded controls in a non-editable body cell; Escape returns to its cell. Search, filter inputs, and custom text editors retain their native keys. Shift+arrow extends a cell range, and Shift+Space toggles a row.
229
+ - Column dragging starts from the rendered width, including flexible columns, and publishes at most one width update per animation frame plus the final release position. Pointer capture supports mouse, pen and touch; right-pinned columns resize from their left edge. Escape, pointer cancellation and window blur end the drag at its latest position. Unmount discards pending work. Controlled widths continue to require the owner to apply `onColumnWidthModelChange`.
230
+ - Column tracks and pinned offsets use shared CSS variables so width changes do not rebuild unchanged rows. Keep column definitions, row objects and render callbacks stable between unrelated updates; replace changed row objects so memoized business content refreshes.
231
+
232
+ ## Server requests and exports
233
+
234
+ Memoize column definitions and the `dataSource` object. Equivalent column definitions and callback changes do not restart a request; changes to query state do. `getRows(request)` must return `{ rows, rowCount }` with a known non-negative integer total. Apply filtering and sorting before paging on the backend. Requests carry cancellation signals; superseded responses are ignored. Both synchronous and asynchronous failures enter the error state and expose a Retry action.
235
+
236
+ `apiRef.current.exportData()` serializes loaded data synchronously. In server mode it rejects `all` and `filtered` scopes, and rejects `selected` when selected IDs include unloaded rows. Connect `exportDataSource` for those scopes through the toolbar export contract. The request includes selected IDs, filters, sorting, columns, and pagination. Without that service, unavailable scopes are disabled with an explanation. Superseded or unmounted exports cannot trigger a download or success callback.
237
+
238
+ CSV serialization quotes delimiters and escapes formula-leading string values and headers. Actual numeric values remain numeric. The backend export service must apply equivalent protections and its own access checks.
239
+
240
+ For bulk clipboard/fill/clear transactions, `onRowsUpdate` is the application persistence boundary. This synchronous transaction API is distinct from the asynchronous per-row `processRowUpdate` lifecycle. Applications must handle batch persistence, authorization, conflicts, and rollback for their backend.
241
+
242
+ Storybook provides `EnterpriseOperations`, `ServerRecovery`, `AccessibleEditing`, and `DarkTheme`, alongside the existing feature stories. See `docs/design-system/DATA_GRID_ENTERPRISE_REVIEW.md` in the repository for the benchmark scope and qualification limits.
243
+
244
+ ## Row reordering and example source
245
+
246
+ `isRowDraggable` enables native dragging on data rows for host-owned drop interactions. Built-in row reordering takes precedence.
247
+
248
+ `rowReordering` uses the design-system DragHandle and the animation package's pointer and layout controllers. Drag with mouse, pen, or touch; neighboring rows make room before release. Arrow Up/Down moves the focused handle one row, and Home/End moves it to a visible edge. Escape, pointer cancellation, capture loss, window blur, and viewport resizing cancel the drag. Reduced-motion users get direct positioning without animated settling.
249
+
250
+ `onRowOrderChange(order, change)` emits once for a committed move. Controlled `rowOrder` requires the owner to apply the supplied order. Filtered and paginated views resolve the target by row ID into the source order. Pinned rows remain anchored; sorting, loading, active editing, and expanded detail panels disable manual reordering with an explanatory handle title. Pointer targeting uses mounted rows; keyboard and API ordering remain available independently of pointer geometry.
251
+
252
+ Every DataGrid Storybook example uses the shared `DocumentationDemo` frame: Show code, copy, download TSX, reset, and preview container widths. Its source is the generated complete application module used by Docs, including imports, data, handlers, and the design-system provider.
253
+
254
+ Columns accept `cellBackgroundColor` and `cellColor` as CSS color values or
255
+ callbacks receiving `DataGridCellParams<Row>`. Use semantic theme tokens for
256
+ conditional data formatting. Returning `undefined` preserves the normal and
257
+ pinned-cell surface. Cell selection has priority over conditional fills; the
258
+ grid continues to own keyboard focus, sizing, editing and accessible semantics.
259
+
260
+ ## Neutral workbook export
261
+
262
+ `exportTabularWorkbook(rows, { sheetName })` writes actual OOXML `.xlsx` bytes from
263
+ string, finite number, boolean or empty cells. It preserves numeric/boolean types,
264
+ freezes the header, escapes XML, and always writes user text as literal strings
265
+ rather than executable formulas. Sheet names and Excel cell limits are validated;
266
+ the bounded writer accepts up to 100,000 rows and 2 million cells. Scheduler Pro's
267
+ event workbook and Gantt's project workbook reuse this single neutral export engine.
268
+
269
+ ### Shared query and viewport contracts
270
+
271
+ `filterDataGridRows` supports `logicOperator: 'and' | 'or'` (default AND), negative
272
+ text predicates, numeric/date comparisons, `isEmpty` / `isNotEmpty`, and exact
273
+ `isAnyOf` selection through `values: string[]`. Keep `value: ''` for unary/distinct
274
+ conditions. An empty distinct array matches no rows. Quick search remains ANDed
275
+ with field predicates. Unknown active fields/operators and invalid comparisons
276
+ reject. The built-in panel edits text/comparison/unary predicates; applications
277
+ provide distinct-value selection through a custom filter panel (Gantt does so).
278
+
279
+ `sortDataGridRows` accepts one sort model or an ordered array of models. Ties keep
280
+ input order and custom comparators remain authoritative. This neutral helper does
281
+ not change the React grid's existing single-sort state contract.
282
+
283
+ React `onViewportChange({ scrollLeft, scrollTop, viewportWidth, viewportHeight })`
284
+ reports measured scrolling through a public callback. Composed timeline libraries
285
+ can window dense decorations without inspecting private grid DOM. The callback
286
+ must not mutate controlled layout in a way that repeatedly changes its own size.
287
+
288
+ `api.scrollToPosition({ left?, top? })` moves the owned scroller using nonnegative
289
+ CSS-pixel offsets and reports the browser's clamped position. Invalid offsets
290
+ reject before either axis changes. Gantt uses this API to reveal keyboard-focused
291
+ SVG tasks consistently across browsers, including tasks inside very wide cells.
292
+
293
+ ## Shared composition and report contracts
294
+
295
+ `DataGridFilterPanel` is exported from `/react` for capability workbenches that
296
+ share the grid's filter model and controls. It is the same panel used by DataGrid.
297
+ The neutral root exports `exportTabularWorkbook` and `assembleRasterPdf` for
298
+ first-party tabular and browser-rendered report consumers. Raster PDF pages are
299
+ JPEG images. Supply the title, language, and an ordered text alternative for each
300
+ page to tag those images as PDF figures. The image content stays raster.
301
+
302
+ The React grid inherits the active design-system provider's `styleNonce` for its scoped stylesheet. A host with a nonce-based Content Security Policy can configure this on `QuickBuilderDesignSystemProvider`.
303
+
304
+ ### Portable tabular reports
305
+
306
+ Use `exportTabularCsv(rows)` for CSV with the same spreadsheet text protection
307
+ as grid exports. Use `exportTabularSvgPages(rows, { title })` for standalone SVG
308
+ report pages with repeated column headers. Supply an already-authorized row
309
+ projection.