@ornery/ui-grid-react 0.1.4 → 0.1.6
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/UiGrid.d.ts +11 -0
- package/dist/UiGrid.d.ts.map +1 -0
- package/dist/gridStateMath.d.ts +8 -0
- package/dist/gridStateMath.d.ts.map +1 -0
- package/dist/index.d.ts +13 -133
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1248 -1202
- package/dist/index.mjs +1198 -1131
- package/dist/mountUiGrid.d.ts +4 -0
- package/dist/mountUiGrid.d.ts.map +1 -0
- package/dist/rustWasmGridEngine.d.ts +8 -0
- package/dist/rustWasmGridEngine.d.ts.map +1 -0
- package/dist/{index.d.mts → useGridState.d.ts} +14 -37
- package/dist/useGridState.d.ts.map +1 -0
- package/dist/useVirtualScroll.d.ts +20 -0
- package/dist/useVirtualScroll.d.ts.map +1 -0
- package/dist/virtualScrollMath.d.ts +17 -0
- package/dist/virtualScrollMath.d.ts.map +1 -0
- package/package.json +3 -3
- package/src/UiGrid.test.tsx +2 -1
- package/src/UiGrid.tsx +330 -74
- package/src/gridStateMath.test.ts +49 -0
- package/src/gridStateMath.ts +32 -0
- package/src/index.ts +3 -0
- package/src/mountUiGrid.tsx +10 -0
- package/src/rustWasmGridEngine.test.ts +56 -0
- package/src/rustWasmGridEngine.ts +23 -0
- package/src/ui-grid.css +161 -1
- package/src/useGridState.ts +664 -343
- package/src/useVirtualScroll.ts +13 -10
- package/src/virtualScrollMath.test.ts +44 -0
- package/src/virtualScrollMath.ts +36 -0
- package/tsconfig.build.json +6 -0
- package/tsconfig.dts.json +15 -0
- package/CLAUDE.md +0 -283
package/dist/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,597 +17,106 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
|
|
20
30
|
// src/index.ts
|
|
21
31
|
var index_exports = {};
|
|
22
32
|
__export(index_exports, {
|
|
23
|
-
DEFAULT_GRID_LABELS: () =>
|
|
33
|
+
DEFAULT_GRID_LABELS: () => import_ui_grid4.DEFAULT_GRID_LABELS,
|
|
24
34
|
UiGrid: () => UiGrid,
|
|
35
|
+
buildGridTemplateColumns: () => buildGridTemplateColumns,
|
|
36
|
+
computeViewportHeightPx: () => computeViewportHeightPx,
|
|
37
|
+
computeViewportRows: () => computeViewportRows,
|
|
38
|
+
enableReactUiGridWasmEngine: () => enableReactUiGridWasmEngine,
|
|
39
|
+
formatPaginationSummary: () => formatPaginationSummary,
|
|
40
|
+
mountUiGrid: () => mountUiGrid,
|
|
41
|
+
orderVisibleColumns: () => orderVisibleColumns,
|
|
42
|
+
registerReactUiGridWasmEngineFromModule: () => registerReactUiGridWasmEngineFromModule,
|
|
43
|
+
resolveBenchmarkIterations: () => resolveBenchmarkIterations,
|
|
25
44
|
useGridState: () => useGridState,
|
|
26
45
|
useVirtualScroll: () => useVirtualScroll
|
|
27
46
|
});
|
|
28
47
|
module.exports = __toCommonJS(index_exports);
|
|
29
48
|
|
|
49
|
+
// src/UiGrid.tsx
|
|
50
|
+
var import_react3 = __toESM(require("react"));
|
|
51
|
+
|
|
30
52
|
// src/useGridState.ts
|
|
31
53
|
var import_react = require("react");
|
|
32
|
-
var import_ui_grid3 = require("@ornery/ui-grid");
|
|
33
54
|
|
|
34
|
-
//
|
|
35
|
-
|
|
36
|
-
|
|
55
|
+
// src/gridStateMath.ts
|
|
56
|
+
var import_ui_grid = require("@ornery/ui-grid");
|
|
57
|
+
function orderVisibleColumns(columns, order) {
|
|
58
|
+
return [...columns].filter((column) => column.visible !== false).sort((left, right) => order.indexOf(left.name) - order.indexOf(right.name));
|
|
37
59
|
}
|
|
38
|
-
function
|
|
39
|
-
return
|
|
60
|
+
function buildGridTemplateColumns(columns) {
|
|
61
|
+
return columns.map((column) => (0, import_ui_grid.gridColumnWidth)(column)).join(" ");
|
|
40
62
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
var SORT_DIRECTIONS = {
|
|
44
|
-
asc: "asc",
|
|
45
|
-
desc: "desc",
|
|
46
|
-
none: "none"
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
// ../ui-grid/src/lib/grid/grid.utils.ts
|
|
50
|
-
var PROTECTED_PATH_SEGMENTS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
51
|
-
function getPathValue(record, path) {
|
|
52
|
-
return path.split(".").reduce((current, part) => {
|
|
53
|
-
if (current === null || current === void 0 || typeof current !== "object") {
|
|
54
|
-
return void 0;
|
|
55
|
-
}
|
|
56
|
-
if (PROTECTED_PATH_SEGMENTS.has(part)) {
|
|
57
|
-
return void 0;
|
|
58
|
-
}
|
|
59
|
-
if (!Object.prototype.hasOwnProperty.call(current, part)) {
|
|
60
|
-
return void 0;
|
|
61
|
-
}
|
|
62
|
-
return current[part];
|
|
63
|
-
}, record);
|
|
63
|
+
function resolveBenchmarkIterations(iterations, configuredIterations) {
|
|
64
|
+
return Math.max(1, iterations ?? configuredIterations ?? 25);
|
|
64
65
|
}
|
|
65
|
-
function
|
|
66
|
-
if (
|
|
67
|
-
return
|
|
66
|
+
function formatPaginationSummary(totalItems, firstRowIndex, lastRowIndex) {
|
|
67
|
+
if (totalItems === 0) {
|
|
68
|
+
return "0-0 of 0";
|
|
68
69
|
}
|
|
69
|
-
|
|
70
|
-
return getPathValue(row, column.field);
|
|
71
|
-
}
|
|
72
|
-
return row[column.name];
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// ../ui-grid/src/lib/grid/grid.core.identity.ts
|
|
76
|
-
function buildGridSortState(columnName, direction) {
|
|
77
|
-
return {
|
|
78
|
-
columnName,
|
|
79
|
-
direction: direction ?? SORT_DIRECTIONS.asc
|
|
80
|
-
};
|
|
70
|
+
return `${firstRowIndex + 1}-${lastRowIndex + 1} of ${totalItems}`;
|
|
81
71
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
function beginGridEditSession(rowId, columnName, editingValue) {
|
|
85
|
-
const position = { rowId, columnName };
|
|
86
|
-
return {
|
|
87
|
-
focusedCell: position,
|
|
88
|
-
editingCell: position,
|
|
89
|
-
editingValue
|
|
90
|
-
};
|
|
72
|
+
function computeViewportHeightPx(viewportHeight, autoViewportHeight) {
|
|
73
|
+
return `${viewportHeight ?? autoViewportHeight ?? 560}px`;
|
|
91
74
|
}
|
|
92
|
-
function
|
|
93
|
-
return
|
|
94
|
-
editingCell: null,
|
|
95
|
-
editingValue: ""
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
function stringifyGridEditorValue(value) {
|
|
99
|
-
if (value instanceof Date) {
|
|
100
|
-
return value.toISOString().slice(0, 10);
|
|
101
|
-
}
|
|
102
|
-
return value === null || value === void 0 ? "" : String(value);
|
|
75
|
+
function computeViewportRows(viewportHeight, rowHeight) {
|
|
76
|
+
return Math.max(1, Math.ceil((viewportHeight ?? 560) / (rowHeight ?? 44)));
|
|
103
77
|
}
|
|
104
78
|
|
|
105
|
-
//
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
return {
|
|
112
|
-
request: "top",
|
|
113
|
-
nextState: {
|
|
114
|
-
...context.state,
|
|
115
|
-
dataLoading: true,
|
|
116
|
-
previousVisibleRows: context.visibleRows
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
if (context.state.scrollDown && context.startIndex + context.viewportRows >= Math.max(context.visibleRows - context.threshold, 0)) {
|
|
121
|
-
return {
|
|
122
|
-
request: "bottom",
|
|
123
|
-
nextState: {
|
|
124
|
-
...context.state,
|
|
125
|
-
dataLoading: true,
|
|
126
|
-
previousVisibleRows: context.visibleRows
|
|
127
|
-
}
|
|
128
|
-
};
|
|
79
|
+
// src/useGridState.ts
|
|
80
|
+
var import_ui_grid2 = require("@ornery/ui-grid");
|
|
81
|
+
function escapeCssSelectorValue(value) {
|
|
82
|
+
const nativeEscape = globalThis.CSS?.escape;
|
|
83
|
+
if (typeof nativeEscape === "function") {
|
|
84
|
+
return nativeEscape(value);
|
|
129
85
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
dataLoading: false
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
function resetInfiniteScrollState(scrollUp, scrollDown) {
|
|
141
|
-
return {
|
|
142
|
-
scrollUp,
|
|
143
|
-
scrollDown,
|
|
144
|
-
dataLoading: false,
|
|
145
|
-
previousVisibleRows: 0
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
function saveInfiniteScrollPercentage(state, visibleRows) {
|
|
149
|
-
return {
|
|
150
|
-
...state,
|
|
151
|
-
previousVisibleRows: visibleRows
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
function setInfiniteScrollDirectionsState(state, scrollUp, scrollDown) {
|
|
155
|
-
return {
|
|
156
|
-
...state,
|
|
157
|
-
scrollUp,
|
|
158
|
-
scrollDown
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
// ../ui-grid/src/lib/grid/grid.core.row-state.ts
|
|
163
|
-
function toggleGridRowExpanded(expandedRows, rowId) {
|
|
164
|
-
const expanded = !expandedRows[rowId];
|
|
165
|
-
return {
|
|
166
|
-
expanded,
|
|
167
|
-
nextExpandedRows: {
|
|
168
|
-
...expandedRows,
|
|
169
|
-
[rowId]: expanded
|
|
86
|
+
let output = "";
|
|
87
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
88
|
+
const codePoint = value.charCodeAt(index);
|
|
89
|
+
const character = value.charAt(index);
|
|
90
|
+
if (codePoint === 0) {
|
|
91
|
+
output += "\uFFFD";
|
|
92
|
+
continue;
|
|
170
93
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
}
|
|
178
|
-
return nextExpandedRows;
|
|
179
|
-
}
|
|
180
|
-
function setGridTreeRowExpanded(expandedTreeRows, rowId, expanded) {
|
|
181
|
-
return {
|
|
182
|
-
...expandedTreeRows,
|
|
183
|
-
[rowId]: expanded
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
function toggleGridTreeRowExpanded(expandedTreeRows, rowId) {
|
|
187
|
-
const expanded = !expandedTreeRows[rowId];
|
|
188
|
-
return {
|
|
189
|
-
expanded,
|
|
190
|
-
nextExpandedTreeRows: setGridTreeRowExpanded(expandedTreeRows, rowId, expanded)
|
|
191
|
-
};
|
|
192
|
-
}
|
|
193
|
-
function expandAllGridTreeRows(rows) {
|
|
194
|
-
const nextExpandedTreeRows = {};
|
|
195
|
-
for (const row of rows) {
|
|
196
|
-
if (row.hasChildren) {
|
|
197
|
-
nextExpandedTreeRows[row.id] = true;
|
|
94
|
+
const isControlCharacter = codePoint >= 1 && codePoint <= 31 || codePoint === 127;
|
|
95
|
+
const startsWithDigit = index === 0 && codePoint >= 48 && codePoint <= 57;
|
|
96
|
+
const secondCharDigitAfterHyphen = index === 1 && codePoint >= 48 && codePoint <= 57 && value.charCodeAt(0) === 45;
|
|
97
|
+
if (isControlCharacter || startsWithDigit || secondCharDigitAfterHyphen) {
|
|
98
|
+
output += `\\${codePoint.toString(16)} `;
|
|
99
|
+
continue;
|
|
198
100
|
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
// ../ui-grid/src/lib/grid/grid.core.state.ts
|
|
204
|
-
function normalizeGridSavedState(state) {
|
|
205
|
-
const normalized = {};
|
|
206
|
-
if (Array.isArray(state.columnOrder)) {
|
|
207
|
-
normalized.columnOrder = state.columnOrder.filter(
|
|
208
|
-
(columnName) => typeof columnName === "string" && isSafeStateKey(columnName)
|
|
209
|
-
);
|
|
210
|
-
}
|
|
211
|
-
if (state.filters && typeof state.filters === "object") {
|
|
212
|
-
normalized.filters = Object.entries(state.filters).reduce((accumulator, [key, value]) => {
|
|
213
|
-
if (typeof key === "string" && isSafeStateKey(key) && typeof value === "string") {
|
|
214
|
-
accumulator[key] = value;
|
|
215
|
-
}
|
|
216
|
-
return accumulator;
|
|
217
|
-
}, {});
|
|
218
|
-
}
|
|
219
|
-
if (state.sort && typeof state.sort === "object") {
|
|
220
|
-
normalized.sort = {
|
|
221
|
-
columnName: typeof state.sort.columnName === "string" && isSafeStateKey(state.sort.columnName) ? state.sort.columnName : null,
|
|
222
|
-
direction: state.sort.direction === SORT_DIRECTIONS.asc || state.sort.direction === SORT_DIRECTIONS.desc ? state.sort.direction : SORT_DIRECTIONS.none
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
if (Array.isArray(state.grouping)) {
|
|
226
|
-
normalized.grouping = state.grouping.filter(
|
|
227
|
-
(columnName) => typeof columnName === "string" && isSafeStateKey(columnName)
|
|
228
|
-
);
|
|
229
|
-
}
|
|
230
|
-
if (state.pagination && typeof state.pagination === "object") {
|
|
231
|
-
const paginationCurrentPage = Number(state.pagination.paginationCurrentPage);
|
|
232
|
-
const paginationPageSize = Number(state.pagination.paginationPageSize);
|
|
233
|
-
normalized.pagination = {
|
|
234
|
-
paginationCurrentPage: Number.isFinite(paginationCurrentPage) && paginationCurrentPage > 0 ? Math.floor(paginationCurrentPage) : 1,
|
|
235
|
-
paginationPageSize: Number.isFinite(paginationPageSize) && paginationPageSize >= 0 ? Math.floor(paginationPageSize) : 0
|
|
236
|
-
};
|
|
237
|
-
}
|
|
238
|
-
if (state.expandable && typeof state.expandable === "object") {
|
|
239
|
-
normalized.expandable = normalizeBooleanMap(state.expandable);
|
|
240
|
-
}
|
|
241
|
-
if (state.treeView && typeof state.treeView === "object") {
|
|
242
|
-
normalized.treeView = normalizeBooleanMap(state.treeView);
|
|
243
|
-
}
|
|
244
|
-
return normalized;
|
|
245
|
-
}
|
|
246
|
-
function normalizeBooleanMap(value) {
|
|
247
|
-
return Object.entries(value).reduce((accumulator, [key, entry]) => {
|
|
248
|
-
if (typeof key === "string" && isSafeStateKey(key) && typeof entry === "boolean") {
|
|
249
|
-
accumulator[key] = entry;
|
|
101
|
+
if (index === 0 && value.length === 1 && codePoint === 45) {
|
|
102
|
+
output += `\\${character}`;
|
|
103
|
+
continue;
|
|
250
104
|
}
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
}
|
|
254
|
-
function isSafeStateKey(value) {
|
|
255
|
-
return value !== "__proto__" && value !== "constructor" && value !== "prototype";
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
// ../ui-grid/src/lib/grid/ui-grid.events.ts
|
|
259
|
-
function raiseGridRenderingComplete(gridApi) {
|
|
260
|
-
gridApi.core.raise.renderingComplete(gridApi);
|
|
261
|
-
}
|
|
262
|
-
function raiseGridRowsRendered(gridApi, rows) {
|
|
263
|
-
gridApi.core.raise.rowsRendered(rows);
|
|
264
|
-
}
|
|
265
|
-
function raiseGridRowsVisibleChanged(gridApi, rows) {
|
|
266
|
-
gridApi.core.raise.rowsVisibleChanged(rows);
|
|
267
|
-
}
|
|
268
|
-
function raiseGridCanvasHeightChanged(gridApi, oldHeight, newHeight) {
|
|
269
|
-
gridApi.core.raise.canvasHeightChanged(oldHeight, newHeight);
|
|
270
|
-
}
|
|
271
|
-
function raiseGridDimensionChanged(gridApi, oldHeight, oldWidth, newHeight, newWidth) {
|
|
272
|
-
gridApi.core.raise.gridDimensionChanged(oldHeight, oldWidth, newHeight, newWidth);
|
|
273
|
-
}
|
|
274
|
-
function raiseGridScrollBegin(gridApi) {
|
|
275
|
-
gridApi.core.raise.scrollBegin();
|
|
276
|
-
}
|
|
277
|
-
function raiseGridScrollEnd(gridApi) {
|
|
278
|
-
gridApi.core.raise.scrollEnd();
|
|
279
|
-
}
|
|
280
|
-
function raiseGridSortChanged(gridApi, sortState) {
|
|
281
|
-
gridApi.core.raise.sortChanged(sortState.columnName, sortState.direction);
|
|
282
|
-
}
|
|
283
|
-
function raiseGridFilterChanged(gridApi, filters) {
|
|
284
|
-
gridApi.core.raise.filterChanged(filters);
|
|
285
|
-
}
|
|
286
|
-
function raiseGridGroupingChanged(gridApi, groupByColumns) {
|
|
287
|
-
gridApi.core.raise.groupingChanged(groupByColumns);
|
|
288
|
-
}
|
|
289
|
-
function raiseGridColumnOrderChanged(gridApi, order) {
|
|
290
|
-
gridApi.core.raise.columnOrderChanged(order);
|
|
291
|
-
}
|
|
292
|
-
function raiseGridBenchmarkComplete(gridApi, result) {
|
|
293
|
-
gridApi.core.raise.benchmarkComplete(result);
|
|
294
|
-
}
|
|
295
|
-
function raiseGridPaginationChanged(gridApi, currentPage, pageSize) {
|
|
296
|
-
gridApi.pagination.raise.paginationChanged(currentPage, pageSize);
|
|
297
|
-
}
|
|
298
|
-
function raiseGridExpandableRowStateChanged(gridApi, row, expanded) {
|
|
299
|
-
gridApi.expandable.raise.rowExpandedStateChanged(row, expanded);
|
|
300
|
-
}
|
|
301
|
-
function raiseGridTreeRowStateChanged(gridApi, row, expanded) {
|
|
302
|
-
if (expanded) {
|
|
303
|
-
gridApi.treeBase.raise.rowExpanded(row);
|
|
304
|
-
return;
|
|
305
|
-
}
|
|
306
|
-
gridApi.treeBase.raise.rowCollapsed(row);
|
|
307
|
-
}
|
|
308
|
-
function raiseGridNeedMoreData(gridApi, request) {
|
|
309
|
-
if (request === "top") {
|
|
310
|
-
gridApi.infiniteScroll.raise.needLoadMoreDataTop();
|
|
311
|
-
return;
|
|
312
|
-
}
|
|
313
|
-
gridApi.infiniteScroll.raise.needLoadMoreData();
|
|
314
|
-
}
|
|
315
|
-
function raiseGridBeginCellEdit(gridApi, rowEntity, column, triggerEvent) {
|
|
316
|
-
gridApi.edit.raise.beginCellEdit(rowEntity, column, triggerEvent);
|
|
317
|
-
}
|
|
318
|
-
function raiseGridAfterCellEdit(gridApi, rowEntity, column, newValue, oldValue) {
|
|
319
|
-
gridApi.edit.raise.afterCellEdit(rowEntity, column, newValue, oldValue);
|
|
320
|
-
}
|
|
321
|
-
function raiseGridCancelCellEdit(gridApi, rowEntity, column) {
|
|
322
|
-
gridApi.edit.raise.cancelCellEdit(rowEntity, column);
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
// ../ui-grid/src/lib/grid/ui-grid.state.ts
|
|
326
|
-
function moveArrayItem(items, fromIndex, toIndex) {
|
|
327
|
-
const next = [...items];
|
|
328
|
-
const [item] = next.splice(fromIndex, 1);
|
|
329
|
-
if (item === void 0) {
|
|
330
|
-
return next;
|
|
105
|
+
const isSafeCharacter = codePoint >= 128 || codePoint === 45 || codePoint === 95 || codePoint >= 48 && codePoint <= 57 || codePoint >= 65 && codePoint <= 90 || codePoint >= 97 && codePoint <= 122;
|
|
106
|
+
output += isSafeCharacter ? character : `\\${character}`;
|
|
331
107
|
}
|
|
332
|
-
|
|
333
|
-
return next;
|
|
334
|
-
}
|
|
335
|
-
function moveGridColumnOrderState(current, fromIndex, toIndex) {
|
|
336
|
-
return moveArrayItem(current, fromIndex, toIndex);
|
|
337
|
-
}
|
|
338
|
-
function createGridRestoreMutationPlan(state) {
|
|
339
|
-
const normalizedState = normalizeGridSavedState(state);
|
|
340
|
-
const plan = {};
|
|
341
|
-
if (normalizedState.columnOrder) {
|
|
342
|
-
plan.columnOrder = normalizedState.columnOrder;
|
|
343
|
-
}
|
|
344
|
-
if (normalizedState.filters) {
|
|
345
|
-
plan.filters = normalizedState.filters;
|
|
346
|
-
}
|
|
347
|
-
if (normalizedState.sort) {
|
|
348
|
-
plan.sort = normalizedState.sort;
|
|
349
|
-
}
|
|
350
|
-
if (normalizedState.grouping) {
|
|
351
|
-
plan.grouping = normalizedState.grouping;
|
|
352
|
-
}
|
|
353
|
-
if (normalizedState.pagination) {
|
|
354
|
-
plan.pagination = {
|
|
355
|
-
currentPage: normalizedState.pagination.paginationCurrentPage,
|
|
356
|
-
pageSize: normalizedState.pagination.paginationPageSize
|
|
357
|
-
};
|
|
358
|
-
}
|
|
359
|
-
if (normalizedState.expandable) {
|
|
360
|
-
plan.expandable = normalizedState.expandable;
|
|
361
|
-
}
|
|
362
|
-
if (normalizedState.treeView) {
|
|
363
|
-
plan.treeView = normalizedState.treeView;
|
|
364
|
-
}
|
|
365
|
-
return plan;
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
// ../ui-grid/src/lib/grid/ui-grid.commands.ts
|
|
369
|
-
function applyGridSortStateCommand(gridApi, setSortState, sortState) {
|
|
370
|
-
setSortState(sortState);
|
|
371
|
-
raiseGridSortChanged(gridApi, sortState);
|
|
372
|
-
}
|
|
373
|
-
function sortGridColumnCommand(gridApi, setSortState, columnName, direction) {
|
|
374
|
-
applyGridSortStateCommand(gridApi, setSortState, buildGridSortState(columnName, direction));
|
|
108
|
+
return output;
|
|
375
109
|
}
|
|
376
|
-
function updateGridFilterCommand(gridApi, updateFilters, getFilters, columnName, value) {
|
|
377
|
-
updateFilters((current) => ({
|
|
378
|
-
...current,
|
|
379
|
-
[columnName]: value
|
|
380
|
-
}));
|
|
381
|
-
raiseGridFilterChanged(gridApi, getFilters());
|
|
382
|
-
}
|
|
383
|
-
function clearGridFiltersCommand(gridApi, setFilters) {
|
|
384
|
-
const nextFilters = {};
|
|
385
|
-
setFilters(nextFilters);
|
|
386
|
-
raiseGridFilterChanged(gridApi, nextFilters);
|
|
387
|
-
}
|
|
388
|
-
function clearGridGroupingCommand(gridApi, setGroupByColumns, shouldRaise = true) {
|
|
389
|
-
const nextGrouping = [];
|
|
390
|
-
setGroupByColumns(nextGrouping);
|
|
391
|
-
if (shouldRaise) {
|
|
392
|
-
raiseGridGroupingChanged(gridApi, nextGrouping);
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
function moveGridColumnCommand(gridApi, canMoveColumns, updateColumnOrder, fromIndex, toIndex) {
|
|
396
|
-
if (!canMoveColumns) {
|
|
397
|
-
return;
|
|
398
|
-
}
|
|
399
|
-
updateColumnOrder((current) => {
|
|
400
|
-
const next = moveGridColumnOrderState(current, fromIndex, toIndex);
|
|
401
|
-
raiseGridColumnOrderChanged(gridApi, next);
|
|
402
|
-
return next;
|
|
403
|
-
});
|
|
404
|
-
}
|
|
405
|
-
function seekGridPaginationCommand(gridApi, setCurrentPage, getTotalPages, getEffectivePageSize, page) {
|
|
406
|
-
const nextPage = seekGridPage(page, getTotalPages());
|
|
407
|
-
setCurrentPage(nextPage);
|
|
408
|
-
raiseGridPaginationChanged(gridApi, nextPage, getEffectivePageSize());
|
|
409
|
-
}
|
|
410
|
-
function setGridPaginationPageSizeCommand(gridApi, setPageSize, setCurrentPage, pageSize) {
|
|
411
|
-
const nextPageSize = resolveGridPageSize(pageSize);
|
|
412
|
-
if (nextPageSize === null) {
|
|
413
|
-
return;
|
|
414
|
-
}
|
|
415
|
-
setPageSize(nextPageSize);
|
|
416
|
-
setCurrentPage(1);
|
|
417
|
-
raiseGridPaginationChanged(gridApi, 1, nextPageSize);
|
|
418
|
-
}
|
|
419
|
-
function restoreGridStateCommand(gridApi, state, access) {
|
|
420
|
-
const restorePlan = createGridRestoreMutationPlan(state);
|
|
421
|
-
if (restorePlan.columnOrder) {
|
|
422
|
-
access.setColumnOrder(restorePlan.columnOrder);
|
|
423
|
-
}
|
|
424
|
-
if (restorePlan.filters) {
|
|
425
|
-
access.setActiveFilters(restorePlan.filters);
|
|
426
|
-
raiseGridFilterChanged(gridApi, restorePlan.filters);
|
|
427
|
-
}
|
|
428
|
-
if (restorePlan.sort) {
|
|
429
|
-
access.setSortState(restorePlan.sort);
|
|
430
|
-
}
|
|
431
|
-
if (restorePlan.grouping) {
|
|
432
|
-
access.setGroupByColumns(restorePlan.grouping);
|
|
433
|
-
raiseGridGroupingChanged(gridApi, restorePlan.grouping);
|
|
434
|
-
}
|
|
435
|
-
if (restorePlan.pagination) {
|
|
436
|
-
access.setCurrentPage(restorePlan.pagination.currentPage);
|
|
437
|
-
access.setPageSize(restorePlan.pagination.pageSize);
|
|
438
|
-
raiseGridPaginationChanged(gridApi, restorePlan.pagination.currentPage, access.getEffectivePageSize());
|
|
439
|
-
}
|
|
440
|
-
if (restorePlan.expandable) {
|
|
441
|
-
access.setExpandedRows(restorePlan.expandable);
|
|
442
|
-
}
|
|
443
|
-
if (restorePlan.treeView) {
|
|
444
|
-
access.setExpandedTreeRows(restorePlan.treeView);
|
|
445
|
-
}
|
|
446
|
-
}
|
|
447
|
-
function toggleGridRowExpansionCommand(gridApi, canExpandRows, currentExpandedRows, rowId, setExpandedRows, findRowById) {
|
|
448
|
-
if (!canExpandRows) {
|
|
449
|
-
return;
|
|
450
|
-
}
|
|
451
|
-
const { expanded, nextExpandedRows } = toggleGridRowExpanded(currentExpandedRows, rowId);
|
|
452
|
-
setExpandedRows(nextExpandedRows);
|
|
453
|
-
const gridRow = findRowById(rowId);
|
|
454
|
-
if (!gridRow) {
|
|
455
|
-
return;
|
|
456
|
-
}
|
|
457
|
-
gridRow.expanded = expanded;
|
|
458
|
-
raiseGridExpandableRowStateChanged(gridApi, gridRow, expanded);
|
|
459
|
-
}
|
|
460
|
-
function expandAllGridRowsCommand(buildRows, data, setExpandedRows) {
|
|
461
|
-
setExpandedRows(expandAllGridRows(buildRows(data)));
|
|
462
|
-
}
|
|
463
|
-
function collapseAllGridRowsCommand(setExpandedRows) {
|
|
464
|
-
setExpandedRows({});
|
|
465
|
-
}
|
|
466
|
-
function toggleGridTreeRowCommand(gridApi, currentExpandedTreeRows, rowId, setExpandedTreeRows, findRowById) {
|
|
467
|
-
const { expanded, nextExpandedTreeRows } = toggleGridTreeRowExpanded(currentExpandedTreeRows, rowId);
|
|
468
|
-
setExpandedTreeRows(nextExpandedTreeRows);
|
|
469
|
-
const gridRow = findRowById(rowId);
|
|
470
|
-
if (gridRow) {
|
|
471
|
-
raiseGridTreeRowStateChanged(gridApi, gridRow, expanded);
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
function setGridTreeRowExpandedCommand(gridApi, currentExpandedTreeRows, rowId, expanded, setExpandedTreeRows, findRowById) {
|
|
475
|
-
setExpandedTreeRows(setGridTreeRowExpanded(currentExpandedTreeRows, rowId, expanded));
|
|
476
|
-
const gridRow = findRowById(rowId);
|
|
477
|
-
if (gridRow) {
|
|
478
|
-
raiseGridTreeRowStateChanged(gridApi, gridRow, expanded);
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
function expandAllGridTreeRowsCommand(buildRows, data, setExpandedTreeRows) {
|
|
482
|
-
setExpandedTreeRows(expandAllGridTreeRows(buildRows(data)));
|
|
483
|
-
}
|
|
484
|
-
function collapseAllGridTreeRowsCommand(setExpandedTreeRows) {
|
|
485
|
-
setExpandedTreeRows({});
|
|
486
|
-
}
|
|
487
|
-
function beginGridCellEditCommand(gridApi, access, row, column, currentValue, triggerEvent, initialValue) {
|
|
488
|
-
const nextEditSession = beginGridEditSession(
|
|
489
|
-
row.id,
|
|
490
|
-
column.name,
|
|
491
|
-
initialValue ?? stringifyGridEditorValue(currentValue)
|
|
492
|
-
);
|
|
493
|
-
access.setFocusedCell(nextEditSession.focusedCell);
|
|
494
|
-
access.setEditingCell(nextEditSession.editingCell);
|
|
495
|
-
access.setEditingValue(nextEditSession.editingValue);
|
|
496
|
-
raiseGridBeginCellEdit(gridApi, row.entity, column, triggerEvent);
|
|
497
|
-
return nextEditSession.editingCell;
|
|
498
|
-
}
|
|
499
|
-
function commitGridCellEditCommand(gridApi, access) {
|
|
500
|
-
const editingCell = access.getEditingCell();
|
|
501
|
-
if (!editingCell) {
|
|
502
|
-
return { committed: false };
|
|
503
|
-
}
|
|
504
|
-
const row = access.findRowById(editingCell.rowId);
|
|
505
|
-
const column = access.findColumnByName(editingCell.columnName);
|
|
506
|
-
if (!row || !column) {
|
|
507
|
-
access.setEditingCell(null);
|
|
508
|
-
return { committed: false };
|
|
509
|
-
}
|
|
510
|
-
const oldValue = getCellValue(row.entity, column);
|
|
511
|
-
const newValue = access.parseEditedValue(column, access.getEditingValue(), oldValue);
|
|
512
|
-
access.setCellValue(row.entity, column, newValue);
|
|
513
|
-
const clearedEditSession = clearGridEditSession();
|
|
514
|
-
access.setEditingCell(clearedEditSession.editingCell);
|
|
515
|
-
raiseGridAfterCellEdit(gridApi, row.entity, column, newValue, oldValue);
|
|
516
|
-
access.setEditingValue(clearedEditSession.editingValue);
|
|
517
|
-
return {
|
|
518
|
-
committed: true,
|
|
519
|
-
focusTarget: { rowId: row.id, columnName: column.name },
|
|
520
|
-
row,
|
|
521
|
-
column
|
|
522
|
-
};
|
|
523
|
-
}
|
|
524
|
-
function cancelGridCellEditCommand(gridApi, access) {
|
|
525
|
-
const editingCell = access.getEditingCell();
|
|
526
|
-
if (!editingCell) {
|
|
527
|
-
return {};
|
|
528
|
-
}
|
|
529
|
-
const row = access.findRowById(editingCell.rowId);
|
|
530
|
-
const column = access.findColumnByName(editingCell.columnName);
|
|
531
|
-
const clearedEditSession = clearGridEditSession();
|
|
532
|
-
access.setEditingCell(clearedEditSession.editingCell);
|
|
533
|
-
access.setEditingValue(clearedEditSession.editingValue);
|
|
534
|
-
if (!row || !column) {
|
|
535
|
-
return {};
|
|
536
|
-
}
|
|
537
|
-
raiseGridCancelCellEdit(gridApi, row.entity, column);
|
|
538
|
-
return { focusTarget: editingCell };
|
|
539
|
-
}
|
|
540
|
-
function maybeRequestInfiniteScrollCommand(gridApi, access) {
|
|
541
|
-
if (!access.enabled || !access.virtualizationEnabled) {
|
|
542
|
-
return;
|
|
543
|
-
}
|
|
544
|
-
const { request, nextState } = maybeRequestInfiniteScrollData({
|
|
545
|
-
state: access.state,
|
|
546
|
-
startIndex: access.startIndex,
|
|
547
|
-
visibleRows: access.visibleRows,
|
|
548
|
-
viewportRows: access.viewportRows,
|
|
549
|
-
threshold: access.threshold
|
|
550
|
-
});
|
|
551
|
-
if (request === "top" || request === "bottom") {
|
|
552
|
-
access.setState(nextState);
|
|
553
|
-
raiseGridNeedMoreData(gridApi, request);
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
function completeGridInfiniteScrollDataLoadCommand(currentState, setState, scrollUp, scrollDown) {
|
|
557
|
-
setState(completeInfiniteScrollDataLoad(currentState, scrollUp, scrollDown));
|
|
558
|
-
return Promise.resolve();
|
|
559
|
-
}
|
|
560
|
-
function resetGridInfiniteScrollCommand(setState, scrollUp, scrollDown) {
|
|
561
|
-
setState(resetInfiniteScrollState(scrollUp, scrollDown));
|
|
562
|
-
}
|
|
563
|
-
function saveGridInfiniteScrollPercentageCommand(currentState, visibleRows, setState) {
|
|
564
|
-
setState(saveInfiniteScrollPercentage(currentState, visibleRows));
|
|
565
|
-
}
|
|
566
|
-
function setGridInfiniteScrollDirectionsCommand(currentState, setState, scrollUp, scrollDown) {
|
|
567
|
-
setState(setInfiniteScrollDirectionsState(currentState, scrollUp, scrollDown));
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
// ../ui-grid/src/lib/grid/ui-grid.host.ts
|
|
571
|
-
function observeGridHostSize(hostElement, onSizeChange) {
|
|
572
|
-
if (typeof ResizeObserver === "undefined") {
|
|
573
|
-
return null;
|
|
574
|
-
}
|
|
575
|
-
const observer = new ResizeObserver((entries) => {
|
|
576
|
-
const entry = entries[0];
|
|
577
|
-
if (!entry) {
|
|
578
|
-
return;
|
|
579
|
-
}
|
|
580
|
-
onSizeChange({
|
|
581
|
-
height: Math.round(entry.contentRect.height),
|
|
582
|
-
width: Math.round(entry.contentRect.width)
|
|
583
|
-
});
|
|
584
|
-
});
|
|
585
|
-
observer.observe(hostElement);
|
|
586
|
-
return observer;
|
|
587
|
-
}
|
|
588
|
-
function downloadGridCsvFile(csv, filename) {
|
|
589
|
-
if (typeof Blob === "undefined" || typeof URL === "undefined" || typeof document === "undefined") {
|
|
590
|
-
return;
|
|
591
|
-
}
|
|
592
|
-
const blob = new Blob([csv], { type: "text/csv;charset=utf-8" });
|
|
593
|
-
const url = URL.createObjectURL(blob);
|
|
594
|
-
const link = document.createElement("a");
|
|
595
|
-
link.href = url;
|
|
596
|
-
link.download = filename;
|
|
597
|
-
link.click();
|
|
598
|
-
URL.revokeObjectURL(url);
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
// src/useGridState.ts
|
|
602
110
|
function useGridState(options, onRegisterApi) {
|
|
603
111
|
const [activeFilters, setActiveFilters] = (0, import_react.useState)({});
|
|
604
112
|
const [groupByColumns, setGroupByColumns] = (0, import_react.useState)([]);
|
|
605
113
|
const [collapsedGroups, setCollapsedGroups] = (0, import_react.useState)({});
|
|
606
114
|
const [columnOrder, setColumnOrder] = (0, import_react.useState)([]);
|
|
607
115
|
const [hiddenRowReasons, setHiddenRowReasons] = (0, import_react.useState)({});
|
|
608
|
-
const [sortState, setSortState] = (0, import_react.useState)({
|
|
116
|
+
const [sortState, setSortState] = (0, import_react.useState)({
|
|
117
|
+
columnName: null,
|
|
118
|
+
direction: import_ui_grid2.SORT_DIRECTIONS.none
|
|
119
|
+
});
|
|
609
120
|
const [focusedCell, setFocusedCell] = (0, import_react.useState)(null);
|
|
610
121
|
const [editingCell, setEditingCell] = (0, import_react.useState)(null);
|
|
611
122
|
const [editingValue, setEditingValue] = (0, import_react.useState)("");
|
|
@@ -621,6 +132,7 @@ function useGridState(options, onRegisterApi) {
|
|
|
621
132
|
previousVisibleRows: 0
|
|
622
133
|
});
|
|
623
134
|
const [autoViewportHeight, setAutoViewportHeight] = (0, import_react.useState)(null);
|
|
135
|
+
const [pinnedColumns, setPinnedColumns] = (0, import_react.useState)({});
|
|
624
136
|
const gridContainerRef = (0, import_react.useRef)(null);
|
|
625
137
|
const initializedGridIdRef = (0, import_react.useRef)(null);
|
|
626
138
|
const lastCanvasHeightRef = (0, import_react.useRef)(0);
|
|
@@ -652,6 +164,8 @@ function useGridState(options, onRegisterApi) {
|
|
|
652
164
|
expandedRowsRef.current = expandedRows;
|
|
653
165
|
const expandedTreeRowsRef = (0, import_react.useRef)(expandedTreeRows);
|
|
654
166
|
expandedTreeRowsRef.current = expandedTreeRows;
|
|
167
|
+
const pinnedColumnsRef = (0, import_react.useRef)(pinnedColumns);
|
|
168
|
+
pinnedColumnsRef.current = pinnedColumns;
|
|
655
169
|
const currentPageRef = (0, import_react.useRef)(currentPage);
|
|
656
170
|
currentPageRef.current = currentPage;
|
|
657
171
|
const pageSizeRef = (0, import_react.useRef)(pageSize);
|
|
@@ -662,13 +176,21 @@ function useGridState(options, onRegisterApi) {
|
|
|
662
176
|
optionsRef.current = options;
|
|
663
177
|
const rowSize = options.rowHeight ?? 44;
|
|
664
178
|
const visibleColumns = (0, import_react.useMemo)(() => {
|
|
665
|
-
const
|
|
666
|
-
|
|
667
|
-
|
|
179
|
+
const orderedColumns = orderVisibleColumns(options.columnDefs, columnOrder);
|
|
180
|
+
const pinnedEntries = Object.entries(pinnedColumns);
|
|
181
|
+
if (pinnedEntries.length === 0) {
|
|
182
|
+
return orderedColumns;
|
|
183
|
+
}
|
|
184
|
+
const columnByName = new Map(orderedColumns.map((column) => [column.name, column]));
|
|
185
|
+
const pinnedLeft = pinnedEntries.filter(([, direction]) => direction === "left").map(([columnName]) => columnByName.get(columnName)).filter((column) => column !== void 0);
|
|
186
|
+
const pinnedRight = pinnedEntries.filter(([, direction]) => direction === "right").map(([columnName]) => columnByName.get(columnName)).filter((column) => column !== void 0);
|
|
187
|
+
const centerColumns = orderedColumns.filter((column) => pinnedColumns[column.name] === void 0);
|
|
188
|
+
return [...pinnedLeft, ...centerColumns, ...pinnedRight];
|
|
189
|
+
}, [options.columnDefs, columnOrder, pinnedColumns]);
|
|
668
190
|
const visibleColumnsRef = (0, import_react.useRef)(visibleColumns);
|
|
669
191
|
visibleColumnsRef.current = visibleColumns;
|
|
670
192
|
const pipeline = (0, import_react.useMemo)(() => {
|
|
671
|
-
return
|
|
193
|
+
return import_ui_grid2.defaultGridEngine.buildPipeline({
|
|
672
194
|
options,
|
|
673
195
|
columns: visibleColumns,
|
|
674
196
|
activeFilters,
|
|
@@ -682,70 +204,116 @@ function useGridState(options, onRegisterApi) {
|
|
|
682
204
|
pageSize,
|
|
683
205
|
rowSize
|
|
684
206
|
});
|
|
685
|
-
}, [
|
|
207
|
+
}, [
|
|
208
|
+
options,
|
|
209
|
+
visibleColumns,
|
|
210
|
+
activeFilters,
|
|
211
|
+
sortState,
|
|
212
|
+
groupByColumns,
|
|
213
|
+
collapsedGroups,
|
|
214
|
+
hiddenRowReasons,
|
|
215
|
+
expandedRows,
|
|
216
|
+
expandedTreeRows,
|
|
217
|
+
currentPage,
|
|
218
|
+
pageSize,
|
|
219
|
+
rowSize
|
|
220
|
+
]);
|
|
686
221
|
const pipelineRef = (0, import_react.useRef)(pipeline);
|
|
687
222
|
pipelineRef.current = pipeline;
|
|
688
|
-
const labels = (0, import_react.useMemo)(() => (0,
|
|
223
|
+
const labels = (0, import_react.useMemo)(() => (0, import_ui_grid2.resolveGridLabels)(options.labels), [options.labels]);
|
|
689
224
|
const gridTemplateColumns = (0, import_react.useMemo)(
|
|
690
|
-
() => visibleColumns
|
|
225
|
+
() => buildGridTemplateColumns(visibleColumns),
|
|
691
226
|
[visibleColumns]
|
|
692
227
|
);
|
|
228
|
+
const isPinningEnabledFn = (0, import_react.useCallback)(() => {
|
|
229
|
+
return (0, import_ui_grid2.isPinningEnabled)(optionsRef.current);
|
|
230
|
+
}, []);
|
|
231
|
+
const isColumnPinnableFn = (0, import_react.useCallback)((column) => {
|
|
232
|
+
return (0, import_ui_grid2.isColumnPinnable)(optionsRef.current, column);
|
|
233
|
+
}, []);
|
|
234
|
+
const isPinnedFn = (0, import_react.useCallback)((column) => {
|
|
235
|
+
return pinnedColumnsRef.current[column.name] !== void 0;
|
|
236
|
+
}, []);
|
|
237
|
+
const pinnedOffsetFn = (0, import_react.useCallback)((column) => {
|
|
238
|
+
return (0, import_ui_grid2.computePinnedOffset)(visibleColumnsRef.current, pinnedColumnsRef.current, column);
|
|
239
|
+
}, []);
|
|
693
240
|
const resolveRowId = (0, import_react.useCallback)((row) => {
|
|
694
|
-
return (0,
|
|
241
|
+
return (0, import_ui_grid2.resolveGridRowId)(optionsRef.current, row);
|
|
695
242
|
}, []);
|
|
696
243
|
const buildRowsFromData = (0, import_react.useCallback)((data) => {
|
|
697
|
-
return (0,
|
|
244
|
+
return (0, import_ui_grid2.buildGridRows)(
|
|
698
245
|
{ ...optionsRef.current, data },
|
|
699
246
|
optionsRef.current.rowHeight ?? 44,
|
|
700
247
|
hiddenRowReasonsRef.current,
|
|
701
248
|
expandedRowsRef.current
|
|
702
249
|
);
|
|
703
250
|
}, []);
|
|
704
|
-
const findRowById = (0, import_react.useCallback)(
|
|
705
|
-
|
|
706
|
-
|
|
251
|
+
const findRowById = (0, import_react.useCallback)(
|
|
252
|
+
(rowId) => {
|
|
253
|
+
return (0, import_ui_grid2.findGridRowById)(buildRowsFromData(optionsRef.current.data), rowId);
|
|
254
|
+
},
|
|
255
|
+
[buildRowsFromData]
|
|
256
|
+
);
|
|
707
257
|
const canExpandRowsFn = (0, import_react.useCallback)(() => {
|
|
708
|
-
return
|
|
258
|
+
return import_ui_grid2.FEATURE_EXPANDABLE && (0, import_ui_grid2.canGridExpandRows)(optionsRef.current);
|
|
709
259
|
}, []);
|
|
710
260
|
const effectivePageSizeFn = (0, import_react.useCallback)((totalItems) => {
|
|
711
|
-
return (0,
|
|
261
|
+
return (0, import_ui_grid2.getEffectivePageSize)(optionsRef.current, pageSizeRef.current, totalItems);
|
|
712
262
|
}, []);
|
|
713
263
|
const getCurrentPageValueFn = (0, import_react.useCallback)((totalItems) => {
|
|
714
264
|
const ti = totalItems ?? pipelineRef.current.totalItems;
|
|
715
|
-
return (0,
|
|
265
|
+
return (0, import_ui_grid2.getCurrentPageValue)(
|
|
266
|
+
optionsRef.current,
|
|
267
|
+
currentPageRef.current,
|
|
268
|
+
ti,
|
|
269
|
+
pageSizeRef.current
|
|
270
|
+
);
|
|
716
271
|
}, []);
|
|
717
272
|
const getTotalPagesValueFn = (0, import_react.useCallback)((totalItems) => {
|
|
718
273
|
const ti = totalItems ?? pipelineRef.current.totalItems;
|
|
719
|
-
return (0,
|
|
274
|
+
return (0, import_ui_grid2.getTotalPagesValue)(optionsRef.current, ti, pageSizeRef.current);
|
|
720
275
|
}, []);
|
|
721
276
|
const getFirstRowIndexValueFn = (0, import_react.useCallback)((totalItems) => {
|
|
722
277
|
const ti = totalItems ?? pipelineRef.current.totalItems;
|
|
723
|
-
return (0,
|
|
278
|
+
return (0, import_ui_grid2.getFirstRowIndexValue)(
|
|
279
|
+
optionsRef.current,
|
|
280
|
+
currentPageRef.current,
|
|
281
|
+
ti,
|
|
282
|
+
pageSizeRef.current
|
|
283
|
+
);
|
|
724
284
|
}, []);
|
|
725
285
|
const getLastRowIndexValueFn = (0, import_react.useCallback)((totalItems) => {
|
|
726
286
|
const ti = totalItems ?? pipelineRef.current.totalItems;
|
|
727
|
-
return (0,
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
const condition = column.cellEditableCondition ?? optionsRef.current.cellEditableCondition ?? true;
|
|
734
|
-
if (typeof condition === "boolean") return condition;
|
|
735
|
-
const context = {
|
|
736
|
-
row: row.entity,
|
|
737
|
-
column,
|
|
738
|
-
rowIndex: row.index,
|
|
739
|
-
triggerEvent
|
|
740
|
-
};
|
|
741
|
-
return condition(context);
|
|
287
|
+
return (0, import_ui_grid2.getLastRowIndexValue)(
|
|
288
|
+
optionsRef.current,
|
|
289
|
+
currentPageRef.current,
|
|
290
|
+
ti,
|
|
291
|
+
pageSizeRef.current
|
|
292
|
+
);
|
|
742
293
|
}, []);
|
|
294
|
+
const isCellEditable = (0, import_react.useCallback)(
|
|
295
|
+
(row, column, triggerEvent) => {
|
|
296
|
+
if (!import_ui_grid2.FEATURE_CELL_EDIT) return false;
|
|
297
|
+
const editable = column.enableCellEdit ?? optionsRef.current.enableCellEdit ?? false;
|
|
298
|
+
if (!editable) return false;
|
|
299
|
+
const condition = column.cellEditableCondition ?? optionsRef.current.cellEditableCondition ?? true;
|
|
300
|
+
if (typeof condition === "boolean") return condition;
|
|
301
|
+
const context = {
|
|
302
|
+
row: row.entity,
|
|
303
|
+
column,
|
|
304
|
+
rowIndex: row.index,
|
|
305
|
+
triggerEvent
|
|
306
|
+
};
|
|
307
|
+
return condition(context);
|
|
308
|
+
},
|
|
309
|
+
[]
|
|
310
|
+
);
|
|
743
311
|
const shouldEditOnFocusFn = (0, import_react.useCallback)((column) => {
|
|
744
312
|
return column.enableCellEditOnFocus ?? optionsRef.current.enableCellEditOnFocus ?? false;
|
|
745
313
|
}, []);
|
|
746
314
|
const focusRenderedCell = (0, import_react.useCallback)((position) => {
|
|
747
315
|
const focusToken = ++renderedCellFocusTokenRef.current;
|
|
748
|
-
const selector = `.body-cell[data-row-id="${position.rowId}"][data-col-name="${position.columnName}"]`;
|
|
316
|
+
const selector = `.body-cell[data-row-id="${escapeCssSelectorValue(position.rowId)}"][data-col-name="${escapeCssSelectorValue(position.columnName)}"]`;
|
|
749
317
|
const doFocus = (retry = true) => {
|
|
750
318
|
if (focusToken !== renderedCellFocusTokenRef.current) return;
|
|
751
319
|
const container = gridContainerRef.current;
|
|
@@ -766,11 +334,12 @@ function useGridState(options, onRegisterApi) {
|
|
|
766
334
|
if (focusToken !== editorFocusTokenRef.current) return;
|
|
767
335
|
const ec = editingCellRef.current;
|
|
768
336
|
if (!ec) return;
|
|
769
|
-
const selector = `.cell-editor[data-row-id="${ec.rowId}"][data-col-name="${ec.columnName}"]`;
|
|
337
|
+
const selector = `.cell-editor[data-row-id="${escapeCssSelectorValue(ec.rowId)}"][data-col-name="${escapeCssSelectorValue(ec.columnName)}"]`;
|
|
770
338
|
const doFocus = (retry = true) => {
|
|
771
339
|
if (focusToken !== editorFocusTokenRef.current) return;
|
|
772
340
|
const currentEc = editingCellRef.current;
|
|
773
|
-
if (!currentEc || currentEc.rowId !== ec.rowId || currentEc.columnName !== ec.columnName)
|
|
341
|
+
if (!currentEc || currentEc.rowId !== ec.rowId || currentEc.columnName !== ec.columnName)
|
|
342
|
+
return;
|
|
774
343
|
const container = gridContainerRef.current;
|
|
775
344
|
if (!container) return;
|
|
776
345
|
const input = container.querySelector(selector);
|
|
@@ -789,12 +358,12 @@ function useGridState(options, onRegisterApi) {
|
|
|
789
358
|
refresh: () => setActiveFilters((current) => ({ ...current })),
|
|
790
359
|
getVisibleRows: () => pipelineRef.current.visibleRows,
|
|
791
360
|
setRowInvisible: (row, reason = "user") => {
|
|
792
|
-
const rowId = (0,
|
|
793
|
-
setHiddenRowReasons((current) => (0,
|
|
361
|
+
const rowId = (0, import_ui_grid2.resolveGridRowId)(optionsRef.current, row);
|
|
362
|
+
setHiddenRowReasons((current) => (0, import_ui_grid2.addGridRowInvisibleReason)(current, rowId, reason));
|
|
794
363
|
},
|
|
795
364
|
clearRowInvisible: (row, reason = "user") => {
|
|
796
|
-
const rowId = (0,
|
|
797
|
-
setHiddenRowReasons((current) => (0,
|
|
365
|
+
const rowId = (0, import_ui_grid2.resolveGridRowId)(optionsRef.current, row);
|
|
366
|
+
setHiddenRowReasons((current) => (0, import_ui_grid2.clearGridRowInvisibleReason)(current, rowId, reason));
|
|
798
367
|
},
|
|
799
368
|
setFilter: (columnName, value) => {
|
|
800
369
|
setActiveFilters((current) => {
|
|
@@ -811,19 +380,19 @@ function useGridState(options, onRegisterApi) {
|
|
|
811
380
|
queueMicrotask(() => gridApiRef.current.core.raise.filterChanged(nextFilters));
|
|
812
381
|
},
|
|
813
382
|
sortColumn: (columnName, direction) => {
|
|
814
|
-
sortGridColumnCommand(gridApiRef.current, (s) => setSortState(s), columnName, direction);
|
|
383
|
+
(0, import_ui_grid2.sortGridColumnCommand)(gridApiRef.current, (s) => setSortState(s), columnName, direction);
|
|
815
384
|
},
|
|
816
385
|
moveColumn: (fromIndex, toIndex) => {
|
|
817
|
-
moveGridColumnCommand(
|
|
386
|
+
(0, import_ui_grid2.moveGridColumnCommand)(
|
|
818
387
|
gridApiRef.current,
|
|
819
|
-
|
|
388
|
+
import_ui_grid2.FEATURE_COLUMN_MOVING && optionsRef.current.enableColumnMoving === true,
|
|
820
389
|
(updater) => setColumnOrder((current) => updater(current)),
|
|
821
390
|
fromIndex,
|
|
822
391
|
toIndex
|
|
823
392
|
);
|
|
824
393
|
},
|
|
825
394
|
toggleGrouping: (columnName) => {
|
|
826
|
-
if (!(
|
|
395
|
+
if (!(import_ui_grid2.FEATURE_GROUPING && (0, import_ui_grid2.isGridGroupingEnabled)(optionsRef.current))) return;
|
|
827
396
|
const current = groupByColumnsRef.current;
|
|
828
397
|
const next = current.includes(columnName) ? current.filter((n) => n !== columnName) : [...current, columnName];
|
|
829
398
|
groupByColumnsRef.current = next;
|
|
@@ -831,7 +400,11 @@ function useGridState(options, onRegisterApi) {
|
|
|
831
400
|
gridApiRef.current.core.raise.groupingChanged(next);
|
|
832
401
|
},
|
|
833
402
|
clearGrouping: () => {
|
|
834
|
-
|
|
403
|
+
(0, import_ui_grid2.clearGridGroupingCommand)(
|
|
404
|
+
gridApiRef.current,
|
|
405
|
+
(grouping) => setGroupByColumns(grouping),
|
|
406
|
+
false
|
|
407
|
+
);
|
|
835
408
|
},
|
|
836
409
|
benchmark: (iterations) => {
|
|
837
410
|
return runBenchmarkFn(iterations);
|
|
@@ -850,30 +423,30 @@ function useGridState(options, onRegisterApi) {
|
|
|
850
423
|
toggleRowExpansion: (row) => toggleRowExpansionByRefFn(row),
|
|
851
424
|
expandAllRows: () => expandAllRowsFn(),
|
|
852
425
|
collapseAllRows: () => {
|
|
853
|
-
collapseAllGridRowsCommand((e) => setExpandedRows(e));
|
|
426
|
+
(0, import_ui_grid2.collapseAllGridRowsCommand)((e) => setExpandedRows(e));
|
|
854
427
|
},
|
|
855
428
|
toggleAllRows: () => toggleAllRowsFn(),
|
|
856
429
|
treeExpandAllRows: () => {
|
|
857
|
-
expandAllGridTreeRowsCommand(
|
|
430
|
+
(0, import_ui_grid2.expandAllGridTreeRowsCommand)(
|
|
858
431
|
(data) => buildRowsFromData(data),
|
|
859
432
|
optionsRef.current.data,
|
|
860
433
|
(e) => setExpandedTreeRows(e)
|
|
861
434
|
);
|
|
862
435
|
},
|
|
863
436
|
treeCollapseAllRows: () => {
|
|
864
|
-
collapseAllGridTreeRowsCommand((e) => setExpandedTreeRows(e));
|
|
437
|
+
(0, import_ui_grid2.collapseAllGridTreeRowsCommand)((e) => setExpandedTreeRows(e));
|
|
865
438
|
},
|
|
866
439
|
treeToggleRow: (row) => toggleTreeRowByRefFn(row),
|
|
867
440
|
treeExpandRow: (row) => expandTreeRowByRefFn(row),
|
|
868
441
|
treeCollapseRow: (row) => collapseTreeRowByRefFn(row),
|
|
869
442
|
treeGetRowChildren: (row) => {
|
|
870
|
-
const rowId = (0,
|
|
443
|
+
const rowId = (0, import_ui_grid2.resolveGridRowId)(optionsRef.current, row);
|
|
871
444
|
return buildRowsFromData(optionsRef.current.data).filter((r) => r.parentId === rowId);
|
|
872
445
|
},
|
|
873
446
|
treeGetState: () => expandedTreeRowsRef.current,
|
|
874
447
|
treeSetState: (state) => setExpandedTreeRows({ ...state }),
|
|
875
448
|
infiniteScrollDataLoaded: (scrollUp, scrollDown) => {
|
|
876
|
-
return completeGridInfiniteScrollDataLoadCommand(
|
|
449
|
+
return (0, import_ui_grid2.completeGridInfiniteScrollDataLoadCommand)(
|
|
877
450
|
infiniteScrollStateRef.current,
|
|
878
451
|
(s) => setInfiniteScrollState(s),
|
|
879
452
|
scrollUp ?? infiniteScrollStateRef.current.scrollUp,
|
|
@@ -881,35 +454,35 @@ function useGridState(options, onRegisterApi) {
|
|
|
881
454
|
);
|
|
882
455
|
},
|
|
883
456
|
infiniteScrollReset: (scrollUp, scrollDown) => {
|
|
884
|
-
resetGridInfiniteScrollCommand(
|
|
457
|
+
(0, import_ui_grid2.resetGridInfiniteScrollCommand)(
|
|
885
458
|
(s) => setInfiniteScrollState(s),
|
|
886
459
|
scrollUp ?? infiniteScrollStateRef.current.scrollUp,
|
|
887
460
|
scrollDown ?? infiniteScrollStateRef.current.scrollDown
|
|
888
461
|
);
|
|
889
462
|
},
|
|
890
463
|
infiniteScrollSaveScrollPercentage: () => {
|
|
891
|
-
saveGridInfiniteScrollPercentageCommand(
|
|
464
|
+
(0, import_ui_grid2.saveGridInfiniteScrollPercentageCommand)(
|
|
892
465
|
infiniteScrollStateRef.current,
|
|
893
466
|
pipelineRef.current.visibleRows.length,
|
|
894
467
|
(s) => setInfiniteScrollState(s)
|
|
895
468
|
);
|
|
896
469
|
},
|
|
897
470
|
infiniteScrollDataRemovedTop: (scrollUp, scrollDown) => {
|
|
898
|
-
resetGridInfiniteScrollCommand(
|
|
471
|
+
(0, import_ui_grid2.resetGridInfiniteScrollCommand)(
|
|
899
472
|
(s) => setInfiniteScrollState(s),
|
|
900
473
|
scrollUp ?? infiniteScrollStateRef.current.scrollUp,
|
|
901
474
|
scrollDown ?? infiniteScrollStateRef.current.scrollDown
|
|
902
475
|
);
|
|
903
476
|
},
|
|
904
477
|
infiniteScrollDataRemovedBottom: (scrollUp, scrollDown) => {
|
|
905
|
-
resetGridInfiniteScrollCommand(
|
|
478
|
+
(0, import_ui_grid2.resetGridInfiniteScrollCommand)(
|
|
906
479
|
(s) => setInfiniteScrollState(s),
|
|
907
480
|
scrollUp ?? infiniteScrollStateRef.current.scrollUp,
|
|
908
481
|
scrollDown ?? infiniteScrollStateRef.current.scrollDown
|
|
909
482
|
);
|
|
910
483
|
},
|
|
911
484
|
infiniteScrollSetDirections: (scrollUp, scrollDown) => {
|
|
912
|
-
setGridInfiniteScrollDirectionsCommand(
|
|
485
|
+
(0, import_ui_grid2.setGridInfiniteScrollDirectionsCommand)(
|
|
913
486
|
infiniteScrollStateRef.current,
|
|
914
487
|
(s) => setInfiniteScrollState(s),
|
|
915
488
|
scrollUp,
|
|
@@ -917,7 +490,7 @@ function useGridState(options, onRegisterApi) {
|
|
|
917
490
|
);
|
|
918
491
|
},
|
|
919
492
|
saveState: () => {
|
|
920
|
-
return (0,
|
|
493
|
+
return (0, import_ui_grid2.buildGridSavedState)({
|
|
921
494
|
columnOrder: columnOrderRef.current,
|
|
922
495
|
activeFilters: activeFiltersRef.current,
|
|
923
496
|
sortState: sortStateRef.current,
|
|
@@ -926,11 +499,12 @@ function useGridState(options, onRegisterApi) {
|
|
|
926
499
|
pageSize: pageSizeRef.current,
|
|
927
500
|
totalItems: pipelineRef.current.totalItems,
|
|
928
501
|
expandedRows: expandedRowsRef.current,
|
|
929
|
-
expandedTreeRows: expandedTreeRowsRef.current
|
|
502
|
+
expandedTreeRows: expandedTreeRowsRef.current,
|
|
503
|
+
pinnedColumns: pinnedColumnsRef.current
|
|
930
504
|
});
|
|
931
505
|
},
|
|
932
506
|
restoreState: (state) => {
|
|
933
|
-
restoreGridStateCommand(gridApiRef.current, state, {
|
|
507
|
+
(0, import_ui_grid2.restoreGridStateCommand)(gridApiRef.current, state, {
|
|
934
508
|
setColumnOrder: (order) => setColumnOrder(order),
|
|
935
509
|
setActiveFilters: (filters) => setActiveFilters(filters),
|
|
936
510
|
setSortState: (s) => setSortState(s),
|
|
@@ -939,175 +513,228 @@ function useGridState(options, onRegisterApi) {
|
|
|
939
513
|
setPageSize: (ps) => setPageSize(ps),
|
|
940
514
|
setExpandedRows: (e) => setExpandedRows(e),
|
|
941
515
|
setExpandedTreeRows: (e) => setExpandedTreeRows(e),
|
|
516
|
+
setPinnedColumns: (p) => setPinnedColumns(p),
|
|
942
517
|
getEffectivePageSize: () => effectivePageSizeFn(pipelineRef.current.totalItems)
|
|
943
518
|
});
|
|
944
519
|
},
|
|
945
520
|
beginCellEdit: (row, columnName, triggerEvent) => {
|
|
946
|
-
const rowId = (0,
|
|
947
|
-
const gridRow = (0,
|
|
521
|
+
const rowId = (0, import_ui_grid2.resolveGridRowId)(optionsRef.current, row);
|
|
522
|
+
const gridRow = (0, import_ui_grid2.findGridRowById)(buildRowsFromData(optionsRef.current.data), rowId);
|
|
948
523
|
const column = visibleColumnsRef.current.find((c) => c.name === columnName);
|
|
949
524
|
if (!gridRow || !column || !isCellEditable(gridRow, column, triggerEvent)) return;
|
|
950
525
|
startCellEditFn(gridRow, column, triggerEvent);
|
|
951
526
|
},
|
|
952
527
|
endCellEdit: () => commitCellEditFn(),
|
|
953
528
|
cancelCellEdit: () => cancelCellEditFn(),
|
|
954
|
-
getEditingCell: () => editingCellRef.current
|
|
529
|
+
getEditingCell: () => editingCellRef.current,
|
|
530
|
+
pinColumn: (columnName, direction) => {
|
|
531
|
+
(0, import_ui_grid2.pinGridColumnCommand)(
|
|
532
|
+
gridApiRef.current,
|
|
533
|
+
isPinningEnabledFn(),
|
|
534
|
+
(v) => setPinnedColumns(v),
|
|
535
|
+
() => pinnedColumnsRef.current,
|
|
536
|
+
columnName,
|
|
537
|
+
direction
|
|
538
|
+
);
|
|
539
|
+
}
|
|
955
540
|
};
|
|
956
|
-
gridApiRef.current = (0,
|
|
541
|
+
gridApiRef.current = (0, import_ui_grid2.createGridApi)(bindings);
|
|
957
542
|
}
|
|
958
543
|
const gridApi = gridApiRef.current;
|
|
959
|
-
const seekPageFn = (0, import_react.useCallback)(
|
|
960
|
-
|
|
544
|
+
const seekPageFn = (0, import_react.useCallback)(
|
|
545
|
+
(page) => {
|
|
546
|
+
(0, import_ui_grid2.seekGridPaginationCommand)(
|
|
547
|
+
gridApiRef.current,
|
|
548
|
+
(nextPage) => setCurrentPage(nextPage),
|
|
549
|
+
() => getTotalPagesValueFn(),
|
|
550
|
+
() => effectivePageSizeFn(pipelineRef.current.totalItems),
|
|
551
|
+
page
|
|
552
|
+
);
|
|
553
|
+
},
|
|
554
|
+
[getTotalPagesValueFn, effectivePageSizeFn]
|
|
555
|
+
);
|
|
556
|
+
const togglePinFn = (0, import_react.useCallback)((column) => {
|
|
557
|
+
const current = pinnedColumnsRef.current[column.name];
|
|
558
|
+
const next = current === "left" ? "right" : current === "right" ? "none" : "left";
|
|
559
|
+
(0, import_ui_grid2.pinGridColumnCommand)(
|
|
961
560
|
gridApiRef.current,
|
|
962
|
-
(
|
|
963
|
-
() =>
|
|
964
|
-
() =>
|
|
965
|
-
|
|
561
|
+
isPinningEnabledFn(),
|
|
562
|
+
(v) => setPinnedColumns(v),
|
|
563
|
+
() => pinnedColumnsRef.current,
|
|
564
|
+
column.name,
|
|
565
|
+
next
|
|
966
566
|
);
|
|
967
|
-
}, [
|
|
567
|
+
}, []);
|
|
968
568
|
const setPaginationPageSizeFn = (0, import_react.useCallback)((ps) => {
|
|
969
|
-
setGridPaginationPageSizeCommand(
|
|
569
|
+
(0, import_ui_grid2.setGridPaginationPageSizeCommand)(
|
|
970
570
|
gridApiRef.current,
|
|
971
571
|
(nextPageSize) => setPageSize(nextPageSize),
|
|
972
572
|
(nextPage) => setCurrentPage(nextPage),
|
|
973
573
|
ps
|
|
974
574
|
);
|
|
975
575
|
}, []);
|
|
976
|
-
const toggleRowExpansionByRefFn = (0, import_react.useCallback)(
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
576
|
+
const toggleRowExpansionByRefFn = (0, import_react.useCallback)(
|
|
577
|
+
(row) => {
|
|
578
|
+
const rowId = (0, import_ui_grid2.resolveGridRowId)(optionsRef.current, row);
|
|
579
|
+
(0, import_ui_grid2.toggleGridRowExpansionCommand)(
|
|
580
|
+
gridApiRef.current,
|
|
581
|
+
import_ui_grid2.FEATURE_EXPANDABLE && (0, import_ui_grid2.canGridExpandRows)(optionsRef.current),
|
|
582
|
+
expandedRowsRef.current,
|
|
583
|
+
rowId,
|
|
584
|
+
(e) => setExpandedRows(e),
|
|
585
|
+
(resolvedRowId) => (0, import_ui_grid2.findGridRowById)(buildRowsFromData(optionsRef.current.data), resolvedRowId)
|
|
586
|
+
);
|
|
587
|
+
},
|
|
588
|
+
[buildRowsFromData]
|
|
589
|
+
);
|
|
987
590
|
const expandAllRowsFn = (0, import_react.useCallback)(() => {
|
|
988
|
-
if (!(0,
|
|
989
|
-
expandAllGridRowsCommand(
|
|
591
|
+
if (!(0, import_ui_grid2.canGridExpandRows)(optionsRef.current)) return;
|
|
592
|
+
(0, import_ui_grid2.expandAllGridRowsCommand)(
|
|
990
593
|
(data) => buildRowsFromData(data),
|
|
991
594
|
optionsRef.current.data,
|
|
992
595
|
(e) => setExpandedRows(e)
|
|
993
596
|
);
|
|
994
597
|
}, [buildRowsFromData]);
|
|
995
598
|
const toggleAllRowsFn = (0, import_react.useCallback)(() => {
|
|
996
|
-
const allExpanded = (0,
|
|
599
|
+
const allExpanded = (0, import_ui_grid2.areAllGridRowsExpanded)(
|
|
600
|
+
buildRowsFromData(optionsRef.current.data),
|
|
601
|
+
expandedRowsRef.current
|
|
602
|
+
);
|
|
997
603
|
if (allExpanded) {
|
|
998
|
-
collapseAllGridRowsCommand((e) => setExpandedRows(e));
|
|
604
|
+
(0, import_ui_grid2.collapseAllGridRowsCommand)((e) => setExpandedRows(e));
|
|
999
605
|
} else {
|
|
1000
606
|
expandAllRowsFn();
|
|
1001
607
|
}
|
|
1002
608
|
}, [buildRowsFromData, expandAllRowsFn]);
|
|
1003
|
-
const toggleTreeRowByRefFn = (0, import_react.useCallback)(
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
rowId,
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
column
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
parseEditedValue: (column, value, oldValue) => (0, import_ui_grid3.parseGridEditedValue)(column, value, oldValue),
|
|
1064
|
-
setCellValue: (rowEntity, column, value) => {
|
|
1065
|
-
const fieldPath = column.editModelField ?? column.field ?? column.name;
|
|
1066
|
-
(0, import_ui_grid3.setPathValue)(rowEntity, fieldPath, value);
|
|
609
|
+
const toggleTreeRowByRefFn = (0, import_react.useCallback)(
|
|
610
|
+
(row) => {
|
|
611
|
+
const rowId = (0, import_ui_grid2.resolveGridRowId)(optionsRef.current, row);
|
|
612
|
+
(0, import_ui_grid2.toggleGridTreeRowCommand)(
|
|
613
|
+
gridApiRef.current,
|
|
614
|
+
expandedTreeRowsRef.current,
|
|
615
|
+
rowId,
|
|
616
|
+
(e) => setExpandedTreeRows(e),
|
|
617
|
+
(resolvedRowId) => (0, import_ui_grid2.findGridRowById)(buildRowsFromData(optionsRef.current.data), resolvedRowId)
|
|
618
|
+
);
|
|
619
|
+
},
|
|
620
|
+
[buildRowsFromData]
|
|
621
|
+
);
|
|
622
|
+
const expandTreeRowByRefFn = (0, import_react.useCallback)(
|
|
623
|
+
(row) => {
|
|
624
|
+
const rowId = (0, import_ui_grid2.resolveGridRowId)(optionsRef.current, row);
|
|
625
|
+
(0, import_ui_grid2.setGridTreeRowExpandedCommand)(
|
|
626
|
+
gridApiRef.current,
|
|
627
|
+
expandedTreeRowsRef.current,
|
|
628
|
+
rowId,
|
|
629
|
+
true,
|
|
630
|
+
(e) => setExpandedTreeRows(e),
|
|
631
|
+
(resolvedRowId) => (0, import_ui_grid2.findGridRowById)(buildRowsFromData(optionsRef.current.data), resolvedRowId)
|
|
632
|
+
);
|
|
633
|
+
},
|
|
634
|
+
[buildRowsFromData]
|
|
635
|
+
);
|
|
636
|
+
const collapseTreeRowByRefFn = (0, import_react.useCallback)(
|
|
637
|
+
(row) => {
|
|
638
|
+
const rowId = (0, import_ui_grid2.resolveGridRowId)(optionsRef.current, row);
|
|
639
|
+
(0, import_ui_grid2.setGridTreeRowExpandedCommand)(
|
|
640
|
+
gridApiRef.current,
|
|
641
|
+
expandedTreeRowsRef.current,
|
|
642
|
+
rowId,
|
|
643
|
+
false,
|
|
644
|
+
(e) => setExpandedTreeRows(e),
|
|
645
|
+
(resolvedRowId) => (0, import_ui_grid2.findGridRowById)(buildRowsFromData(optionsRef.current.data), resolvedRowId)
|
|
646
|
+
);
|
|
647
|
+
},
|
|
648
|
+
[buildRowsFromData]
|
|
649
|
+
);
|
|
650
|
+
const startCellEditFn = (0, import_react.useCallback)(
|
|
651
|
+
(row, column, triggerEvent, initialValue) => {
|
|
652
|
+
const currentValue = (0, import_ui_grid2.getCellValue)(row.entity, column);
|
|
653
|
+
const focusToken = ++editorFocusTokenRef.current;
|
|
654
|
+
const ec = (0, import_ui_grid2.beginGridCellEditCommand)(
|
|
655
|
+
gridApiRef.current,
|
|
656
|
+
{
|
|
657
|
+
setFocusedCell: (fc) => setFocusedCell(fc),
|
|
658
|
+
setEditingCell: (ec2) => setEditingCell(ec2),
|
|
659
|
+
setEditingValue: (ev) => setEditingValue(ev)
|
|
660
|
+
},
|
|
661
|
+
row,
|
|
662
|
+
column,
|
|
663
|
+
currentValue,
|
|
664
|
+
triggerEvent,
|
|
665
|
+
initialValue
|
|
666
|
+
);
|
|
667
|
+
if (ec) {
|
|
668
|
+
queueMicrotask(() => focusEditorInput(focusToken));
|
|
1067
669
|
}
|
|
1068
|
-
}
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
670
|
+
},
|
|
671
|
+
[focusEditorInput]
|
|
672
|
+
);
|
|
673
|
+
const commitCellEditFn = (0, import_react.useCallback)(
|
|
674
|
+
(direction, restoreFocus = true) => {
|
|
675
|
+
const result = (0, import_ui_grid2.commitGridCellEditCommand)(gridApiRef.current, {
|
|
676
|
+
getEditingCell: () => editingCellRef.current,
|
|
677
|
+
getEditingValue: () => editingValueRef.current,
|
|
678
|
+
setEditingCell: (ec) => setEditingCell(ec),
|
|
679
|
+
setEditingValue: (ev) => setEditingValue(ev),
|
|
680
|
+
findRowById: (rowId) => (0, import_ui_grid2.findGridRowById)(buildRowsFromData(optionsRef.current.data), rowId),
|
|
681
|
+
findColumnByName: (columnName) => visibleColumnsRef.current.find((c) => c.name === columnName),
|
|
682
|
+
parseEditedValue: (column, value, oldValue) => (0, import_ui_grid2.parseGridEditedValue)(column, value, oldValue),
|
|
683
|
+
setCellValue: (rowEntity, column, value) => {
|
|
684
|
+
const fieldPath = column.editModelField ?? column.field ?? column.name;
|
|
685
|
+
(0, import_ui_grid2.setPathValue)(rowEntity, fieldPath, value);
|
|
686
|
+
}
|
|
687
|
+
});
|
|
688
|
+
if (!result.committed || !result.row || !result.column || !result.focusTarget) return;
|
|
689
|
+
editorFocusTokenRef.current += 1;
|
|
690
|
+
if (direction) {
|
|
691
|
+
const moved = moveFocusFn(result.row, result.column, direction);
|
|
692
|
+
if (!moved) focusRenderedCell(result.focusTarget);
|
|
693
|
+
} else if (restoreFocus) {
|
|
694
|
+
focusRenderedCell(result.focusTarget);
|
|
695
|
+
}
|
|
696
|
+
},
|
|
697
|
+
[buildRowsFromData, focusRenderedCell]
|
|
698
|
+
);
|
|
1078
699
|
const cancelCellEditFn = (0, import_react.useCallback)(() => {
|
|
1079
700
|
const hadEditingCell = editingCellRef.current !== null;
|
|
1080
|
-
const result = cancelGridCellEditCommand(gridApiRef.current, {
|
|
701
|
+
const result = (0, import_ui_grid2.cancelGridCellEditCommand)(gridApiRef.current, {
|
|
1081
702
|
getEditingCell: () => editingCellRef.current,
|
|
1082
703
|
setEditingCell: (ec) => setEditingCell(ec),
|
|
1083
704
|
setEditingValue: (ev) => setEditingValue(ev),
|
|
1084
|
-
findRowById: (rowId) => (0,
|
|
705
|
+
findRowById: (rowId) => (0, import_ui_grid2.findGridRowById)(buildRowsFromData(optionsRef.current.data), rowId),
|
|
1085
706
|
findColumnByName: (columnName) => visibleColumnsRef.current.find((c) => c.name === columnName)
|
|
1086
707
|
});
|
|
1087
708
|
if (!hadEditingCell) return;
|
|
1088
709
|
editorFocusTokenRef.current += 1;
|
|
1089
710
|
if (result.focusTarget) focusRenderedCell(result.focusTarget);
|
|
1090
711
|
}, [buildRowsFromData, focusRenderedCell]);
|
|
1091
|
-
const moveFocusFn = (0, import_react.useCallback)(
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
712
|
+
const moveFocusFn = (0, import_react.useCallback)(
|
|
713
|
+
(row, column, direction, triggerEvent) => {
|
|
714
|
+
const nextCell = (0, import_ui_grid2.findNextGridCell)({
|
|
715
|
+
rows: pipelineRef.current.visibleRows,
|
|
716
|
+
columns: visibleColumnsRef.current,
|
|
717
|
+
rowId: row.id,
|
|
718
|
+
columnName: column.name,
|
|
719
|
+
direction
|
|
720
|
+
});
|
|
721
|
+
if (!nextCell) return false;
|
|
722
|
+
setFocusedCell({ rowId: nextCell.row.id, columnName: nextCell.column.name });
|
|
723
|
+
focusRenderedCell({ rowId: nextCell.row.id, columnName: nextCell.column.name });
|
|
724
|
+
if (shouldEditOnFocusFn(nextCell.column) && isCellEditable(nextCell.row, nextCell.column, triggerEvent)) {
|
|
725
|
+
startCellEditFn(nextCell.row, nextCell.column, triggerEvent);
|
|
726
|
+
}
|
|
727
|
+
return true;
|
|
728
|
+
},
|
|
729
|
+
[focusRenderedCell, isCellEditable, shouldEditOnFocusFn, startCellEditFn]
|
|
730
|
+
);
|
|
1107
731
|
const runBenchmarkFn = (0, import_react.useCallback)((iterations) => {
|
|
1108
|
-
const safeIterations =
|
|
732
|
+
const safeIterations = resolveBenchmarkIterations(
|
|
733
|
+
iterations,
|
|
734
|
+
optionsRef.current.benchmark?.iterations
|
|
735
|
+
);
|
|
1109
736
|
const startedAt = performance.now();
|
|
1110
|
-
let lastResult =
|
|
737
|
+
let lastResult = import_ui_grid2.defaultGridEngine.buildPipeline({
|
|
1111
738
|
options: optionsRef.current,
|
|
1112
739
|
columns: visibleColumnsRef.current,
|
|
1113
740
|
activeFilters: activeFiltersRef.current,
|
|
@@ -1122,7 +749,7 @@ function useGridState(options, onRegisterApi) {
|
|
|
1122
749
|
rowSize: optionsRef.current.rowHeight ?? 44
|
|
1123
750
|
});
|
|
1124
751
|
for (let i = 1; i < safeIterations; i++) {
|
|
1125
|
-
lastResult =
|
|
752
|
+
lastResult = import_ui_grid2.defaultGridEngine.buildPipeline({
|
|
1126
753
|
options: optionsRef.current,
|
|
1127
754
|
columns: visibleColumnsRef.current,
|
|
1128
755
|
activeFilters: activeFiltersRef.current,
|
|
@@ -1146,14 +773,14 @@ function useGridState(options, onRegisterApi) {
|
|
|
1146
773
|
renderedItems: lastResult.displayItems.length
|
|
1147
774
|
};
|
|
1148
775
|
setBenchmarkResult(result);
|
|
1149
|
-
raiseGridBenchmarkComplete(gridApiRef.current, result);
|
|
776
|
+
(0, import_ui_grid2.raiseGridBenchmarkComplete)(gridApiRef.current, result);
|
|
1150
777
|
return result;
|
|
1151
778
|
}, []);
|
|
1152
779
|
const exportCsvFn = (0, import_react.useCallback)(() => {
|
|
1153
|
-
if (!
|
|
780
|
+
if (!import_ui_grid2.FEATURE_CSV_EXPORT) return;
|
|
1154
781
|
const columns = visibleColumnsRef.current;
|
|
1155
|
-
const csv = (0,
|
|
1156
|
-
downloadGridCsvFile(csv, `${(0,
|
|
782
|
+
const csv = (0, import_ui_grid2.exportCsvRows)(columns, pipelineRef.current.visibleRows);
|
|
783
|
+
(0, import_ui_grid2.downloadGridCsvFile)(csv, `${(0, import_ui_grid2.sanitizeDownloadFilename)(optionsRef.current.id)}.csv`);
|
|
1157
784
|
}, []);
|
|
1158
785
|
(0, import_react.useEffect)(() => {
|
|
1159
786
|
if (initializedGridIdRef.current === options.id) return;
|
|
@@ -1168,8 +795,9 @@ function useGridState(options, onRegisterApi) {
|
|
|
1168
795
|
setExpandedTreeRows({});
|
|
1169
796
|
setColumnOrder(options.columnDefs.map((column) => column.name));
|
|
1170
797
|
setGroupByColumns(options.grouping?.groupBy ?? []);
|
|
798
|
+
setPinnedColumns((0, import_ui_grid2.buildInitialPinnedState)(options.columnDefs));
|
|
1171
799
|
setCurrentPage(options.paginationCurrentPage ?? 1);
|
|
1172
|
-
setPageSize((0,
|
|
800
|
+
setPageSize((0, import_ui_grid2.getEffectivePageSize)(options, 0, options.data.length));
|
|
1173
801
|
setInfiniteScrollState({
|
|
1174
802
|
scrollUp: options.infiniteScrollUp === true,
|
|
1175
803
|
scrollDown: options.infiniteScrollDown !== false,
|
|
@@ -1181,27 +809,34 @@ function useGridState(options, onRegisterApi) {
|
|
|
1181
809
|
);
|
|
1182
810
|
setSortState({
|
|
1183
811
|
columnName: initialSort?.name ?? null,
|
|
1184
|
-
direction: initialSort?.sort?.direction ??
|
|
812
|
+
direction: initialSort?.sort?.direction ?? import_ui_grid2.SORT_DIRECTIONS.none
|
|
1185
813
|
});
|
|
1186
814
|
onRegisterApi?.(gridApi);
|
|
1187
|
-
raiseGridRenderingComplete(gridApi);
|
|
815
|
+
(0, import_ui_grid2.raiseGridRenderingComplete)(gridApi);
|
|
1188
816
|
}, [options.id]);
|
|
1189
817
|
(0, import_react.useEffect)(() => {
|
|
1190
|
-
raiseGridRowsRendered(gridApi, pipeline.visibleRows);
|
|
1191
|
-
raiseGridRowsVisibleChanged(gridApi, pipeline.visibleRows);
|
|
818
|
+
(0, import_ui_grid2.raiseGridRowsRendered)(gridApi, pipeline.visibleRows);
|
|
819
|
+
(0, import_ui_grid2.raiseGridRowsVisibleChanged)(gridApi, pipeline.visibleRows);
|
|
1192
820
|
const newHeight = pipeline.displayItems.length * rowSize;
|
|
1193
821
|
if (newHeight !== lastCanvasHeightRef.current) {
|
|
1194
|
-
raiseGridCanvasHeightChanged(gridApi, lastCanvasHeightRef.current, newHeight);
|
|
822
|
+
(0, import_ui_grid2.raiseGridCanvasHeightChanged)(gridApi, lastCanvasHeightRef.current, newHeight);
|
|
1195
823
|
lastCanvasHeightRef.current = newHeight;
|
|
1196
824
|
}
|
|
1197
825
|
}, [pipeline, gridApi, rowSize]);
|
|
1198
826
|
(0, import_react.useEffect)(() => {
|
|
1199
|
-
if (!
|
|
827
|
+
if (!import_ui_grid2.FEATURE_AUTO_RESIZE || !options.enableAutoResize) return;
|
|
1200
828
|
const container = gridContainerRef.current;
|
|
1201
829
|
if (!container) return;
|
|
1202
|
-
const observer = observeGridHostSize(container, ({ height: nextHeight, width: nextWidth }) => {
|
|
1203
|
-
if (nextHeight === lastGridHeightRef.current && nextWidth === lastGridWidthRef.current)
|
|
1204
|
-
|
|
830
|
+
const observer = (0, import_ui_grid2.observeGridHostSize)(container, ({ height: nextHeight, width: nextWidth }) => {
|
|
831
|
+
if (nextHeight === lastGridHeightRef.current && nextWidth === lastGridWidthRef.current)
|
|
832
|
+
return;
|
|
833
|
+
(0, import_ui_grid2.raiseGridDimensionChanged)(
|
|
834
|
+
gridApi,
|
|
835
|
+
lastGridHeightRef.current,
|
|
836
|
+
lastGridWidthRef.current,
|
|
837
|
+
nextHeight,
|
|
838
|
+
nextWidth
|
|
839
|
+
);
|
|
1205
840
|
lastGridHeightRef.current = nextHeight;
|
|
1206
841
|
lastGridWidthRef.current = nextWidth;
|
|
1207
842
|
if (!options.viewportHeight && nextHeight > 0) {
|
|
@@ -1219,116 +854,157 @@ function useGridState(options, onRegisterApi) {
|
|
|
1219
854
|
const paginationCurrentPage = getCurrentPageValueFn();
|
|
1220
855
|
const paginationTotalPages = getTotalPagesValueFn();
|
|
1221
856
|
const paginationSelectedPageSize = effectivePageSizeFn(pipeline.totalItems);
|
|
1222
|
-
const viewportHeightPx =
|
|
1223
|
-
const headerLabelFn = (0, import_react.useCallback)((column) => (0,
|
|
1224
|
-
const isGroupItemFn = (0, import_react.useCallback)(
|
|
1225
|
-
|
|
857
|
+
const viewportHeightPx = computeViewportHeightPx(options.viewportHeight, autoViewportHeight);
|
|
858
|
+
const headerLabelFn = (0, import_react.useCallback)((column) => (0, import_ui_grid2.headerLabel)(column), []);
|
|
859
|
+
const isGroupItemFn = (0, import_react.useCallback)(
|
|
860
|
+
(item) => item.kind === "group",
|
|
861
|
+
[]
|
|
862
|
+
);
|
|
863
|
+
const isExpandableItemFn = (0, import_react.useCallback)(
|
|
864
|
+
(item) => item.kind === "expandable",
|
|
865
|
+
[]
|
|
866
|
+
);
|
|
1226
867
|
const isRowItemFn = (0, import_react.useCallback)((item) => item.kind === "row", []);
|
|
1227
|
-
const isOddStripedRowFn = (0, import_react.useCallback)(
|
|
868
|
+
const isOddStripedRowFn = (0, import_react.useCallback)(
|
|
869
|
+
(item) => item.kind === "row" && item.visibleIndex % 2 === 0,
|
|
870
|
+
[]
|
|
871
|
+
);
|
|
1228
872
|
const sortDirectionFn = (0, import_react.useCallback)((column) => {
|
|
1229
|
-
return sortStateRef.current.columnName === column.name ? sortStateRef.current.direction :
|
|
873
|
+
return sortStateRef.current.columnName === column.name ? sortStateRef.current.direction : import_ui_grid2.SORT_DIRECTIONS.none;
|
|
1230
874
|
}, []);
|
|
1231
|
-
const sortButtonLabelFn = (0, import_react.useCallback)(
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
const
|
|
1238
|
-
|
|
1239
|
-
|
|
875
|
+
const sortButtonLabelFn = (0, import_react.useCallback)(
|
|
876
|
+
(column) => {
|
|
877
|
+
return (0, import_ui_grid2.gridSortButtonLabel)(sortDirectionFn(column), labels);
|
|
878
|
+
},
|
|
879
|
+
[labels, sortDirectionFn]
|
|
880
|
+
);
|
|
881
|
+
const sortAriaSortFn = (0, import_react.useCallback)(
|
|
882
|
+
(column) => {
|
|
883
|
+
return (0, import_ui_grid2.gridSortAriaSort)(sortDirectionFn(column));
|
|
884
|
+
},
|
|
885
|
+
[sortDirectionFn]
|
|
886
|
+
);
|
|
887
|
+
const groupingButtonLabelFn = (0, import_react.useCallback)(
|
|
888
|
+
(column) => {
|
|
889
|
+
return (0, import_ui_grid2.gridGroupingButtonLabel)(
|
|
890
|
+
(0, import_ui_grid2.isGridColumnGrouped)(groupByColumnsRef.current, column),
|
|
891
|
+
labels
|
|
892
|
+
);
|
|
893
|
+
},
|
|
894
|
+
[labels]
|
|
895
|
+
);
|
|
1240
896
|
const filterValueFn = (0, import_react.useCallback)((columnName) => {
|
|
1241
897
|
return activeFiltersRef.current[columnName] ?? "";
|
|
1242
898
|
}, []);
|
|
1243
|
-
const filterPlaceholderFn = (0, import_react.useCallback)(
|
|
1244
|
-
|
|
1245
|
-
|
|
899
|
+
const filterPlaceholderFn = (0, import_react.useCallback)(
|
|
900
|
+
(column) => {
|
|
901
|
+
return (0, import_ui_grid2.gridFilterPlaceholder)((0, import_ui_grid2.isGridColumnFilterable)(optionsRef.current, column), labels);
|
|
902
|
+
},
|
|
903
|
+
[labels]
|
|
904
|
+
);
|
|
1246
905
|
const isFilterInputDisabledFn = (0, import_react.useCallback)((column) => {
|
|
1247
|
-
return !(0,
|
|
906
|
+
return !(0, import_ui_grid2.isGridColumnFilterable)(optionsRef.current, column);
|
|
1248
907
|
}, []);
|
|
1249
|
-
const groupDisclosureLabelFn = (0, import_react.useCallback)(
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
const
|
|
1256
|
-
|
|
1257
|
-
|
|
908
|
+
const groupDisclosureLabelFn = (0, import_react.useCallback)(
|
|
909
|
+
(item) => {
|
|
910
|
+
return (0, import_ui_grid2.gridGroupDisclosureLabel)(item.collapsed, labels);
|
|
911
|
+
},
|
|
912
|
+
[labels]
|
|
913
|
+
);
|
|
914
|
+
const cellContextFn = (0, import_react.useCallback)(
|
|
915
|
+
(row, column) => {
|
|
916
|
+
return (0, import_ui_grid2.buildGridCellContext)(row, column);
|
|
917
|
+
},
|
|
918
|
+
[]
|
|
919
|
+
);
|
|
920
|
+
const displayValueFn = (0, import_react.useCallback)(
|
|
921
|
+
(row, column) => {
|
|
922
|
+
return (0, import_ui_grid2.formatGridCellDisplayValue)(cellContextFn(row, column));
|
|
923
|
+
},
|
|
924
|
+
[cellContextFn]
|
|
925
|
+
);
|
|
1258
926
|
const isFocusedCellFn = (0, import_react.useCallback)((row, column) => {
|
|
1259
|
-
return (0,
|
|
927
|
+
return (0, import_ui_grid2.isGridCellPosition)(focusedCellRef.current, row.id, column.name);
|
|
1260
928
|
}, []);
|
|
1261
929
|
const isEditingCellFn = (0, import_react.useCallback)((row, column) => {
|
|
1262
|
-
return (0,
|
|
930
|
+
return (0, import_ui_grid2.isGridCellPosition)(editingCellRef.current, row.id, column.name);
|
|
1263
931
|
}, []);
|
|
1264
932
|
const editorInputTypeFn = (0, import_react.useCallback)((column) => {
|
|
1265
|
-
return (0,
|
|
1266
|
-
}, []);
|
|
1267
|
-
const expandedContextFn = (0, import_react.useCallback)((row) => {
|
|
1268
|
-
return {
|
|
1269
|
-
$implicit: row.entity,
|
|
1270
|
-
row: row.entity,
|
|
1271
|
-
rowIndex: row.index,
|
|
1272
|
-
expanded: true,
|
|
1273
|
-
...optionsRef.current.expandableRowScope ?? {}
|
|
1274
|
-
};
|
|
933
|
+
return (0, import_ui_grid2.gridEditorInputType)(column);
|
|
1275
934
|
}, []);
|
|
1276
|
-
const
|
|
935
|
+
const expandedContextFn = (0, import_react.useCallback)(
|
|
936
|
+
(row) => {
|
|
937
|
+
return {
|
|
938
|
+
$implicit: row.entity,
|
|
939
|
+
row: row.entity,
|
|
940
|
+
rowIndex: row.index,
|
|
941
|
+
expanded: true,
|
|
942
|
+
...optionsRef.current.expandableRowScope ?? {}
|
|
943
|
+
};
|
|
944
|
+
},
|
|
945
|
+
[]
|
|
946
|
+
);
|
|
947
|
+
const columnWidthFn = (0, import_react.useCallback)((column) => (0, import_ui_grid2.gridColumnWidth)(column), []);
|
|
1277
948
|
const isColumnSortableFn = (0, import_react.useCallback)((column) => {
|
|
1278
|
-
return (0,
|
|
949
|
+
return (0, import_ui_grid2.isGridColumnSortable)(optionsRef.current, column);
|
|
1279
950
|
}, []);
|
|
1280
951
|
const isColumnFilterableFn = (0, import_react.useCallback)((column) => {
|
|
1281
|
-
return (0,
|
|
952
|
+
return (0, import_ui_grid2.isGridColumnFilterable)(optionsRef.current, column);
|
|
1282
953
|
}, []);
|
|
1283
954
|
const cellIndentFn = (0, import_react.useCallback)((row, column) => {
|
|
1284
|
-
return (0,
|
|
955
|
+
return (0, import_ui_grid2.gridCellIndent)(optionsRef.current, visibleColumnsRef.current, row, column);
|
|
1285
956
|
}, []);
|
|
1286
|
-
const treeToggleLabelFn = (0, import_react.useCallback)(
|
|
1287
|
-
|
|
1288
|
-
|
|
957
|
+
const treeToggleLabelFn = (0, import_react.useCallback)(
|
|
958
|
+
(row) => {
|
|
959
|
+
return (0, import_ui_grid2.gridTreeToggleLabelForRow)(expandedTreeRowsRef.current, row, labels);
|
|
960
|
+
},
|
|
961
|
+
[labels]
|
|
962
|
+
);
|
|
1289
963
|
const isTreeRowExpandedFn = (0, import_react.useCallback)((row) => {
|
|
1290
|
-
return (0,
|
|
964
|
+
return (0, import_ui_grid2.isGridTreeRowExpanded)(expandedTreeRowsRef.current, row);
|
|
1291
965
|
}, []);
|
|
1292
|
-
const expandToggleLabelFn = (0, import_react.useCallback)(
|
|
1293
|
-
|
|
1294
|
-
|
|
966
|
+
const expandToggleLabelFn = (0, import_react.useCallback)(
|
|
967
|
+
(row) => {
|
|
968
|
+
return (0, import_ui_grid2.gridExpandToggleLabelForRow)(row, labels);
|
|
969
|
+
},
|
|
970
|
+
[labels]
|
|
971
|
+
);
|
|
1295
972
|
const isGroupedFn = (0, import_react.useCallback)((column) => {
|
|
1296
|
-
return (0,
|
|
973
|
+
return (0, import_ui_grid2.isGridColumnGrouped)(groupByColumnsRef.current, column);
|
|
1297
974
|
}, []);
|
|
1298
975
|
const showTreeToggleFn = (0, import_react.useCallback)((row, column) => {
|
|
1299
|
-
return (0,
|
|
976
|
+
return (0, import_ui_grid2.shouldShowGridTreeToggle)(optionsRef.current, visibleColumnsRef.current, row, column);
|
|
1300
977
|
}, []);
|
|
1301
978
|
const showExpandToggleFn = (0, import_react.useCallback)((row, column) => {
|
|
1302
|
-
return (0,
|
|
979
|
+
return (0, import_ui_grid2.shouldShowGridExpandToggle)(optionsRef.current, visibleColumnsRef.current, column);
|
|
1303
980
|
}, []);
|
|
1304
981
|
const showPaginationControlsFn = (0, import_react.useCallback)(() => {
|
|
1305
|
-
return
|
|
982
|
+
return import_ui_grid2.FEATURE_PAGINATION && (0, import_ui_grid2.shouldShowGridPaginationControls)(optionsRef.current);
|
|
1306
983
|
}, []);
|
|
1307
984
|
const paginationSummaryFn = (0, import_react.useCallback)(() => {
|
|
1308
985
|
const ti = pipelineRef.current.totalItems;
|
|
1309
|
-
|
|
1310
|
-
return `${getFirstRowIndexValueFn(ti) + 1}-${getLastRowIndexValueFn(ti) + 1} of ${ti}`;
|
|
986
|
+
return formatPaginationSummary(ti, getFirstRowIndexValueFn(ti), getLastRowIndexValueFn(ti));
|
|
1311
987
|
}, [getFirstRowIndexValueFn, getLastRowIndexValueFn]);
|
|
1312
988
|
const pageSizeOptionsFn = (0, import_react.useCallback)(() => {
|
|
1313
989
|
return optionsRef.current.paginationPageSizes ?? [];
|
|
1314
990
|
}, []);
|
|
1315
991
|
const isGroupingEnabledFn = (0, import_react.useCallback)(() => {
|
|
1316
|
-
return
|
|
992
|
+
return import_ui_grid2.FEATURE_GROUPING && (0, import_ui_grid2.isGridGroupingEnabled)(optionsRef.current);
|
|
1317
993
|
}, []);
|
|
1318
994
|
const isFilteringEnabledFn = (0, import_react.useCallback)(() => {
|
|
1319
|
-
return
|
|
995
|
+
return import_ui_grid2.FEATURE_FILTERING && (0, import_ui_grid2.isGridFilteringEnabled)(optionsRef.current);
|
|
1320
996
|
}, []);
|
|
1321
997
|
const toggleSortFn = (0, import_react.useCallback)((column) => {
|
|
1322
|
-
if (!
|
|
1323
|
-
const currentDirection = sortStateRef.current.columnName === column.name ? sortStateRef.current.direction :
|
|
1324
|
-
const nextDirection = currentDirection ===
|
|
1325
|
-
applyGridSortStateCommand(gridApiRef.current, (state) => setSortState(state), {
|
|
1326
|
-
columnName: nextDirection ===
|
|
998
|
+
if (!import_ui_grid2.FEATURE_SORTING || !(0, import_ui_grid2.isGridColumnSortable)(optionsRef.current, column)) return;
|
|
999
|
+
const currentDirection = sortStateRef.current.columnName === column.name ? sortStateRef.current.direction : import_ui_grid2.SORT_DIRECTIONS.none;
|
|
1000
|
+
const nextDirection = currentDirection === import_ui_grid2.SORT_DIRECTIONS.none ? import_ui_grid2.SORT_DIRECTIONS.asc : currentDirection === import_ui_grid2.SORT_DIRECTIONS.asc ? import_ui_grid2.SORT_DIRECTIONS.desc : import_ui_grid2.SORT_DIRECTIONS.none;
|
|
1001
|
+
(0, import_ui_grid2.applyGridSortStateCommand)(gridApiRef.current, (state) => setSortState(state), {
|
|
1002
|
+
columnName: nextDirection === import_ui_grid2.SORT_DIRECTIONS.none ? null : column.name,
|
|
1327
1003
|
direction: nextDirection
|
|
1328
1004
|
});
|
|
1329
1005
|
}, []);
|
|
1330
1006
|
const updateFilterFn = (0, import_react.useCallback)((columnName, value) => {
|
|
1331
|
-
updateGridFilterCommand(
|
|
1007
|
+
(0, import_ui_grid2.updateGridFilterCommand)(
|
|
1332
1008
|
gridApiRef.current,
|
|
1333
1009
|
(updater) => setActiveFilters((current) => updater(current)),
|
|
1334
1010
|
() => activeFiltersRef.current,
|
|
@@ -1337,11 +1013,11 @@ function useGridState(options, onRegisterApi) {
|
|
|
1337
1013
|
);
|
|
1338
1014
|
}, []);
|
|
1339
1015
|
const clearAllFiltersFn = (0, import_react.useCallback)(() => {
|
|
1340
|
-
clearGridFiltersCommand(gridApiRef.current, (filters) => setActiveFilters(filters));
|
|
1016
|
+
(0, import_ui_grid2.clearGridFiltersCommand)(gridApiRef.current, (filters) => setActiveFilters(filters));
|
|
1341
1017
|
}, []);
|
|
1342
1018
|
const toggleGroupingFn = (0, import_react.useCallback)((column, event) => {
|
|
1343
1019
|
event?.stopPropagation();
|
|
1344
|
-
if (!(
|
|
1020
|
+
if (!(import_ui_grid2.FEATURE_GROUPING && (0, import_ui_grid2.isGridGroupingEnabled)(optionsRef.current))) return;
|
|
1345
1021
|
const current = groupByColumnsRef.current;
|
|
1346
1022
|
const next = current.includes(column.name) ? current.filter((n) => n !== column.name) : [...current, column.name];
|
|
1347
1023
|
groupByColumnsRef.current = next;
|
|
@@ -1354,112 +1030,134 @@ function useGridState(options, onRegisterApi) {
|
|
|
1354
1030
|
[item.id]: !current[item.id]
|
|
1355
1031
|
}));
|
|
1356
1032
|
}, []);
|
|
1357
|
-
const focusCellFn = (0, import_react.useCallback)(
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1033
|
+
const focusCellFn = (0, import_react.useCallback)(
|
|
1034
|
+
(row, column, triggerEvent) => {
|
|
1035
|
+
const nextFocusResult = (0, import_ui_grid2.buildGridFocusCellResult)({
|
|
1036
|
+
currentFocusedCell: focusedCellRef.current,
|
|
1037
|
+
currentEditingCell: editingCellRef.current,
|
|
1038
|
+
rowId: row.id,
|
|
1039
|
+
columnName: column.name,
|
|
1040
|
+
shouldEditOnFocus: shouldEditOnFocusFn(column),
|
|
1041
|
+
isCellEditable: isCellEditable(row, column, triggerEvent)
|
|
1042
|
+
});
|
|
1043
|
+
setFocusedCell(nextFocusResult.focusedCell);
|
|
1044
|
+
if (nextFocusResult.shouldBeginEdit) {
|
|
1045
|
+
startCellEditFn(row, column, triggerEvent);
|
|
1046
|
+
}
|
|
1047
|
+
},
|
|
1048
|
+
[isCellEditable, shouldEditOnFocusFn, startCellEditFn]
|
|
1049
|
+
);
|
|
1050
|
+
const handleCellKeyDownFn = (0, import_react.useCallback)(
|
|
1051
|
+
(row, column, event) => {
|
|
1052
|
+
focusCellFn(row, column, event.nativeEvent);
|
|
1053
|
+
switch (event.key) {
|
|
1054
|
+
case "ArrowLeft":
|
|
1055
|
+
event.preventDefault();
|
|
1056
|
+
moveFocusFn(row, column, "left", event.nativeEvent);
|
|
1057
|
+
return;
|
|
1058
|
+
case "ArrowRight":
|
|
1059
|
+
event.preventDefault();
|
|
1060
|
+
moveFocusFn(row, column, "right", event.nativeEvent);
|
|
1061
|
+
return;
|
|
1062
|
+
case "ArrowUp":
|
|
1063
|
+
event.preventDefault();
|
|
1064
|
+
moveFocusFn(row, column, "up", event.nativeEvent);
|
|
1065
|
+
return;
|
|
1066
|
+
case "ArrowDown":
|
|
1067
|
+
event.preventDefault();
|
|
1068
|
+
moveFocusFn(row, column, "down", event.nativeEvent);
|
|
1069
|
+
return;
|
|
1070
|
+
case "Tab":
|
|
1071
|
+
event.preventDefault();
|
|
1072
|
+
moveFocusFn(row, column, event.shiftKey ? "left" : "right", event.nativeEvent);
|
|
1073
|
+
return;
|
|
1074
|
+
case "Enter":
|
|
1075
|
+
event.preventDefault();
|
|
1076
|
+
moveFocusFn(row, column, event.shiftKey ? "up" : "down", event.nativeEvent);
|
|
1077
|
+
return;
|
|
1078
|
+
case "F2":
|
|
1079
|
+
event.preventDefault();
|
|
1080
|
+
if (isCellEditable(row, column, event.nativeEvent)) {
|
|
1081
|
+
startCellEditFn(row, column, event.nativeEvent);
|
|
1082
|
+
}
|
|
1083
|
+
return;
|
|
1084
|
+
case "Backspace":
|
|
1085
|
+
case "Delete":
|
|
1086
|
+
if (isCellEditable(row, column, event.nativeEvent)) {
|
|
1087
|
+
event.preventDefault();
|
|
1088
|
+
startCellEditFn(row, column, event.nativeEvent, "");
|
|
1089
|
+
}
|
|
1090
|
+
return;
|
|
1091
|
+
default:
|
|
1092
|
+
break;
|
|
1093
|
+
}
|
|
1094
|
+
if ((0, import_ui_grid2.isPrintableGridKey)(event.key, event.ctrlKey, event.metaKey, event.altKey) && isCellEditable(row, column, event.nativeEvent)) {
|
|
1387
1095
|
event.preventDefault();
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1096
|
+
startCellEditFn(row, column, event.nativeEvent, event.key);
|
|
1097
|
+
}
|
|
1098
|
+
},
|
|
1099
|
+
[focusCellFn, moveFocusFn, isCellEditable, startCellEditFn]
|
|
1100
|
+
);
|
|
1101
|
+
const handleCellDoubleClickFn = (0, import_react.useCallback)(
|
|
1102
|
+
(row, column, event) => {
|
|
1103
|
+
focusCellFn(row, column, event.nativeEvent);
|
|
1104
|
+
if (isCellEditable(row, column, event.nativeEvent)) {
|
|
1105
|
+
startCellEditFn(row, column, event.nativeEvent);
|
|
1106
|
+
}
|
|
1107
|
+
},
|
|
1108
|
+
[focusCellFn, isCellEditable, startCellEditFn]
|
|
1109
|
+
);
|
|
1110
|
+
const updateEditingValueFn = (0, import_react.useCallback)((value) => {
|
|
1111
|
+
setEditingValue(value);
|
|
1112
|
+
}, []);
|
|
1113
|
+
const handleEditorKeyDownFn = (0, import_react.useCallback)(
|
|
1114
|
+
(event) => {
|
|
1115
|
+
if (event.key === "Escape") {
|
|
1391
1116
|
event.preventDefault();
|
|
1392
|
-
|
|
1117
|
+
cancelCellEditFn();
|
|
1393
1118
|
return;
|
|
1394
|
-
|
|
1119
|
+
}
|
|
1120
|
+
if (event.key === "Enter") {
|
|
1395
1121
|
event.preventDefault();
|
|
1396
|
-
|
|
1122
|
+
commitCellEditFn(event.shiftKey ? "up" : "down");
|
|
1397
1123
|
return;
|
|
1398
|
-
|
|
1124
|
+
}
|
|
1125
|
+
if (event.key === "Tab") {
|
|
1399
1126
|
event.preventDefault();
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1127
|
+
commitCellEditFn(event.shiftKey ? "left" : "right");
|
|
1128
|
+
}
|
|
1129
|
+
},
|
|
1130
|
+
[cancelCellEditFn, commitCellEditFn]
|
|
1131
|
+
);
|
|
1132
|
+
const handleEditorBlurFn = (0, import_react.useCallback)(
|
|
1133
|
+
(event) => {
|
|
1134
|
+
const ec = editingCellRef.current;
|
|
1135
|
+
const target = event.target;
|
|
1136
|
+
if (!ec || !target) return;
|
|
1137
|
+
if (target.dataset["rowId"] !== ec.rowId || target.dataset["colName"] !== ec.columnName)
|
|
1410
1138
|
return;
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
if (event.key === "Escape") {
|
|
1430
|
-
event.preventDefault();
|
|
1431
|
-
cancelCellEditFn();
|
|
1432
|
-
return;
|
|
1433
|
-
}
|
|
1434
|
-
if (event.key === "Enter") {
|
|
1435
|
-
event.preventDefault();
|
|
1436
|
-
commitCellEditFn(event.shiftKey ? "up" : "down");
|
|
1437
|
-
return;
|
|
1438
|
-
}
|
|
1439
|
-
if (event.key === "Tab") {
|
|
1440
|
-
event.preventDefault();
|
|
1441
|
-
commitCellEditFn(event.shiftKey ? "left" : "right");
|
|
1442
|
-
}
|
|
1443
|
-
}, [cancelCellEditFn, commitCellEditFn]);
|
|
1444
|
-
const handleEditorBlurFn = (0, import_react.useCallback)((event) => {
|
|
1445
|
-
const ec = editingCellRef.current;
|
|
1446
|
-
const target = event.target;
|
|
1447
|
-
if (!ec || !target) return;
|
|
1448
|
-
if (target.dataset["rowId"] !== ec.rowId || target.dataset["colName"] !== ec.columnName) return;
|
|
1449
|
-
commitCellEditFn(void 0, false);
|
|
1450
|
-
}, [commitCellEditFn]);
|
|
1451
|
-
const toggleRowExpansionFn = (0, import_react.useCallback)((row, event) => {
|
|
1452
|
-
event?.stopPropagation();
|
|
1453
|
-
toggleRowExpansionByRefFn(row);
|
|
1454
|
-
}, [toggleRowExpansionByRefFn]);
|
|
1455
|
-
const toggleTreeRowFn = (0, import_react.useCallback)((row, event) => {
|
|
1456
|
-
event?.stopPropagation();
|
|
1457
|
-
toggleTreeRowByRefFn(row);
|
|
1458
|
-
}, [toggleTreeRowByRefFn]);
|
|
1139
|
+
commitCellEditFn(void 0, false);
|
|
1140
|
+
},
|
|
1141
|
+
[commitCellEditFn]
|
|
1142
|
+
);
|
|
1143
|
+
const toggleRowExpansionFn = (0, import_react.useCallback)(
|
|
1144
|
+
(row, event) => {
|
|
1145
|
+
event?.stopPropagation();
|
|
1146
|
+
toggleRowExpansionByRefFn(row);
|
|
1147
|
+
},
|
|
1148
|
+
[toggleRowExpansionByRefFn]
|
|
1149
|
+
);
|
|
1150
|
+
const toggleTreeRowFn = (0, import_react.useCallback)(
|
|
1151
|
+
(row, event) => {
|
|
1152
|
+
event?.stopPropagation();
|
|
1153
|
+
toggleTreeRowByRefFn(row);
|
|
1154
|
+
},
|
|
1155
|
+
[toggleTreeRowByRefFn]
|
|
1156
|
+
);
|
|
1459
1157
|
const moveColumnFn = (0, import_react.useCallback)((fromIndex, toIndex) => {
|
|
1460
|
-
moveGridColumnCommand(
|
|
1158
|
+
(0, import_ui_grid2.moveGridColumnCommand)(
|
|
1461
1159
|
gridApiRef.current,
|
|
1462
|
-
|
|
1160
|
+
import_ui_grid2.FEATURE_COLUMN_MOVING && optionsRef.current.enableColumnMoving === true,
|
|
1463
1161
|
(updater) => setColumnOrder((current) => updater(current)),
|
|
1464
1162
|
fromIndex,
|
|
1465
1163
|
toIndex
|
|
@@ -1471,29 +1169,35 @@ function useGridState(options, onRegisterApi) {
|
|
|
1471
1169
|
const previousPageFn = (0, import_react.useCallback)(() => {
|
|
1472
1170
|
seekPageFn(getCurrentPageValueFn() - 1);
|
|
1473
1171
|
}, [seekPageFn, getCurrentPageValueFn]);
|
|
1474
|
-
const onPageSizeChangeFn = (0, import_react.useCallback)(
|
|
1475
|
-
|
|
1476
|
-
|
|
1172
|
+
const onPageSizeChangeFn = (0, import_react.useCallback)(
|
|
1173
|
+
(value) => {
|
|
1174
|
+
setPaginationPageSizeFn(Number(value));
|
|
1175
|
+
},
|
|
1176
|
+
[setPaginationPageSizeFn]
|
|
1177
|
+
);
|
|
1477
1178
|
const onViewportScrollFn = (0, import_react.useCallback)((startIndex) => {
|
|
1478
1179
|
if (!scrollingRef.current) {
|
|
1479
1180
|
scrollingRef.current = true;
|
|
1480
|
-
raiseGridScrollBegin(gridApiRef.current);
|
|
1181
|
+
(0, import_ui_grid2.raiseGridScrollBegin)(gridApiRef.current);
|
|
1481
1182
|
}
|
|
1482
1183
|
if (scrollEndHandleRef.current) {
|
|
1483
1184
|
window.clearTimeout(scrollEndHandleRef.current);
|
|
1484
1185
|
}
|
|
1485
1186
|
scrollEndHandleRef.current = window.setTimeout(() => {
|
|
1486
1187
|
scrollingRef.current = false;
|
|
1487
|
-
raiseGridScrollEnd(gridApiRef.current);
|
|
1188
|
+
(0, import_ui_grid2.raiseGridScrollEnd)(gridApiRef.current);
|
|
1488
1189
|
}, 120);
|
|
1489
|
-
const isInfiniteScrollEnabled =
|
|
1490
|
-
maybeRequestInfiniteScrollCommand(gridApiRef.current, {
|
|
1190
|
+
const isInfiniteScrollEnabled = import_ui_grid2.FEATURE_INFINITE_SCROLL && (optionsRef.current.infiniteScrollRowsFromEnd !== void 0 || optionsRef.current.infiniteScrollUp === true || optionsRef.current.infiniteScrollDown !== void 0);
|
|
1191
|
+
(0, import_ui_grid2.maybeRequestInfiniteScrollCommand)(gridApiRef.current, {
|
|
1491
1192
|
enabled: isInfiniteScrollEnabled,
|
|
1492
1193
|
virtualizationEnabled: pipelineRef.current.virtualizationEnabled,
|
|
1493
1194
|
state: infiniteScrollStateRef.current,
|
|
1494
1195
|
startIndex,
|
|
1495
1196
|
visibleRows: pipelineRef.current.visibleRows.length,
|
|
1496
|
-
viewportRows:
|
|
1197
|
+
viewportRows: computeViewportRows(
|
|
1198
|
+
optionsRef.current.viewportHeight,
|
|
1199
|
+
optionsRef.current.rowHeight
|
|
1200
|
+
),
|
|
1497
1201
|
threshold: optionsRef.current.infiniteScrollRowsFromEnd ?? 20,
|
|
1498
1202
|
setState: (state) => setInfiniteScrollState(state)
|
|
1499
1203
|
});
|
|
@@ -1562,16 +1266,16 @@ function useGridState(options, onRegisterApi) {
|
|
|
1562
1266
|
pageSizeOptions: pageSizeOptionsFn,
|
|
1563
1267
|
isCellEditable,
|
|
1564
1268
|
shouldEditOnFocus: shouldEditOnFocusFn,
|
|
1565
|
-
sortingFeature:
|
|
1566
|
-
filteringFeature:
|
|
1567
|
-
groupingFeature:
|
|
1568
|
-
paginationFeature:
|
|
1569
|
-
cellEditFeature:
|
|
1570
|
-
expandableFeature:
|
|
1571
|
-
treeViewFeature:
|
|
1572
|
-
infiniteScrollFeature:
|
|
1573
|
-
columnMovingFeature:
|
|
1574
|
-
csvExportFeature:
|
|
1269
|
+
sortingFeature: import_ui_grid2.FEATURE_SORTING,
|
|
1270
|
+
filteringFeature: import_ui_grid2.FEATURE_FILTERING,
|
|
1271
|
+
groupingFeature: import_ui_grid2.FEATURE_GROUPING,
|
|
1272
|
+
paginationFeature: import_ui_grid2.FEATURE_PAGINATION,
|
|
1273
|
+
cellEditFeature: import_ui_grid2.FEATURE_CELL_EDIT,
|
|
1274
|
+
expandableFeature: import_ui_grid2.FEATURE_EXPANDABLE,
|
|
1275
|
+
treeViewFeature: import_ui_grid2.FEATURE_TREE_VIEW,
|
|
1276
|
+
infiniteScrollFeature: import_ui_grid2.FEATURE_INFINITE_SCROLL,
|
|
1277
|
+
columnMovingFeature: import_ui_grid2.FEATURE_COLUMN_MOVING,
|
|
1278
|
+
csvExportFeature: import_ui_grid2.FEATURE_CSV_EXPORT,
|
|
1575
1279
|
isGroupingEnabled: isGroupingEnabledFn,
|
|
1576
1280
|
isFilteringEnabled: isFilteringEnabledFn,
|
|
1577
1281
|
toggleSort: toggleSortFn,
|
|
@@ -1593,30 +1297,62 @@ function useGridState(options, onRegisterApi) {
|
|
|
1593
1297
|
onPageSizeChange: onPageSizeChangeFn,
|
|
1594
1298
|
runBenchmark: runBenchmarkFn,
|
|
1595
1299
|
exportCsv: exportCsvFn,
|
|
1596
|
-
onViewportScroll: onViewportScrollFn
|
|
1300
|
+
onViewportScroll: onViewportScrollFn,
|
|
1301
|
+
// Pinning
|
|
1302
|
+
isPinned: isPinnedFn,
|
|
1303
|
+
pinnedOffset: pinnedOffsetFn,
|
|
1304
|
+
isPinningEnabled: isPinningEnabledFn,
|
|
1305
|
+
isColumnPinnable: isColumnPinnableFn,
|
|
1306
|
+
togglePin: togglePinFn,
|
|
1307
|
+
pinningFeature: import_ui_grid2.FEATURE_PINNING
|
|
1597
1308
|
};
|
|
1598
1309
|
}
|
|
1599
1310
|
|
|
1600
1311
|
// src/useVirtualScroll.ts
|
|
1601
1312
|
var import_react2 = require("react");
|
|
1313
|
+
|
|
1314
|
+
// src/virtualScrollMath.ts
|
|
1315
|
+
function calculateVirtualWindow(request) {
|
|
1316
|
+
const overscan = request.overscan ?? 3;
|
|
1317
|
+
if (request.itemCount <= 0 || request.itemSize <= 0) {
|
|
1318
|
+
return {
|
|
1319
|
+
visibleRange: { start: 0, end: 0 },
|
|
1320
|
+
totalHeight: Math.max(0, request.itemCount) * Math.max(0, request.itemSize),
|
|
1321
|
+
offsetY: 0
|
|
1322
|
+
};
|
|
1323
|
+
}
|
|
1324
|
+
const rawStart = Math.floor(request.scrollTop / request.itemSize) - overscan;
|
|
1325
|
+
const start = Math.max(0, rawStart);
|
|
1326
|
+
const rawEnd = rawStart + Math.ceil(request.viewportHeight / request.itemSize) + 2 * overscan;
|
|
1327
|
+
const end = Math.min(request.itemCount, rawEnd);
|
|
1328
|
+
return {
|
|
1329
|
+
visibleRange: { start, end },
|
|
1330
|
+
totalHeight: request.itemCount * request.itemSize,
|
|
1331
|
+
offsetY: start * request.itemSize
|
|
1332
|
+
};
|
|
1333
|
+
}
|
|
1334
|
+
|
|
1335
|
+
// src/useVirtualScroll.ts
|
|
1602
1336
|
function useVirtualScroll(options) {
|
|
1603
1337
|
const { itemCount, itemSize, viewportHeight, overscan = 3 } = options;
|
|
1604
1338
|
const [scrollTop, setScrollTop] = (0, import_react2.useState)(0);
|
|
1605
1339
|
const viewportRef = (0, import_react2.useRef)(null);
|
|
1606
|
-
const
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1340
|
+
const virtualWindow = calculateVirtualWindow({
|
|
1341
|
+
itemCount,
|
|
1342
|
+
itemSize,
|
|
1343
|
+
viewportHeight,
|
|
1344
|
+
overscan,
|
|
1345
|
+
scrollTop
|
|
1346
|
+
});
|
|
1612
1347
|
const onScroll = (0, import_react2.useCallback)((event) => {
|
|
1613
1348
|
setScrollTop(event.currentTarget.scrollTop);
|
|
1614
1349
|
}, []);
|
|
1615
1350
|
return {
|
|
1616
|
-
visibleRange:
|
|
1617
|
-
totalHeight,
|
|
1618
|
-
offsetY,
|
|
1351
|
+
visibleRange: virtualWindow.visibleRange,
|
|
1352
|
+
totalHeight: virtualWindow.totalHeight,
|
|
1353
|
+
offsetY: virtualWindow.offsetY,
|
|
1619
1354
|
onScroll,
|
|
1355
|
+
setScrollTop,
|
|
1620
1356
|
viewportRef,
|
|
1621
1357
|
scrollTop
|
|
1622
1358
|
};
|
|
@@ -1624,7 +1360,13 @@ function useVirtualScroll(options) {
|
|
|
1624
1360
|
|
|
1625
1361
|
// src/UiGrid.tsx
|
|
1626
1362
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
1627
|
-
function UiGrid({
|
|
1363
|
+
function UiGrid({
|
|
1364
|
+
options,
|
|
1365
|
+
onRegisterApi,
|
|
1366
|
+
cellRenderer,
|
|
1367
|
+
expandableRenderer,
|
|
1368
|
+
className
|
|
1369
|
+
}) {
|
|
1628
1370
|
const state = useGridState(options, onRegisterApi);
|
|
1629
1371
|
const {
|
|
1630
1372
|
pipeline,
|
|
@@ -1659,10 +1401,82 @@ function UiGrid({ options, onRegisterApi, cellRenderer, expandableRenderer, clas
|
|
|
1659
1401
|
viewportHeight: options.viewportHeight ?? 560,
|
|
1660
1402
|
overscan: 3
|
|
1661
1403
|
});
|
|
1404
|
+
const headerGridRef = import_react3.default.useRef(null);
|
|
1405
|
+
const filterGridRef = import_react3.default.useRef(null);
|
|
1406
|
+
const [openPinMenuColumn, setOpenPinMenuColumn] = import_react3.default.useState(null);
|
|
1407
|
+
const [headerStickyHeight, setHeaderStickyHeight] = import_react3.default.useState(0);
|
|
1408
|
+
const [filterStickyHeight, setFilterStickyHeight] = import_react3.default.useState(0);
|
|
1409
|
+
const stickyChromeHeight = headerStickyHeight + filterStickyHeight;
|
|
1410
|
+
const scrollContainerHeight = `${(options.viewportHeight ?? 560) + stickyChromeHeight}px`;
|
|
1411
|
+
const eventPathIncludesClass = import_react3.default.useCallback((event, className2) => {
|
|
1412
|
+
const eventPath = typeof event.composedPath === "function" ? event.composedPath() : event.target ? [event.target] : [];
|
|
1413
|
+
return eventPath.some((target) => {
|
|
1414
|
+
if (!target || typeof target !== "object" || !("classList" in target)) {
|
|
1415
|
+
return false;
|
|
1416
|
+
}
|
|
1417
|
+
const classList = target.classList;
|
|
1418
|
+
return classList?.contains(className2) ?? false;
|
|
1419
|
+
});
|
|
1420
|
+
}, []);
|
|
1421
|
+
const isPinMenuOpen = import_react3.default.useCallback(
|
|
1422
|
+
(column) => openPinMenuColumn === column.name,
|
|
1423
|
+
[openPinMenuColumn]
|
|
1424
|
+
);
|
|
1425
|
+
const pinButtonLabel = import_react3.default.useCallback(
|
|
1426
|
+
(column) => state.isPinned(column) ? labels.unpin : labels.pinColumn,
|
|
1427
|
+
[labels, state]
|
|
1428
|
+
);
|
|
1429
|
+
const onPinTrigger = import_react3.default.useCallback(
|
|
1430
|
+
(column, event) => {
|
|
1431
|
+
event?.stopPropagation();
|
|
1432
|
+
if (state.isPinned(column)) {
|
|
1433
|
+
setOpenPinMenuColumn(null);
|
|
1434
|
+
state.gridApi.pinning.pinColumn(column.name, "none");
|
|
1435
|
+
return;
|
|
1436
|
+
}
|
|
1437
|
+
setOpenPinMenuColumn((current) => current === column.name ? null : column.name);
|
|
1438
|
+
},
|
|
1439
|
+
[state]
|
|
1440
|
+
);
|
|
1441
|
+
const choosePinDirection = import_react3.default.useCallback(
|
|
1442
|
+
(column, direction, event) => {
|
|
1443
|
+
event?.stopPropagation();
|
|
1444
|
+
setOpenPinMenuColumn(null);
|
|
1445
|
+
state.gridApi.pinning.pinColumn(column.name, direction);
|
|
1446
|
+
},
|
|
1447
|
+
[state]
|
|
1448
|
+
);
|
|
1449
|
+
import_react3.default.useLayoutEffect(() => {
|
|
1450
|
+
setHeaderStickyHeight(headerGridRef.current?.offsetHeight ?? 0);
|
|
1451
|
+
setFilterStickyHeight(filterGridRef.current?.offsetHeight ?? 0);
|
|
1452
|
+
}, [visibleColumns, filteringFeature, options.enableFiltering]);
|
|
1453
|
+
import_react3.default.useEffect(() => {
|
|
1454
|
+
if (!openPinMenuColumn) {
|
|
1455
|
+
return;
|
|
1456
|
+
}
|
|
1457
|
+
const handleDocumentClick = (event) => {
|
|
1458
|
+
if (eventPathIncludesClass(event, "pin-control")) {
|
|
1459
|
+
return;
|
|
1460
|
+
}
|
|
1461
|
+
setOpenPinMenuColumn(null);
|
|
1462
|
+
};
|
|
1463
|
+
const handleDocumentEscape = (event) => {
|
|
1464
|
+
if (event.key === "Escape") {
|
|
1465
|
+
setOpenPinMenuColumn(null);
|
|
1466
|
+
}
|
|
1467
|
+
};
|
|
1468
|
+
document.addEventListener("click", handleDocumentClick);
|
|
1469
|
+
document.addEventListener("keydown", handleDocumentEscape);
|
|
1470
|
+
return () => {
|
|
1471
|
+
document.removeEventListener("click", handleDocumentClick);
|
|
1472
|
+
document.removeEventListener("keydown", handleDocumentEscape);
|
|
1473
|
+
};
|
|
1474
|
+
}, [eventPathIncludesClass, openPinMenuColumn]);
|
|
1662
1475
|
const itemsToRender = virtualizationEnabled ? displayItems.slice(virtualScroll.visibleRange.start, virtualScroll.visibleRange.end) : displayItems;
|
|
1663
|
-
const
|
|
1664
|
-
|
|
1665
|
-
|
|
1476
|
+
const onGridTableScroll = (event) => {
|
|
1477
|
+
const bodyScrollTop = Math.max(0, event.currentTarget.scrollTop - stickyChromeHeight);
|
|
1478
|
+
virtualScroll.setScrollTop(bodyScrollTop);
|
|
1479
|
+
const startIndex = Math.floor(bodyScrollTop / rowSize);
|
|
1666
1480
|
state.onViewportScroll(startIndex);
|
|
1667
1481
|
};
|
|
1668
1482
|
function renderDisplayItem(item) {
|
|
@@ -1688,7 +1502,16 @@ function UiGrid({ options, onRegisterApi, cellRenderer, expandableRenderer, clas
|
|
|
1688
1502
|
" ",
|
|
1689
1503
|
labels.groupRowsSuffix
|
|
1690
1504
|
] }),
|
|
1691
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1505
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1506
|
+
"svg",
|
|
1507
|
+
{
|
|
1508
|
+
className: "toggle-icon group-disclosure-icon",
|
|
1509
|
+
viewBox: "0 0 24 24",
|
|
1510
|
+
"aria-hidden": "true",
|
|
1511
|
+
focusable: false,
|
|
1512
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: item.collapsed ? "M10 7l5 5-5 5z" : "M7 10l5 5 5-5z" })
|
|
1513
|
+
}
|
|
1514
|
+
),
|
|
1692
1515
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "sr-only ui-grid-sr-only", children: state.groupDisclosureLabel(item) })
|
|
1693
1516
|
]
|
|
1694
1517
|
},
|
|
@@ -1710,62 +1533,84 @@ function UiGrid({ options, onRegisterApi, cellRenderer, expandableRenderer, clas
|
|
|
1710
1533
|
}
|
|
1711
1534
|
if (item.kind !== "row") return null;
|
|
1712
1535
|
const rowItem = item;
|
|
1713
|
-
return visibleColumns.map((column) =>
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
"
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
}
|
|
1738
|
-
),
|
|
1739
|
-
expandableFeature && state.showExpandToggle(rowItem.row, column) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1740
|
-
"button",
|
|
1741
|
-
{
|
|
1742
|
-
type: "button",
|
|
1743
|
-
className: "row-toggle row-toggle-expand",
|
|
1744
|
-
"data-part": "expand-toggle",
|
|
1745
|
-
"aria-label": state.expandToggleLabel(rowItem.row),
|
|
1746
|
-
"aria-expanded": rowItem.row.expanded,
|
|
1747
|
-
onClick: (e) => state.toggleRowExpansion(rowItem.row, e),
|
|
1748
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { className: "toggle-icon", viewBox: "0 0 24 24", "aria-hidden": "true", focusable: false, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: rowItem.row.expanded ? "M7 10l5 5 5-5z" : "M10 7l5 5-5 5z" }) })
|
|
1749
|
-
}
|
|
1750
|
-
),
|
|
1751
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "cell-value", children: cellEditFeature && state.isEditingCell(rowItem.row, column) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1752
|
-
"input",
|
|
1536
|
+
return visibleColumns.map((column) => {
|
|
1537
|
+
const pinned = state.isPinned(column);
|
|
1538
|
+
const pinOffset = pinned ? state.pinnedOffset(column) : null;
|
|
1539
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1540
|
+
"div",
|
|
1541
|
+
{
|
|
1542
|
+
className: `${cellClassName(rowItem, column)}${pinned ? " is-pinned" : ""}`,
|
|
1543
|
+
"data-part": "body-cell",
|
|
1544
|
+
role: "gridcell",
|
|
1545
|
+
tabIndex: 0,
|
|
1546
|
+
"data-row-id": rowItem.row.id,
|
|
1547
|
+
"data-col-name": column.name,
|
|
1548
|
+
onFocus: () => state.focusCell(rowItem.row, column),
|
|
1549
|
+
onClick: () => state.focusCell(rowItem.row, column),
|
|
1550
|
+
onDoubleClick: (e) => state.handleCellDoubleClick(rowItem.row, column, e),
|
|
1551
|
+
onKeyDown: (e) => state.handleCellKeyDown(rowItem.row, column, e),
|
|
1552
|
+
style: {
|
|
1553
|
+
position: pinned ? "sticky" : void 0,
|
|
1554
|
+
left: pinOffset?.side === "left" ? pinOffset.offset : void 0,
|
|
1555
|
+
right: pinOffset?.side === "right" ? pinOffset.offset : void 0,
|
|
1556
|
+
zIndex: pinned ? 2 : void 0
|
|
1557
|
+
},
|
|
1558
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1559
|
+
"div",
|
|
1753
1560
|
{
|
|
1754
|
-
className: "cell-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1561
|
+
className: "cell-shell",
|
|
1562
|
+
style: { paddingInlineStart: state.cellIndent(rowItem.row, column) },
|
|
1563
|
+
children: [
|
|
1564
|
+
treeViewFeature && state.showTreeToggle(rowItem.row, column) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1565
|
+
"button",
|
|
1566
|
+
{
|
|
1567
|
+
type: "button",
|
|
1568
|
+
className: "row-toggle row-toggle-tree",
|
|
1569
|
+
"data-part": "tree-toggle",
|
|
1570
|
+
"aria-label": state.treeToggleLabel(rowItem.row),
|
|
1571
|
+
"aria-expanded": state.isTreeRowExpanded(rowItem.row),
|
|
1572
|
+
onClick: (e) => state.toggleTreeRow(rowItem.row, e),
|
|
1573
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { className: "toggle-icon", viewBox: "0 0 24 24", "aria-hidden": "true", focusable: false, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1574
|
+
"path",
|
|
1575
|
+
{
|
|
1576
|
+
d: state.isTreeRowExpanded(rowItem.row) ? "M7 10l5 5 5-5z" : "M10 7l5 5-5 5z"
|
|
1577
|
+
}
|
|
1578
|
+
) })
|
|
1579
|
+
}
|
|
1580
|
+
),
|
|
1581
|
+
expandableFeature && state.showExpandToggle(rowItem.row, column) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1582
|
+
"button",
|
|
1583
|
+
{
|
|
1584
|
+
type: "button",
|
|
1585
|
+
className: "row-toggle row-toggle-expand",
|
|
1586
|
+
"data-part": "expand-toggle",
|
|
1587
|
+
"aria-label": state.expandToggleLabel(rowItem.row),
|
|
1588
|
+
"aria-expanded": rowItem.row.expanded,
|
|
1589
|
+
onClick: (e) => state.toggleRowExpansion(rowItem.row, e),
|
|
1590
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { className: "toggle-icon", viewBox: "0 0 24 24", "aria-hidden": "true", focusable: false, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: rowItem.row.expanded ? "M7 10l5 5 5-5z" : "M10 7l5 5-5 5z" }) })
|
|
1591
|
+
}
|
|
1592
|
+
),
|
|
1593
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "cell-value", children: cellEditFeature && state.isEditingCell(rowItem.row, column) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1594
|
+
"input",
|
|
1595
|
+
{
|
|
1596
|
+
className: "cell-editor",
|
|
1597
|
+
"data-row-id": rowItem.row.id,
|
|
1598
|
+
"data-col-name": column.name,
|
|
1599
|
+
"aria-label": state.headerLabel(column),
|
|
1600
|
+
type: state.editorInputType(column),
|
|
1601
|
+
defaultValue: editingValue,
|
|
1602
|
+
onChange: (e) => state.updateEditingValue(e.target.value),
|
|
1603
|
+
onKeyDown: (e) => state.handleEditorKeyDown(e),
|
|
1604
|
+
onBlur: (e) => state.handleEditorBlur(e)
|
|
1605
|
+
}
|
|
1606
|
+
) : cellRenderer ? cellRenderer(state.cellContext(rowItem.row, column)) ?? state.displayValue(rowItem.row, column) : state.displayValue(rowItem.row, column) })
|
|
1607
|
+
]
|
|
1763
1608
|
}
|
|
1764
|
-
)
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
)
|
|
1609
|
+
)
|
|
1610
|
+
},
|
|
1611
|
+
`${rowItem.row.id}-${column.name}`
|
|
1612
|
+
);
|
|
1613
|
+
});
|
|
1769
1614
|
}
|
|
1770
1615
|
function cellClassName(item, column) {
|
|
1771
1616
|
const classes = ["body-cell", "ui-grid-cell"];
|
|
@@ -1795,226 +1640,427 @@ function UiGrid({ options, onRegisterApi, cellRenderer, expandableRenderer, clas
|
|
|
1795
1640
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "deck", children: "Familiar `gridOptions` and `onRegisterApi`, built with React hooks, virtualization, grouping, sorting, filtering, and column ordering." })
|
|
1796
1641
|
] }),
|
|
1797
1642
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "hero-actions", children: [
|
|
1798
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1799
|
-
|
|
1643
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1644
|
+
"button",
|
|
1645
|
+
{
|
|
1646
|
+
type: "button",
|
|
1647
|
+
className: "action action-secondary",
|
|
1648
|
+
"data-part": "action benchmark-action",
|
|
1649
|
+
onClick: () => state.runBenchmark(),
|
|
1650
|
+
children: "Benchmark"
|
|
1651
|
+
}
|
|
1652
|
+
),
|
|
1653
|
+
csvExportFeature && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1654
|
+
"button",
|
|
1655
|
+
{
|
|
1656
|
+
type: "button",
|
|
1657
|
+
className: "action action-secondary",
|
|
1658
|
+
"data-part": "action export-action",
|
|
1659
|
+
onClick: () => state.exportCsv(),
|
|
1660
|
+
children: "Export CSV"
|
|
1661
|
+
}
|
|
1662
|
+
),
|
|
1800
1663
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "stats-card", "data-part": "stats-card", children: [
|
|
1801
1664
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: visibleRowCount }),
|
|
1802
1665
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("small", { children: labels.statsVisibleRows })
|
|
1803
1666
|
] })
|
|
1804
1667
|
] })
|
|
1805
1668
|
] }),
|
|
1806
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [
|
|
1832
|
-
labels.toolbarOf,
|
|
1833
|
-
" ",
|
|
1834
|
-
totalRows,
|
|
1835
|
-
" ",
|
|
1836
|
-
labels.toolbarRows
|
|
1669
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1670
|
+
"section",
|
|
1671
|
+
{
|
|
1672
|
+
className: "metrics-strip",
|
|
1673
|
+
"data-part": "metrics",
|
|
1674
|
+
"aria-label": "Grid performance metrics",
|
|
1675
|
+
children: [
|
|
1676
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("article", { "data-part": "metric-card", children: [
|
|
1677
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("strong", { children: [
|
|
1678
|
+
pipelineMs.toFixed(2),
|
|
1679
|
+
" ms"
|
|
1680
|
+
] }),
|
|
1681
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "pipeline" })
|
|
1682
|
+
] }),
|
|
1683
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("article", { "data-part": "metric-card", children: [
|
|
1684
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: virtualizationEnabled ? "On" : "Off" }),
|
|
1685
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "virtualization" })
|
|
1686
|
+
] }),
|
|
1687
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("article", { "data-part": "metric-card", children: [
|
|
1688
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: state.groupByColumns.length }),
|
|
1689
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "group columns" })
|
|
1690
|
+
] }),
|
|
1691
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("article", { "data-part": "metric-card", children: [
|
|
1692
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: benchmarkResult?.averageMs?.toFixed(2) || "\u2014" }),
|
|
1693
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "benchmark avg" })
|
|
1837
1694
|
] })
|
|
1838
|
-
]
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
{
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
{
|
|
1862
|
-
type: "button",
|
|
1863
|
-
className: `header-action${!state.isColumnSortable(column) ? " header-action-disabled" : ""}`,
|
|
1864
|
-
disabled: !state.isColumnSortable(column),
|
|
1865
|
-
"aria-label": state.sortButtonLabel(column),
|
|
1866
|
-
title: state.sortButtonLabel(column),
|
|
1867
|
-
onClick: () => state.toggleSort(column),
|
|
1868
|
-
children: [
|
|
1869
|
-
renderSortIcon(column),
|
|
1870
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "sr-only ui-grid-sr-only", children: state.sortButtonLabel(column) })
|
|
1871
|
-
]
|
|
1872
|
-
}
|
|
1873
|
-
),
|
|
1874
|
-
groupingFeature && state.isGroupingEnabled() && column.enableGrouping !== false && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1875
|
-
"button",
|
|
1876
|
-
{
|
|
1877
|
-
type: "button",
|
|
1878
|
-
className: `chip-action${state.isGrouped(column) ? " chip-action-active" : ""}`,
|
|
1879
|
-
"data-part": "group-toggle",
|
|
1880
|
-
"aria-label": state.groupingButtonLabel(column),
|
|
1881
|
-
title: state.groupingButtonLabel(column),
|
|
1882
|
-
onClick: (e) => state.toggleGrouping(column, e),
|
|
1883
|
-
children: [
|
|
1884
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", focusable: false, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M4 6h8v4H4V6Zm0 8h8v4H4v-4Zm10-8h6v4h-6V6Zm0 8h6v4h-6v-4Z" }) }),
|
|
1885
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "sr-only ui-grid-sr-only", children: state.groupingButtonLabel(column) })
|
|
1886
|
-
]
|
|
1887
|
-
}
|
|
1888
|
-
)
|
|
1889
|
-
] })
|
|
1890
|
-
]
|
|
1891
|
-
},
|
|
1892
|
-
column.name
|
|
1893
|
-
))
|
|
1894
|
-
}
|
|
1895
|
-
),
|
|
1896
|
-
filteringFeature && state.isFilteringEnabled() && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "filter-grid ui-grid-header", "data-part": "filters", style: { gridTemplateColumns }, children: visibleColumns.map((column) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: "filter-cell ui-grid-filter-container", "data-part": "filter-cell", children: [
|
|
1897
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "sr-only ui-grid-sr-only", children: [
|
|
1898
|
-
labels.filterColumn,
|
|
1899
|
-
" ",
|
|
1900
|
-
state.headerLabel(column)
|
|
1695
|
+
]
|
|
1696
|
+
}
|
|
1697
|
+
),
|
|
1698
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1699
|
+
"section",
|
|
1700
|
+
{
|
|
1701
|
+
className: "grid-frame ui-grid",
|
|
1702
|
+
"data-part": "grid-frame",
|
|
1703
|
+
role: "grid",
|
|
1704
|
+
"aria-label": options.title ?? "Data grid",
|
|
1705
|
+
children: [
|
|
1706
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "grid-toolbar", "data-part": "grid-toolbar", children: [
|
|
1707
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
|
|
1708
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: visibleRowCount }),
|
|
1709
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [
|
|
1710
|
+
labels.toolbarOf,
|
|
1711
|
+
" ",
|
|
1712
|
+
totalRows,
|
|
1713
|
+
" ",
|
|
1714
|
+
labels.toolbarRows
|
|
1715
|
+
] })
|
|
1716
|
+
] }),
|
|
1717
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "`gridOptions` compatibility layer: sorting, filtering, grouping, column moving, templating, and virtualized rendering." })
|
|
1901
1718
|
] }),
|
|
1902
|
-
/* @__PURE__ */ (0, import_jsx_runtime.
|
|
1903
|
-
"
|
|
1719
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1720
|
+
"div",
|
|
1904
1721
|
{
|
|
1905
|
-
className: "ui-grid-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1722
|
+
className: "grid-table ui-grid-contents-wrapper",
|
|
1723
|
+
"data-part": "grid-table",
|
|
1724
|
+
style: virtualizationEnabled ? { height: scrollContainerHeight, overflowY: "auto" } : void 0,
|
|
1725
|
+
onScroll: virtualizationEnabled ? onGridTableScroll : void 0,
|
|
1726
|
+
children: [
|
|
1727
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1728
|
+
"div",
|
|
1729
|
+
{
|
|
1730
|
+
className: "header-grid ui-grid-header ui-grid-header-canvas",
|
|
1731
|
+
"data-part": "header",
|
|
1732
|
+
role: "row",
|
|
1733
|
+
ref: headerGridRef,
|
|
1734
|
+
style: { gridTemplateColumns },
|
|
1735
|
+
children: visibleColumns.map((column) => {
|
|
1736
|
+
const pinned = state.isPinned(column);
|
|
1737
|
+
const pinOffset = pinned ? state.pinnedOffset(column) : null;
|
|
1738
|
+
const pinMenuOpen = isPinMenuOpen(column);
|
|
1739
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1740
|
+
"div",
|
|
1741
|
+
{
|
|
1742
|
+
className: `header-cell ui-grid-header-cell${sortingFeature && state.sortDirection(column) !== "none" ? " is-active" : ""}${pinned ? " is-pinned" : ""}${pinMenuOpen ? " is-pin-menu-open" : ""}`,
|
|
1743
|
+
"data-part": "header-cell",
|
|
1744
|
+
role: "columnheader",
|
|
1745
|
+
"aria-sort": sortingFeature ? state.sortAriaSort(column) : void 0,
|
|
1746
|
+
style: {
|
|
1747
|
+
position: pinned ? "sticky" : void 0,
|
|
1748
|
+
left: pinOffset?.side === "left" ? pinOffset.offset : void 0,
|
|
1749
|
+
right: pinOffset?.side === "right" ? pinOffset.offset : void 0,
|
|
1750
|
+
zIndex: pinMenuOpen ? 8 : pinned ? 2 : void 0
|
|
1751
|
+
},
|
|
1752
|
+
children: [
|
|
1753
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "header-label", children: state.headerLabel(column) }),
|
|
1754
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "header-actions", children: [
|
|
1755
|
+
sortingFeature && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1756
|
+
"button",
|
|
1757
|
+
{
|
|
1758
|
+
type: "button",
|
|
1759
|
+
className: `header-action${!state.isColumnSortable(column) ? " header-action-disabled" : ""}`,
|
|
1760
|
+
disabled: !state.isColumnSortable(column),
|
|
1761
|
+
"aria-label": state.sortButtonLabel(column),
|
|
1762
|
+
title: state.sortButtonLabel(column),
|
|
1763
|
+
onClick: () => state.toggleSort(column),
|
|
1764
|
+
children: [
|
|
1765
|
+
renderSortIcon(column),
|
|
1766
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "sr-only ui-grid-sr-only", children: state.sortButtonLabel(column) })
|
|
1767
|
+
]
|
|
1768
|
+
}
|
|
1769
|
+
),
|
|
1770
|
+
groupingFeature && state.isGroupingEnabled() && column.enableGrouping !== false && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1771
|
+
"button",
|
|
1772
|
+
{
|
|
1773
|
+
type: "button",
|
|
1774
|
+
className: `chip-action${state.isGrouped(column) ? " chip-action-active" : ""}`,
|
|
1775
|
+
"data-part": "group-toggle",
|
|
1776
|
+
"aria-label": state.groupingButtonLabel(column),
|
|
1777
|
+
title: state.groupingButtonLabel(column),
|
|
1778
|
+
onClick: (e) => state.toggleGrouping(column, e),
|
|
1779
|
+
children: [
|
|
1780
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", focusable: false, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M4 6h8v4H4V6Zm0 8h8v4H4v-4Zm10-8h6v4h-6V6Zm0 8h6v4h-6v-4Z" }) }),
|
|
1781
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "sr-only ui-grid-sr-only", children: state.groupingButtonLabel(column) })
|
|
1782
|
+
]
|
|
1783
|
+
}
|
|
1784
|
+
),
|
|
1785
|
+
state.pinningFeature && state.isPinningEnabled() && state.isColumnPinnable(column) && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: `pin-control${pinMenuOpen ? " pin-control-open" : ""}`, onClick: (event) => event.stopPropagation(), children: [
|
|
1786
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1787
|
+
"button",
|
|
1788
|
+
{
|
|
1789
|
+
type: "button",
|
|
1790
|
+
className: `chip-action pin-trigger${pinned || pinMenuOpen ? " chip-action-active" : ""}`,
|
|
1791
|
+
"data-part": "pin-toggle",
|
|
1792
|
+
"aria-label": pinButtonLabel(column),
|
|
1793
|
+
title: pinButtonLabel(column),
|
|
1794
|
+
"aria-haspopup": pinned ? void 0 : "menu",
|
|
1795
|
+
"aria-expanded": pinned ? void 0 : pinMenuOpen,
|
|
1796
|
+
onClick: (event) => onPinTrigger(column, event),
|
|
1797
|
+
children: [
|
|
1798
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", focusable: false, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M16 12V4h1V2H7v2h1v8l-2 2v2h5v6l1 1 1-1v-6h5v-2l-2-2z" }) }),
|
|
1799
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "sr-only ui-grid-sr-only", children: pinButtonLabel(column) })
|
|
1800
|
+
]
|
|
1801
|
+
}
|
|
1802
|
+
),
|
|
1803
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1804
|
+
"div",
|
|
1805
|
+
{
|
|
1806
|
+
className: "pin-menu",
|
|
1807
|
+
"data-part": "pin-menu",
|
|
1808
|
+
role: "menu",
|
|
1809
|
+
"aria-label": "Pin options",
|
|
1810
|
+
"aria-hidden": !pinMenuOpen,
|
|
1811
|
+
children: [
|
|
1812
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1813
|
+
"button",
|
|
1814
|
+
{
|
|
1815
|
+
type: "button",
|
|
1816
|
+
className: "pin-menu-action",
|
|
1817
|
+
"data-part": "pin-left-action",
|
|
1818
|
+
role: "menuitem",
|
|
1819
|
+
"aria-label": labels.pinLeft,
|
|
1820
|
+
title: labels.pinLeft,
|
|
1821
|
+
tabIndex: pinMenuOpen ? 0 : -1,
|
|
1822
|
+
onClick: (event) => choosePinDirection(column, "left", event),
|
|
1823
|
+
children: [
|
|
1824
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", focusable: false, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M10 6 4 12l6 6v-4h10v-4H10V6z" }) }),
|
|
1825
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "sr-only ui-grid-sr-only", children: labels.pinLeft })
|
|
1826
|
+
]
|
|
1827
|
+
}
|
|
1828
|
+
),
|
|
1829
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1830
|
+
"button",
|
|
1831
|
+
{
|
|
1832
|
+
type: "button",
|
|
1833
|
+
className: "pin-menu-action",
|
|
1834
|
+
"data-part": "pin-right-action",
|
|
1835
|
+
role: "menuitem",
|
|
1836
|
+
"aria-label": labels.pinRight,
|
|
1837
|
+
title: labels.pinRight,
|
|
1838
|
+
tabIndex: pinMenuOpen ? 0 : -1,
|
|
1839
|
+
onClick: (event) => choosePinDirection(column, "right", event),
|
|
1840
|
+
children: [
|
|
1841
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", focusable: false, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M14 6v4H4v4h10v4l6-6-6-6z" }) }),
|
|
1842
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "sr-only ui-grid-sr-only", children: labels.pinRight })
|
|
1843
|
+
]
|
|
1844
|
+
}
|
|
1845
|
+
)
|
|
1846
|
+
]
|
|
1847
|
+
}
|
|
1848
|
+
)
|
|
1849
|
+
] })
|
|
1850
|
+
] })
|
|
1851
|
+
]
|
|
1852
|
+
},
|
|
1853
|
+
column.name
|
|
1854
|
+
);
|
|
1855
|
+
})
|
|
1856
|
+
}
|
|
1857
|
+
),
|
|
1858
|
+
filteringFeature && state.isFilteringEnabled() && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1859
|
+
"div",
|
|
1860
|
+
{
|
|
1861
|
+
className: "filter-grid ui-grid-header",
|
|
1862
|
+
"data-part": "filters",
|
|
1863
|
+
ref: filterGridRef,
|
|
1864
|
+
style: { gridTemplateColumns, ["--ui-grid-header-sticky-top"]: `${headerStickyHeight}px` },
|
|
1865
|
+
children: visibleColumns.map((column) => {
|
|
1866
|
+
const pinned = state.isPinned(column);
|
|
1867
|
+
const pinOffset = pinned ? state.pinnedOffset(column) : null;
|
|
1868
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1869
|
+
"label",
|
|
1870
|
+
{
|
|
1871
|
+
className: `filter-cell ui-grid-filter-container${pinned ? " is-pinned" : ""}`,
|
|
1872
|
+
"data-part": "filter-cell",
|
|
1873
|
+
style: {
|
|
1874
|
+
position: pinned ? "sticky" : void 0,
|
|
1875
|
+
left: pinOffset?.side === "left" ? pinOffset.offset : void 0,
|
|
1876
|
+
right: pinOffset?.side === "right" ? pinOffset.offset : void 0,
|
|
1877
|
+
zIndex: pinned ? 2 : void 0
|
|
1878
|
+
},
|
|
1879
|
+
children: [
|
|
1880
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "sr-only ui-grid-sr-only", children: [
|
|
1881
|
+
labels.filterColumn,
|
|
1882
|
+
" ",
|
|
1883
|
+
state.headerLabel(column)
|
|
1884
|
+
] }),
|
|
1885
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1886
|
+
"input",
|
|
1887
|
+
{
|
|
1888
|
+
className: "ui-grid-filter-input",
|
|
1889
|
+
type: "text",
|
|
1890
|
+
defaultValue: state.filterValue(column.name),
|
|
1891
|
+
placeholder: state.filterPlaceholder(column),
|
|
1892
|
+
disabled: state.isFilterInputDisabled(column),
|
|
1893
|
+
onChange: (e) => state.updateFilter(column.name, e.target.value)
|
|
1894
|
+
}
|
|
1895
|
+
)
|
|
1896
|
+
]
|
|
1897
|
+
},
|
|
1898
|
+
column.name
|
|
1899
|
+
);
|
|
1900
|
+
})
|
|
1901
|
+
}
|
|
1902
|
+
),
|
|
1903
|
+
displayItems.length > 0 ? virtualizationEnabled ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "grid-virtual-spacer", style: { height: `${virtualScroll.totalHeight}px` }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1904
|
+
"div",
|
|
1905
|
+
{
|
|
1906
|
+
className: "body-grid ui-grid-canvas grid-virtual-body",
|
|
1907
|
+
"data-part": "body",
|
|
1908
|
+
role: "rowgroup",
|
|
1909
|
+
style: {
|
|
1910
|
+
gridTemplateColumns,
|
|
1911
|
+
position: "absolute",
|
|
1912
|
+
top: `${virtualScroll.offsetY}px`,
|
|
1913
|
+
left: 0
|
|
1914
|
+
},
|
|
1915
|
+
children: itemsToRender.map(renderDisplayItem)
|
|
1916
|
+
}
|
|
1917
|
+
) }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1918
|
+
"div",
|
|
1919
|
+
{
|
|
1920
|
+
className: "body-grid ui-grid-canvas",
|
|
1921
|
+
"data-part": "body",
|
|
1922
|
+
role: "rowgroup",
|
|
1923
|
+
style: { gridTemplateColumns },
|
|
1924
|
+
children: displayItems.map(renderDisplayItem)
|
|
1925
|
+
}
|
|
1926
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "empty-state ui-grid-no-row-overlay", "data-part": "empty-state", children: [
|
|
1927
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: options.emptyMessage ?? labels.emptyHeading }),
|
|
1928
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: labels.emptyDescription })
|
|
1929
|
+
] }),
|
|
1930
|
+
paginationFeature && state.showPaginationControls() && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1931
|
+
"footer",
|
|
1932
|
+
{
|
|
1933
|
+
className: "pagination-bar ui-grid-pagination",
|
|
1934
|
+
"data-part": "pagination",
|
|
1935
|
+
role: "navigation",
|
|
1936
|
+
"aria-label": labels.paginationPage,
|
|
1937
|
+
children: [
|
|
1938
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: state.paginationSummary() }),
|
|
1939
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pagination-controls", children: [
|
|
1940
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1941
|
+
"button",
|
|
1942
|
+
{
|
|
1943
|
+
type: "button",
|
|
1944
|
+
className: "action action-secondary pagination-button",
|
|
1945
|
+
"aria-label": labels.paginationPrevious,
|
|
1946
|
+
disabled: paginationCurrentPage <= 1,
|
|
1947
|
+
onClick: () => state.previousPage(),
|
|
1948
|
+
children: [
|
|
1949
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1950
|
+
"svg",
|
|
1951
|
+
{
|
|
1952
|
+
className: "pagination-icon",
|
|
1953
|
+
viewBox: "0 0 24 24",
|
|
1954
|
+
"aria-hidden": "true",
|
|
1955
|
+
focusable: false,
|
|
1956
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z" })
|
|
1957
|
+
}
|
|
1958
|
+
),
|
|
1959
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "sr-only", children: labels.paginationPrevious })
|
|
1960
|
+
]
|
|
1961
|
+
}
|
|
1962
|
+
),
|
|
1963
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [
|
|
1964
|
+
labels.paginationPage,
|
|
1965
|
+
" ",
|
|
1966
|
+
paginationCurrentPage,
|
|
1967
|
+
" ",
|
|
1968
|
+
labels.paginationOf,
|
|
1969
|
+
" ",
|
|
1970
|
+
paginationTotalPages
|
|
1971
|
+
] }),
|
|
1972
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1973
|
+
"button",
|
|
1974
|
+
{
|
|
1975
|
+
type: "button",
|
|
1976
|
+
className: "action action-secondary pagination-button",
|
|
1977
|
+
"aria-label": labels.paginationNext,
|
|
1978
|
+
disabled: paginationCurrentPage >= paginationTotalPages,
|
|
1979
|
+
onClick: () => state.nextPage(),
|
|
1980
|
+
children: [
|
|
1981
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1982
|
+
"svg",
|
|
1983
|
+
{
|
|
1984
|
+
className: "pagination-icon",
|
|
1985
|
+
viewBox: "0 0 24 24",
|
|
1986
|
+
"aria-hidden": "true",
|
|
1987
|
+
focusable: false,
|
|
1988
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M8.59 16.59L10 18l6-6-6-6-1.41 1.41L13.17 12z" })
|
|
1989
|
+
}
|
|
1990
|
+
),
|
|
1991
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "sr-only", children: labels.paginationNext })
|
|
1992
|
+
]
|
|
1993
|
+
}
|
|
1994
|
+
),
|
|
1995
|
+
state.pageSizeOptions().length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: "pagination-size", children: [
|
|
1996
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "sr-only", children: labels.paginationRows }),
|
|
1997
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1998
|
+
"select",
|
|
1999
|
+
{
|
|
2000
|
+
"aria-label": labels.paginationRows,
|
|
2001
|
+
value: paginationSelectedPageSize,
|
|
2002
|
+
onChange: (e) => state.onPageSizeChange(e.target.value),
|
|
2003
|
+
children: state.pageSizeOptions().map((size) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: size, children: size }, size))
|
|
2004
|
+
}
|
|
2005
|
+
)
|
|
2006
|
+
] })
|
|
2007
|
+
] })
|
|
2008
|
+
]
|
|
2009
|
+
}
|
|
2010
|
+
)
|
|
2011
|
+
]
|
|
1911
2012
|
}
|
|
1912
2013
|
)
|
|
1913
|
-
]
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
{
|
|
1917
|
-
className: "grid-viewport ui-grid-viewport",
|
|
1918
|
-
"data-part": "viewport",
|
|
1919
|
-
ref: virtualScroll.viewportRef,
|
|
1920
|
-
style: { height: viewportHeightPx, overflow: "auto", position: "relative" },
|
|
1921
|
-
onScroll: onViewportScroll,
|
|
1922
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { height: `${virtualScroll.totalHeight}px`, position: "relative" }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1923
|
-
"div",
|
|
1924
|
-
{
|
|
1925
|
-
className: "body-grid ui-grid-canvas",
|
|
1926
|
-
"data-part": "body",
|
|
1927
|
-
role: "rowgroup",
|
|
1928
|
-
style: {
|
|
1929
|
-
gridTemplateColumns,
|
|
1930
|
-
position: "absolute",
|
|
1931
|
-
top: 0,
|
|
1932
|
-
left: 0,
|
|
1933
|
-
right: 0,
|
|
1934
|
-
transform: `translateY(${virtualScroll.offsetY}px)`
|
|
1935
|
-
},
|
|
1936
|
-
children: itemsToRender.map(renderDisplayItem)
|
|
1937
|
-
}
|
|
1938
|
-
) })
|
|
1939
|
-
}
|
|
1940
|
-
) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1941
|
-
"div",
|
|
1942
|
-
{
|
|
1943
|
-
className: "body-grid ui-grid-canvas",
|
|
1944
|
-
"data-part": "body",
|
|
1945
|
-
role: "rowgroup",
|
|
1946
|
-
style: { gridTemplateColumns },
|
|
1947
|
-
children: displayItems.map(renderDisplayItem)
|
|
1948
|
-
}
|
|
1949
|
-
) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "empty-state ui-grid-no-row-overlay", "data-part": "empty-state", children: [
|
|
1950
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: options.emptyMessage ?? labels.emptyHeading }),
|
|
1951
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: labels.emptyDescription })
|
|
1952
|
-
] }),
|
|
1953
|
-
paginationFeature && state.showPaginationControls() && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("footer", { className: "pagination-bar ui-grid-pagination", "data-part": "pagination", role: "navigation", "aria-label": labels.paginationPage, children: [
|
|
1954
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: state.paginationSummary() }),
|
|
1955
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pagination-controls", children: [
|
|
1956
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1957
|
-
"button",
|
|
1958
|
-
{
|
|
1959
|
-
type: "button",
|
|
1960
|
-
className: "action action-secondary pagination-button",
|
|
1961
|
-
"aria-label": labels.paginationPrevious,
|
|
1962
|
-
disabled: paginationCurrentPage <= 1,
|
|
1963
|
-
onClick: () => state.previousPage(),
|
|
1964
|
-
children: [
|
|
1965
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { className: "pagination-icon", viewBox: "0 0 24 24", "aria-hidden": "true", focusable: false, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z" }) }),
|
|
1966
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "sr-only", children: labels.paginationPrevious })
|
|
1967
|
-
]
|
|
1968
|
-
}
|
|
1969
|
-
),
|
|
1970
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [
|
|
1971
|
-
labels.paginationPage,
|
|
1972
|
-
" ",
|
|
1973
|
-
paginationCurrentPage,
|
|
1974
|
-
" ",
|
|
1975
|
-
labels.paginationOf,
|
|
1976
|
-
" ",
|
|
1977
|
-
paginationTotalPages
|
|
1978
|
-
] }),
|
|
1979
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1980
|
-
"button",
|
|
1981
|
-
{
|
|
1982
|
-
type: "button",
|
|
1983
|
-
className: "action action-secondary pagination-button",
|
|
1984
|
-
"aria-label": labels.paginationNext,
|
|
1985
|
-
disabled: paginationCurrentPage >= paginationTotalPages,
|
|
1986
|
-
onClick: () => state.nextPage(),
|
|
1987
|
-
children: [
|
|
1988
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { className: "pagination-icon", viewBox: "0 0 24 24", "aria-hidden": "true", focusable: false, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M8.59 16.59L10 18l6-6-6-6-1.41 1.41L13.17 12z" }) }),
|
|
1989
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "sr-only", children: labels.paginationNext })
|
|
1990
|
-
]
|
|
1991
|
-
}
|
|
1992
|
-
),
|
|
1993
|
-
state.pageSizeOptions().length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: "pagination-size", children: [
|
|
1994
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "sr-only", children: labels.paginationRows }),
|
|
1995
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1996
|
-
"select",
|
|
1997
|
-
{
|
|
1998
|
-
"aria-label": labels.paginationRows,
|
|
1999
|
-
value: paginationSelectedPageSize,
|
|
2000
|
-
onChange: (e) => state.onPageSizeChange(e.target.value),
|
|
2001
|
-
children: state.pageSizeOptions().map((size) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: size, children: size }, size))
|
|
2002
|
-
}
|
|
2003
|
-
)
|
|
2004
|
-
] })
|
|
2005
|
-
] })
|
|
2006
|
-
] })
|
|
2007
|
-
] })
|
|
2008
|
-
] })
|
|
2014
|
+
]
|
|
2015
|
+
}
|
|
2016
|
+
)
|
|
2009
2017
|
] }) });
|
|
2010
2018
|
}
|
|
2011
2019
|
|
|
2020
|
+
// src/mountUiGrid.tsx
|
|
2021
|
+
var import_react4 = __toESM(require("react"));
|
|
2022
|
+
var import_client = require("react-dom/client");
|
|
2023
|
+
function mountUiGrid(container, props) {
|
|
2024
|
+
const root = (0, import_client.createRoot)(container);
|
|
2025
|
+
root.render(import_react4.default.createElement(UiGrid, props));
|
|
2026
|
+
return root;
|
|
2027
|
+
}
|
|
2028
|
+
|
|
2029
|
+
// src/rustWasmGridEngine.ts
|
|
2030
|
+
var import_ui_grid3 = require("@ornery/ui-grid");
|
|
2031
|
+
var uiGridWasmModulePath = "../../../dist/ui-grid-wasm-web/ui_grid_wasm.js";
|
|
2032
|
+
var uiGridWasmBinaryPath = "/dist/ui-grid-wasm-web/ui_grid_wasm_bg.wasm";
|
|
2033
|
+
function registerReactUiGridWasmEngineFromModule(module2) {
|
|
2034
|
+
(0, import_ui_grid3.registerRustWasmGridEngine)({
|
|
2035
|
+
buildPipeline(context) {
|
|
2036
|
+
return module2.build_pipeline_js(context);
|
|
2037
|
+
}
|
|
2038
|
+
});
|
|
2039
|
+
}
|
|
2040
|
+
async function enableReactUiGridWasmEngine() {
|
|
2041
|
+
const module2 = await import(
|
|
2042
|
+
/* @vite-ignore */
|
|
2043
|
+
uiGridWasmModulePath
|
|
2044
|
+
);
|
|
2045
|
+
await module2.default(uiGridWasmBinaryPath);
|
|
2046
|
+
registerReactUiGridWasmEngineFromModule(module2);
|
|
2047
|
+
}
|
|
2048
|
+
|
|
2012
2049
|
// src/index.ts
|
|
2013
|
-
var
|
|
2050
|
+
var import_ui_grid4 = require("@ornery/ui-grid");
|
|
2014
2051
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2015
2052
|
0 && (module.exports = {
|
|
2016
2053
|
DEFAULT_GRID_LABELS,
|
|
2017
2054
|
UiGrid,
|
|
2055
|
+
buildGridTemplateColumns,
|
|
2056
|
+
computeViewportHeightPx,
|
|
2057
|
+
computeViewportRows,
|
|
2058
|
+
enableReactUiGridWasmEngine,
|
|
2059
|
+
formatPaginationSummary,
|
|
2060
|
+
mountUiGrid,
|
|
2061
|
+
orderVisibleColumns,
|
|
2062
|
+
registerReactUiGridWasmEngineFromModule,
|
|
2063
|
+
resolveBenchmarkIterations,
|
|
2018
2064
|
useGridState,
|
|
2019
2065
|
useVirtualScroll
|
|
2020
2066
|
});
|