@ornery/ui-grid-react 0.1.6 → 0.1.7-hotfix
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/demo/main.tsx +1 -1
- package/demo/vite.config.ts +1 -1
- package/dist/UiGrid.d.ts +1 -1
- package/dist/UiGrid.d.ts.map +1 -1
- package/dist/gridStateMath.d.ts +1 -1
- package/dist/gridStateMath.d.ts.map +1 -1
- package/dist/index.d.ts +6 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +388 -239
- package/dist/index.mjs +245 -96
- package/dist/rustWasmGridEngine.d.ts +1 -1
- package/dist/rustWasmGridEngine.d.ts.map +1 -1
- package/dist/useGridState.d.ts +3 -2
- package/dist/useGridState.d.ts.map +1 -1
- package/dist/vanillaAdapter.d.ts +14 -0
- package/dist/vanillaAdapter.d.ts.map +1 -0
- package/package.json +11 -11
- package/src/UiGrid.test.tsx +61 -24
- package/src/UiGrid.tsx +320 -198
- package/src/gridStateMath.test.ts +10 -8
- package/src/gridStateMath.ts +20 -7
- package/src/index.ts +20 -5
- package/src/rustWasmGridEngine.test.ts +4 -4
- package/src/rustWasmGridEngine.ts +4 -4
- package/src/ui-grid.css +56 -17
- package/src/useGridState.ts +20 -6
- package/src/vanillaAdapter.test.ts +33 -0
- package/src/vanillaAdapter.ts +36 -0
- package/tsconfig.dts.json +1 -1
- package/tsconfig.json +1 -1
- package/vitest.config.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -30,7 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
|
-
DEFAULT_GRID_LABELS: () =>
|
|
33
|
+
DEFAULT_GRID_LABELS: () => import_ui_grid_core4.DEFAULT_GRID_LABELS,
|
|
34
34
|
UiGrid: () => UiGrid,
|
|
35
35
|
buildGridTemplateColumns: () => buildGridTemplateColumns,
|
|
36
36
|
computeViewportHeightPx: () => computeViewportHeightPx,
|
|
@@ -38,6 +38,7 @@ __export(index_exports, {
|
|
|
38
38
|
enableReactUiGridWasmEngine: () => enableReactUiGridWasmEngine,
|
|
39
39
|
formatPaginationSummary: () => formatPaginationSummary,
|
|
40
40
|
mountUiGrid: () => mountUiGrid,
|
|
41
|
+
mountUiGridCustomElement: () => mountUiGridCustomElement,
|
|
41
42
|
orderVisibleColumns: () => orderVisibleColumns,
|
|
42
43
|
registerReactUiGridWasmEngineFromModule: () => registerReactUiGridWasmEngineFromModule,
|
|
43
44
|
resolveBenchmarkIterations: () => resolveBenchmarkIterations,
|
|
@@ -53,12 +54,12 @@ var import_react3 = __toESM(require("react"));
|
|
|
53
54
|
var import_react = require("react");
|
|
54
55
|
|
|
55
56
|
// src/gridStateMath.ts
|
|
56
|
-
var
|
|
57
|
+
var import_ui_grid_core = require("@ornery/ui-grid-core");
|
|
57
58
|
function orderVisibleColumns(columns, order) {
|
|
58
59
|
return [...columns].filter((column) => column.visible !== false).sort((left, right) => order.indexOf(left.name) - order.indexOf(right.name));
|
|
59
60
|
}
|
|
60
61
|
function buildGridTemplateColumns(columns) {
|
|
61
|
-
return columns.map((column) => (0,
|
|
62
|
+
return columns.map((column) => (0, import_ui_grid_core.gridColumnWidth)(column)).join(" ");
|
|
62
63
|
}
|
|
63
64
|
function resolveBenchmarkIterations(iterations, configuredIterations) {
|
|
64
65
|
return Math.max(1, iterations ?? configuredIterations ?? 25);
|
|
@@ -77,7 +78,7 @@ function computeViewportRows(viewportHeight, rowHeight) {
|
|
|
77
78
|
}
|
|
78
79
|
|
|
79
80
|
// src/useGridState.ts
|
|
80
|
-
var
|
|
81
|
+
var import_ui_grid_core2 = require("@ornery/ui-grid-core");
|
|
81
82
|
function escapeCssSelectorValue(value) {
|
|
82
83
|
const nativeEscape = globalThis.CSS?.escape;
|
|
83
84
|
if (typeof nativeEscape === "function") {
|
|
@@ -115,7 +116,7 @@ function useGridState(options, onRegisterApi) {
|
|
|
115
116
|
const [hiddenRowReasons, setHiddenRowReasons] = (0, import_react.useState)({});
|
|
116
117
|
const [sortState, setSortState] = (0, import_react.useState)({
|
|
117
118
|
columnName: null,
|
|
118
|
-
direction:
|
|
119
|
+
direction: import_ui_grid_core2.SORT_DIRECTIONS.none
|
|
119
120
|
});
|
|
120
121
|
const [focusedCell, setFocusedCell] = (0, import_react.useState)(null);
|
|
121
122
|
const [editingCell, setEditingCell] = (0, import_react.useState)(null);
|
|
@@ -184,13 +185,15 @@ function useGridState(options, onRegisterApi) {
|
|
|
184
185
|
const columnByName = new Map(orderedColumns.map((column) => [column.name, column]));
|
|
185
186
|
const pinnedLeft = pinnedEntries.filter(([, direction]) => direction === "left").map(([columnName]) => columnByName.get(columnName)).filter((column) => column !== void 0);
|
|
186
187
|
const pinnedRight = pinnedEntries.filter(([, direction]) => direction === "right").map(([columnName]) => columnByName.get(columnName)).filter((column) => column !== void 0);
|
|
187
|
-
const centerColumns = orderedColumns.filter(
|
|
188
|
+
const centerColumns = orderedColumns.filter(
|
|
189
|
+
(column) => pinnedColumns[column.name] === void 0
|
|
190
|
+
);
|
|
188
191
|
return [...pinnedLeft, ...centerColumns, ...pinnedRight];
|
|
189
192
|
}, [options.columnDefs, columnOrder, pinnedColumns]);
|
|
190
193
|
const visibleColumnsRef = (0, import_react.useRef)(visibleColumns);
|
|
191
194
|
visibleColumnsRef.current = visibleColumns;
|
|
192
195
|
const pipeline = (0, import_react.useMemo)(() => {
|
|
193
|
-
return
|
|
196
|
+
return import_ui_grid_core2.defaultGridEngine.buildPipeline({
|
|
194
197
|
options,
|
|
195
198
|
columns: visibleColumns,
|
|
196
199
|
activeFilters,
|
|
@@ -220,28 +223,28 @@ function useGridState(options, onRegisterApi) {
|
|
|
220
223
|
]);
|
|
221
224
|
const pipelineRef = (0, import_react.useRef)(pipeline);
|
|
222
225
|
pipelineRef.current = pipeline;
|
|
223
|
-
const labels = (0, import_react.useMemo)(() => (0,
|
|
226
|
+
const labels = (0, import_react.useMemo)(() => (0, import_ui_grid_core2.resolveGridLabels)(options.labels), [options.labels]);
|
|
224
227
|
const gridTemplateColumns = (0, import_react.useMemo)(
|
|
225
228
|
() => buildGridTemplateColumns(visibleColumns),
|
|
226
229
|
[visibleColumns]
|
|
227
230
|
);
|
|
228
231
|
const isPinningEnabledFn = (0, import_react.useCallback)(() => {
|
|
229
|
-
return (0,
|
|
232
|
+
return (0, import_ui_grid_core2.isPinningEnabled)(optionsRef.current);
|
|
230
233
|
}, []);
|
|
231
234
|
const isColumnPinnableFn = (0, import_react.useCallback)((column) => {
|
|
232
|
-
return (0,
|
|
235
|
+
return (0, import_ui_grid_core2.isColumnPinnable)(optionsRef.current, column);
|
|
233
236
|
}, []);
|
|
234
237
|
const isPinnedFn = (0, import_react.useCallback)((column) => {
|
|
235
238
|
return pinnedColumnsRef.current[column.name] !== void 0;
|
|
236
239
|
}, []);
|
|
237
240
|
const pinnedOffsetFn = (0, import_react.useCallback)((column) => {
|
|
238
|
-
return (0,
|
|
241
|
+
return (0, import_ui_grid_core2.computePinnedOffset)(visibleColumnsRef.current, pinnedColumnsRef.current, column);
|
|
239
242
|
}, []);
|
|
240
243
|
const resolveRowId = (0, import_react.useCallback)((row) => {
|
|
241
|
-
return (0,
|
|
244
|
+
return (0, import_ui_grid_core2.resolveGridRowId)(optionsRef.current, row);
|
|
242
245
|
}, []);
|
|
243
246
|
const buildRowsFromData = (0, import_react.useCallback)((data) => {
|
|
244
|
-
return (0,
|
|
247
|
+
return (0, import_ui_grid_core2.buildGridRows)(
|
|
245
248
|
{ ...optionsRef.current, data },
|
|
246
249
|
optionsRef.current.rowHeight ?? 44,
|
|
247
250
|
hiddenRowReasonsRef.current,
|
|
@@ -250,19 +253,19 @@ function useGridState(options, onRegisterApi) {
|
|
|
250
253
|
}, []);
|
|
251
254
|
const findRowById = (0, import_react.useCallback)(
|
|
252
255
|
(rowId) => {
|
|
253
|
-
return (0,
|
|
256
|
+
return (0, import_ui_grid_core2.findGridRowById)(buildRowsFromData(optionsRef.current.data), rowId);
|
|
254
257
|
},
|
|
255
258
|
[buildRowsFromData]
|
|
256
259
|
);
|
|
257
260
|
const canExpandRowsFn = (0, import_react.useCallback)(() => {
|
|
258
|
-
return
|
|
261
|
+
return import_ui_grid_core2.FEATURE_EXPANDABLE && (0, import_ui_grid_core2.canGridExpandRows)(optionsRef.current);
|
|
259
262
|
}, []);
|
|
260
263
|
const effectivePageSizeFn = (0, import_react.useCallback)((totalItems) => {
|
|
261
|
-
return (0,
|
|
264
|
+
return (0, import_ui_grid_core2.getEffectivePageSize)(optionsRef.current, pageSizeRef.current, totalItems);
|
|
262
265
|
}, []);
|
|
263
266
|
const getCurrentPageValueFn = (0, import_react.useCallback)((totalItems) => {
|
|
264
267
|
const ti = totalItems ?? pipelineRef.current.totalItems;
|
|
265
|
-
return (0,
|
|
268
|
+
return (0, import_ui_grid_core2.getCurrentPageValue)(
|
|
266
269
|
optionsRef.current,
|
|
267
270
|
currentPageRef.current,
|
|
268
271
|
ti,
|
|
@@ -271,11 +274,11 @@ function useGridState(options, onRegisterApi) {
|
|
|
271
274
|
}, []);
|
|
272
275
|
const getTotalPagesValueFn = (0, import_react.useCallback)((totalItems) => {
|
|
273
276
|
const ti = totalItems ?? pipelineRef.current.totalItems;
|
|
274
|
-
return (0,
|
|
277
|
+
return (0, import_ui_grid_core2.getTotalPagesValue)(optionsRef.current, ti, pageSizeRef.current);
|
|
275
278
|
}, []);
|
|
276
279
|
const getFirstRowIndexValueFn = (0, import_react.useCallback)((totalItems) => {
|
|
277
280
|
const ti = totalItems ?? pipelineRef.current.totalItems;
|
|
278
|
-
return (0,
|
|
281
|
+
return (0, import_ui_grid_core2.getFirstRowIndexValue)(
|
|
279
282
|
optionsRef.current,
|
|
280
283
|
currentPageRef.current,
|
|
281
284
|
ti,
|
|
@@ -284,7 +287,7 @@ function useGridState(options, onRegisterApi) {
|
|
|
284
287
|
}, []);
|
|
285
288
|
const getLastRowIndexValueFn = (0, import_react.useCallback)((totalItems) => {
|
|
286
289
|
const ti = totalItems ?? pipelineRef.current.totalItems;
|
|
287
|
-
return (0,
|
|
290
|
+
return (0, import_ui_grid_core2.getLastRowIndexValue)(
|
|
288
291
|
optionsRef.current,
|
|
289
292
|
currentPageRef.current,
|
|
290
293
|
ti,
|
|
@@ -293,7 +296,7 @@ function useGridState(options, onRegisterApi) {
|
|
|
293
296
|
}, []);
|
|
294
297
|
const isCellEditable = (0, import_react.useCallback)(
|
|
295
298
|
(row, column, triggerEvent) => {
|
|
296
|
-
if (!
|
|
299
|
+
if (!import_ui_grid_core2.FEATURE_CELL_EDIT) return false;
|
|
297
300
|
const editable = column.enableCellEdit ?? optionsRef.current.enableCellEdit ?? false;
|
|
298
301
|
if (!editable) return false;
|
|
299
302
|
const condition = column.cellEditableCondition ?? optionsRef.current.cellEditableCondition ?? true;
|
|
@@ -358,12 +361,12 @@ function useGridState(options, onRegisterApi) {
|
|
|
358
361
|
refresh: () => setActiveFilters((current) => ({ ...current })),
|
|
359
362
|
getVisibleRows: () => pipelineRef.current.visibleRows,
|
|
360
363
|
setRowInvisible: (row, reason = "user") => {
|
|
361
|
-
const rowId = (0,
|
|
362
|
-
setHiddenRowReasons((current) => (0,
|
|
364
|
+
const rowId = (0, import_ui_grid_core2.resolveGridRowId)(optionsRef.current, row);
|
|
365
|
+
setHiddenRowReasons((current) => (0, import_ui_grid_core2.addGridRowInvisibleReason)(current, rowId, reason));
|
|
363
366
|
},
|
|
364
367
|
clearRowInvisible: (row, reason = "user") => {
|
|
365
|
-
const rowId = (0,
|
|
366
|
-
setHiddenRowReasons((current) => (0,
|
|
368
|
+
const rowId = (0, import_ui_grid_core2.resolveGridRowId)(optionsRef.current, row);
|
|
369
|
+
setHiddenRowReasons((current) => (0, import_ui_grid_core2.clearGridRowInvisibleReason)(current, rowId, reason));
|
|
367
370
|
},
|
|
368
371
|
setFilter: (columnName, value) => {
|
|
369
372
|
setActiveFilters((current) => {
|
|
@@ -380,19 +383,19 @@ function useGridState(options, onRegisterApi) {
|
|
|
380
383
|
queueMicrotask(() => gridApiRef.current.core.raise.filterChanged(nextFilters));
|
|
381
384
|
},
|
|
382
385
|
sortColumn: (columnName, direction) => {
|
|
383
|
-
(0,
|
|
386
|
+
(0, import_ui_grid_core2.sortGridColumnCommand)(gridApiRef.current, (s) => setSortState(s), columnName, direction);
|
|
384
387
|
},
|
|
385
388
|
moveColumn: (fromIndex, toIndex) => {
|
|
386
|
-
(0,
|
|
389
|
+
(0, import_ui_grid_core2.moveGridColumnCommand)(
|
|
387
390
|
gridApiRef.current,
|
|
388
|
-
|
|
391
|
+
import_ui_grid_core2.FEATURE_COLUMN_MOVING && optionsRef.current.enableColumnMoving === true,
|
|
389
392
|
(updater) => setColumnOrder((current) => updater(current)),
|
|
390
393
|
fromIndex,
|
|
391
394
|
toIndex
|
|
392
395
|
);
|
|
393
396
|
},
|
|
394
397
|
toggleGrouping: (columnName) => {
|
|
395
|
-
if (!(
|
|
398
|
+
if (!(import_ui_grid_core2.FEATURE_GROUPING && (0, import_ui_grid_core2.isGridGroupingEnabled)(optionsRef.current))) return;
|
|
396
399
|
const current = groupByColumnsRef.current;
|
|
397
400
|
const next = current.includes(columnName) ? current.filter((n) => n !== columnName) : [...current, columnName];
|
|
398
401
|
groupByColumnsRef.current = next;
|
|
@@ -400,7 +403,7 @@ function useGridState(options, onRegisterApi) {
|
|
|
400
403
|
gridApiRef.current.core.raise.groupingChanged(next);
|
|
401
404
|
},
|
|
402
405
|
clearGrouping: () => {
|
|
403
|
-
(0,
|
|
406
|
+
(0, import_ui_grid_core2.clearGridGroupingCommand)(
|
|
404
407
|
gridApiRef.current,
|
|
405
408
|
(grouping) => setGroupByColumns(grouping),
|
|
406
409
|
false
|
|
@@ -423,30 +426,30 @@ function useGridState(options, onRegisterApi) {
|
|
|
423
426
|
toggleRowExpansion: (row) => toggleRowExpansionByRefFn(row),
|
|
424
427
|
expandAllRows: () => expandAllRowsFn(),
|
|
425
428
|
collapseAllRows: () => {
|
|
426
|
-
(0,
|
|
429
|
+
(0, import_ui_grid_core2.collapseAllGridRowsCommand)((e) => setExpandedRows(e));
|
|
427
430
|
},
|
|
428
431
|
toggleAllRows: () => toggleAllRowsFn(),
|
|
429
432
|
treeExpandAllRows: () => {
|
|
430
|
-
(0,
|
|
433
|
+
(0, import_ui_grid_core2.expandAllGridTreeRowsCommand)(
|
|
431
434
|
(data) => buildRowsFromData(data),
|
|
432
435
|
optionsRef.current.data,
|
|
433
436
|
(e) => setExpandedTreeRows(e)
|
|
434
437
|
);
|
|
435
438
|
},
|
|
436
439
|
treeCollapseAllRows: () => {
|
|
437
|
-
(0,
|
|
440
|
+
(0, import_ui_grid_core2.collapseAllGridTreeRowsCommand)((e) => setExpandedTreeRows(e));
|
|
438
441
|
},
|
|
439
442
|
treeToggleRow: (row) => toggleTreeRowByRefFn(row),
|
|
440
443
|
treeExpandRow: (row) => expandTreeRowByRefFn(row),
|
|
441
444
|
treeCollapseRow: (row) => collapseTreeRowByRefFn(row),
|
|
442
445
|
treeGetRowChildren: (row) => {
|
|
443
|
-
const rowId = (0,
|
|
446
|
+
const rowId = (0, import_ui_grid_core2.resolveGridRowId)(optionsRef.current, row);
|
|
444
447
|
return buildRowsFromData(optionsRef.current.data).filter((r) => r.parentId === rowId);
|
|
445
448
|
},
|
|
446
449
|
treeGetState: () => expandedTreeRowsRef.current,
|
|
447
450
|
treeSetState: (state) => setExpandedTreeRows({ ...state }),
|
|
448
451
|
infiniteScrollDataLoaded: (scrollUp, scrollDown) => {
|
|
449
|
-
return (0,
|
|
452
|
+
return (0, import_ui_grid_core2.completeGridInfiniteScrollDataLoadCommand)(
|
|
450
453
|
infiniteScrollStateRef.current,
|
|
451
454
|
(s) => setInfiniteScrollState(s),
|
|
452
455
|
scrollUp ?? infiniteScrollStateRef.current.scrollUp,
|
|
@@ -454,35 +457,35 @@ function useGridState(options, onRegisterApi) {
|
|
|
454
457
|
);
|
|
455
458
|
},
|
|
456
459
|
infiniteScrollReset: (scrollUp, scrollDown) => {
|
|
457
|
-
(0,
|
|
460
|
+
(0, import_ui_grid_core2.resetGridInfiniteScrollCommand)(
|
|
458
461
|
(s) => setInfiniteScrollState(s),
|
|
459
462
|
scrollUp ?? infiniteScrollStateRef.current.scrollUp,
|
|
460
463
|
scrollDown ?? infiniteScrollStateRef.current.scrollDown
|
|
461
464
|
);
|
|
462
465
|
},
|
|
463
466
|
infiniteScrollSaveScrollPercentage: () => {
|
|
464
|
-
(0,
|
|
467
|
+
(0, import_ui_grid_core2.saveGridInfiniteScrollPercentageCommand)(
|
|
465
468
|
infiniteScrollStateRef.current,
|
|
466
469
|
pipelineRef.current.visibleRows.length,
|
|
467
470
|
(s) => setInfiniteScrollState(s)
|
|
468
471
|
);
|
|
469
472
|
},
|
|
470
473
|
infiniteScrollDataRemovedTop: (scrollUp, scrollDown) => {
|
|
471
|
-
(0,
|
|
474
|
+
(0, import_ui_grid_core2.resetGridInfiniteScrollCommand)(
|
|
472
475
|
(s) => setInfiniteScrollState(s),
|
|
473
476
|
scrollUp ?? infiniteScrollStateRef.current.scrollUp,
|
|
474
477
|
scrollDown ?? infiniteScrollStateRef.current.scrollDown
|
|
475
478
|
);
|
|
476
479
|
},
|
|
477
480
|
infiniteScrollDataRemovedBottom: (scrollUp, scrollDown) => {
|
|
478
|
-
(0,
|
|
481
|
+
(0, import_ui_grid_core2.resetGridInfiniteScrollCommand)(
|
|
479
482
|
(s) => setInfiniteScrollState(s),
|
|
480
483
|
scrollUp ?? infiniteScrollStateRef.current.scrollUp,
|
|
481
484
|
scrollDown ?? infiniteScrollStateRef.current.scrollDown
|
|
482
485
|
);
|
|
483
486
|
},
|
|
484
487
|
infiniteScrollSetDirections: (scrollUp, scrollDown) => {
|
|
485
|
-
(0,
|
|
488
|
+
(0, import_ui_grid_core2.setGridInfiniteScrollDirectionsCommand)(
|
|
486
489
|
infiniteScrollStateRef.current,
|
|
487
490
|
(s) => setInfiniteScrollState(s),
|
|
488
491
|
scrollUp,
|
|
@@ -490,7 +493,7 @@ function useGridState(options, onRegisterApi) {
|
|
|
490
493
|
);
|
|
491
494
|
},
|
|
492
495
|
saveState: () => {
|
|
493
|
-
return (0,
|
|
496
|
+
return (0, import_ui_grid_core2.buildGridSavedState)({
|
|
494
497
|
columnOrder: columnOrderRef.current,
|
|
495
498
|
activeFilters: activeFiltersRef.current,
|
|
496
499
|
sortState: sortStateRef.current,
|
|
@@ -504,7 +507,7 @@ function useGridState(options, onRegisterApi) {
|
|
|
504
507
|
});
|
|
505
508
|
},
|
|
506
509
|
restoreState: (state) => {
|
|
507
|
-
(0,
|
|
510
|
+
(0, import_ui_grid_core2.restoreGridStateCommand)(gridApiRef.current, state, {
|
|
508
511
|
setColumnOrder: (order) => setColumnOrder(order),
|
|
509
512
|
setActiveFilters: (filters) => setActiveFilters(filters),
|
|
510
513
|
setSortState: (s) => setSortState(s),
|
|
@@ -518,8 +521,8 @@ function useGridState(options, onRegisterApi) {
|
|
|
518
521
|
});
|
|
519
522
|
},
|
|
520
523
|
beginCellEdit: (row, columnName, triggerEvent) => {
|
|
521
|
-
const rowId = (0,
|
|
522
|
-
const gridRow = (0,
|
|
524
|
+
const rowId = (0, import_ui_grid_core2.resolveGridRowId)(optionsRef.current, row);
|
|
525
|
+
const gridRow = (0, import_ui_grid_core2.findGridRowById)(buildRowsFromData(optionsRef.current.data), rowId);
|
|
523
526
|
const column = visibleColumnsRef.current.find((c) => c.name === columnName);
|
|
524
527
|
if (!gridRow || !column || !isCellEditable(gridRow, column, triggerEvent)) return;
|
|
525
528
|
startCellEditFn(gridRow, column, triggerEvent);
|
|
@@ -528,7 +531,7 @@ function useGridState(options, onRegisterApi) {
|
|
|
528
531
|
cancelCellEdit: () => cancelCellEditFn(),
|
|
529
532
|
getEditingCell: () => editingCellRef.current,
|
|
530
533
|
pinColumn: (columnName, direction) => {
|
|
531
|
-
(0,
|
|
534
|
+
(0, import_ui_grid_core2.pinGridColumnCommand)(
|
|
532
535
|
gridApiRef.current,
|
|
533
536
|
isPinningEnabledFn(),
|
|
534
537
|
(v) => setPinnedColumns(v),
|
|
@@ -538,12 +541,12 @@ function useGridState(options, onRegisterApi) {
|
|
|
538
541
|
);
|
|
539
542
|
}
|
|
540
543
|
};
|
|
541
|
-
gridApiRef.current = (0,
|
|
544
|
+
gridApiRef.current = (0, import_ui_grid_core2.createGridApi)(bindings);
|
|
542
545
|
}
|
|
543
546
|
const gridApi = gridApiRef.current;
|
|
544
547
|
const seekPageFn = (0, import_react.useCallback)(
|
|
545
548
|
(page) => {
|
|
546
|
-
(0,
|
|
549
|
+
(0, import_ui_grid_core2.seekGridPaginationCommand)(
|
|
547
550
|
gridApiRef.current,
|
|
548
551
|
(nextPage) => setCurrentPage(nextPage),
|
|
549
552
|
() => getTotalPagesValueFn(),
|
|
@@ -556,7 +559,7 @@ function useGridState(options, onRegisterApi) {
|
|
|
556
559
|
const togglePinFn = (0, import_react.useCallback)((column) => {
|
|
557
560
|
const current = pinnedColumnsRef.current[column.name];
|
|
558
561
|
const next = current === "left" ? "right" : current === "right" ? "none" : "left";
|
|
559
|
-
(0,
|
|
562
|
+
(0, import_ui_grid_core2.pinGridColumnCommand)(
|
|
560
563
|
gridApiRef.current,
|
|
561
564
|
isPinningEnabledFn(),
|
|
562
565
|
(v) => setPinnedColumns(v),
|
|
@@ -566,7 +569,7 @@ function useGridState(options, onRegisterApi) {
|
|
|
566
569
|
);
|
|
567
570
|
}, []);
|
|
568
571
|
const setPaginationPageSizeFn = (0, import_react.useCallback)((ps) => {
|
|
569
|
-
(0,
|
|
572
|
+
(0, import_ui_grid_core2.setGridPaginationPageSizeCommand)(
|
|
570
573
|
gridApiRef.current,
|
|
571
574
|
(nextPageSize) => setPageSize(nextPageSize),
|
|
572
575
|
(nextPage) => setCurrentPage(nextPage),
|
|
@@ -575,83 +578,83 @@ function useGridState(options, onRegisterApi) {
|
|
|
575
578
|
}, []);
|
|
576
579
|
const toggleRowExpansionByRefFn = (0, import_react.useCallback)(
|
|
577
580
|
(row) => {
|
|
578
|
-
const rowId = (0,
|
|
579
|
-
(0,
|
|
581
|
+
const rowId = (0, import_ui_grid_core2.resolveGridRowId)(optionsRef.current, row);
|
|
582
|
+
(0, import_ui_grid_core2.toggleGridRowExpansionCommand)(
|
|
580
583
|
gridApiRef.current,
|
|
581
|
-
|
|
584
|
+
import_ui_grid_core2.FEATURE_EXPANDABLE && (0, import_ui_grid_core2.canGridExpandRows)(optionsRef.current),
|
|
582
585
|
expandedRowsRef.current,
|
|
583
586
|
rowId,
|
|
584
587
|
(e) => setExpandedRows(e),
|
|
585
|
-
(resolvedRowId) => (0,
|
|
588
|
+
(resolvedRowId) => (0, import_ui_grid_core2.findGridRowById)(buildRowsFromData(optionsRef.current.data), resolvedRowId)
|
|
586
589
|
);
|
|
587
590
|
},
|
|
588
591
|
[buildRowsFromData]
|
|
589
592
|
);
|
|
590
593
|
const expandAllRowsFn = (0, import_react.useCallback)(() => {
|
|
591
|
-
if (!(0,
|
|
592
|
-
(0,
|
|
594
|
+
if (!(0, import_ui_grid_core2.canGridExpandRows)(optionsRef.current)) return;
|
|
595
|
+
(0, import_ui_grid_core2.expandAllGridRowsCommand)(
|
|
593
596
|
(data) => buildRowsFromData(data),
|
|
594
597
|
optionsRef.current.data,
|
|
595
598
|
(e) => setExpandedRows(e)
|
|
596
599
|
);
|
|
597
600
|
}, [buildRowsFromData]);
|
|
598
601
|
const toggleAllRowsFn = (0, import_react.useCallback)(() => {
|
|
599
|
-
const allExpanded = (0,
|
|
602
|
+
const allExpanded = (0, import_ui_grid_core2.areAllGridRowsExpanded)(
|
|
600
603
|
buildRowsFromData(optionsRef.current.data),
|
|
601
604
|
expandedRowsRef.current
|
|
602
605
|
);
|
|
603
606
|
if (allExpanded) {
|
|
604
|
-
(0,
|
|
607
|
+
(0, import_ui_grid_core2.collapseAllGridRowsCommand)((e) => setExpandedRows(e));
|
|
605
608
|
} else {
|
|
606
609
|
expandAllRowsFn();
|
|
607
610
|
}
|
|
608
611
|
}, [buildRowsFromData, expandAllRowsFn]);
|
|
609
612
|
const toggleTreeRowByRefFn = (0, import_react.useCallback)(
|
|
610
613
|
(row) => {
|
|
611
|
-
const rowId = (0,
|
|
612
|
-
(0,
|
|
614
|
+
const rowId = (0, import_ui_grid_core2.resolveGridRowId)(optionsRef.current, row);
|
|
615
|
+
(0, import_ui_grid_core2.toggleGridTreeRowCommand)(
|
|
613
616
|
gridApiRef.current,
|
|
614
617
|
expandedTreeRowsRef.current,
|
|
615
618
|
rowId,
|
|
616
619
|
(e) => setExpandedTreeRows(e),
|
|
617
|
-
(resolvedRowId) => (0,
|
|
620
|
+
(resolvedRowId) => (0, import_ui_grid_core2.findGridRowById)(buildRowsFromData(optionsRef.current.data), resolvedRowId)
|
|
618
621
|
);
|
|
619
622
|
},
|
|
620
623
|
[buildRowsFromData]
|
|
621
624
|
);
|
|
622
625
|
const expandTreeRowByRefFn = (0, import_react.useCallback)(
|
|
623
626
|
(row) => {
|
|
624
|
-
const rowId = (0,
|
|
625
|
-
(0,
|
|
627
|
+
const rowId = (0, import_ui_grid_core2.resolveGridRowId)(optionsRef.current, row);
|
|
628
|
+
(0, import_ui_grid_core2.setGridTreeRowExpandedCommand)(
|
|
626
629
|
gridApiRef.current,
|
|
627
630
|
expandedTreeRowsRef.current,
|
|
628
631
|
rowId,
|
|
629
632
|
true,
|
|
630
633
|
(e) => setExpandedTreeRows(e),
|
|
631
|
-
(resolvedRowId) => (0,
|
|
634
|
+
(resolvedRowId) => (0, import_ui_grid_core2.findGridRowById)(buildRowsFromData(optionsRef.current.data), resolvedRowId)
|
|
632
635
|
);
|
|
633
636
|
},
|
|
634
637
|
[buildRowsFromData]
|
|
635
638
|
);
|
|
636
639
|
const collapseTreeRowByRefFn = (0, import_react.useCallback)(
|
|
637
640
|
(row) => {
|
|
638
|
-
const rowId = (0,
|
|
639
|
-
(0,
|
|
641
|
+
const rowId = (0, import_ui_grid_core2.resolveGridRowId)(optionsRef.current, row);
|
|
642
|
+
(0, import_ui_grid_core2.setGridTreeRowExpandedCommand)(
|
|
640
643
|
gridApiRef.current,
|
|
641
644
|
expandedTreeRowsRef.current,
|
|
642
645
|
rowId,
|
|
643
646
|
false,
|
|
644
647
|
(e) => setExpandedTreeRows(e),
|
|
645
|
-
(resolvedRowId) => (0,
|
|
648
|
+
(resolvedRowId) => (0, import_ui_grid_core2.findGridRowById)(buildRowsFromData(optionsRef.current.data), resolvedRowId)
|
|
646
649
|
);
|
|
647
650
|
},
|
|
648
651
|
[buildRowsFromData]
|
|
649
652
|
);
|
|
650
653
|
const startCellEditFn = (0, import_react.useCallback)(
|
|
651
654
|
(row, column, triggerEvent, initialValue) => {
|
|
652
|
-
const currentValue = (0,
|
|
655
|
+
const currentValue = (0, import_ui_grid_core2.getCellValue)(row.entity, column);
|
|
653
656
|
const focusToken = ++editorFocusTokenRef.current;
|
|
654
|
-
const ec = (0,
|
|
657
|
+
const ec = (0, import_ui_grid_core2.beginGridCellEditCommand)(
|
|
655
658
|
gridApiRef.current,
|
|
656
659
|
{
|
|
657
660
|
setFocusedCell: (fc) => setFocusedCell(fc),
|
|
@@ -672,17 +675,17 @@ function useGridState(options, onRegisterApi) {
|
|
|
672
675
|
);
|
|
673
676
|
const commitCellEditFn = (0, import_react.useCallback)(
|
|
674
677
|
(direction, restoreFocus = true) => {
|
|
675
|
-
const result = (0,
|
|
678
|
+
const result = (0, import_ui_grid_core2.commitGridCellEditCommand)(gridApiRef.current, {
|
|
676
679
|
getEditingCell: () => editingCellRef.current,
|
|
677
680
|
getEditingValue: () => editingValueRef.current,
|
|
678
681
|
setEditingCell: (ec) => setEditingCell(ec),
|
|
679
682
|
setEditingValue: (ev) => setEditingValue(ev),
|
|
680
|
-
findRowById: (rowId) => (0,
|
|
683
|
+
findRowById: (rowId) => (0, import_ui_grid_core2.findGridRowById)(buildRowsFromData(optionsRef.current.data), rowId),
|
|
681
684
|
findColumnByName: (columnName) => visibleColumnsRef.current.find((c) => c.name === columnName),
|
|
682
|
-
parseEditedValue: (column, value, oldValue) => (0,
|
|
685
|
+
parseEditedValue: (column, value, oldValue) => (0, import_ui_grid_core2.parseGridEditedValue)(column, value, oldValue),
|
|
683
686
|
setCellValue: (rowEntity, column, value) => {
|
|
684
687
|
const fieldPath = column.editModelField ?? column.field ?? column.name;
|
|
685
|
-
(0,
|
|
688
|
+
(0, import_ui_grid_core2.setPathValue)(rowEntity, fieldPath, value);
|
|
686
689
|
}
|
|
687
690
|
});
|
|
688
691
|
if (!result.committed || !result.row || !result.column || !result.focusTarget) return;
|
|
@@ -698,11 +701,11 @@ function useGridState(options, onRegisterApi) {
|
|
|
698
701
|
);
|
|
699
702
|
const cancelCellEditFn = (0, import_react.useCallback)(() => {
|
|
700
703
|
const hadEditingCell = editingCellRef.current !== null;
|
|
701
|
-
const result = (0,
|
|
704
|
+
const result = (0, import_ui_grid_core2.cancelGridCellEditCommand)(gridApiRef.current, {
|
|
702
705
|
getEditingCell: () => editingCellRef.current,
|
|
703
706
|
setEditingCell: (ec) => setEditingCell(ec),
|
|
704
707
|
setEditingValue: (ev) => setEditingValue(ev),
|
|
705
|
-
findRowById: (rowId) => (0,
|
|
708
|
+
findRowById: (rowId) => (0, import_ui_grid_core2.findGridRowById)(buildRowsFromData(optionsRef.current.data), rowId),
|
|
706
709
|
findColumnByName: (columnName) => visibleColumnsRef.current.find((c) => c.name === columnName)
|
|
707
710
|
});
|
|
708
711
|
if (!hadEditingCell) return;
|
|
@@ -711,7 +714,7 @@ function useGridState(options, onRegisterApi) {
|
|
|
711
714
|
}, [buildRowsFromData, focusRenderedCell]);
|
|
712
715
|
const moveFocusFn = (0, import_react.useCallback)(
|
|
713
716
|
(row, column, direction, triggerEvent) => {
|
|
714
|
-
const nextCell = (0,
|
|
717
|
+
const nextCell = (0, import_ui_grid_core2.findNextGridCell)({
|
|
715
718
|
rows: pipelineRef.current.visibleRows,
|
|
716
719
|
columns: visibleColumnsRef.current,
|
|
717
720
|
rowId: row.id,
|
|
@@ -734,7 +737,7 @@ function useGridState(options, onRegisterApi) {
|
|
|
734
737
|
optionsRef.current.benchmark?.iterations
|
|
735
738
|
);
|
|
736
739
|
const startedAt = performance.now();
|
|
737
|
-
let lastResult =
|
|
740
|
+
let lastResult = import_ui_grid_core2.defaultGridEngine.buildPipeline({
|
|
738
741
|
options: optionsRef.current,
|
|
739
742
|
columns: visibleColumnsRef.current,
|
|
740
743
|
activeFilters: activeFiltersRef.current,
|
|
@@ -749,7 +752,7 @@ function useGridState(options, onRegisterApi) {
|
|
|
749
752
|
rowSize: optionsRef.current.rowHeight ?? 44
|
|
750
753
|
});
|
|
751
754
|
for (let i = 1; i < safeIterations; i++) {
|
|
752
|
-
lastResult =
|
|
755
|
+
lastResult = import_ui_grid_core2.defaultGridEngine.buildPipeline({
|
|
753
756
|
options: optionsRef.current,
|
|
754
757
|
columns: visibleColumnsRef.current,
|
|
755
758
|
activeFilters: activeFiltersRef.current,
|
|
@@ -773,14 +776,14 @@ function useGridState(options, onRegisterApi) {
|
|
|
773
776
|
renderedItems: lastResult.displayItems.length
|
|
774
777
|
};
|
|
775
778
|
setBenchmarkResult(result);
|
|
776
|
-
(0,
|
|
779
|
+
(0, import_ui_grid_core2.raiseGridBenchmarkComplete)(gridApiRef.current, result);
|
|
777
780
|
return result;
|
|
778
781
|
}, []);
|
|
779
782
|
const exportCsvFn = (0, import_react.useCallback)(() => {
|
|
780
|
-
if (!
|
|
783
|
+
if (!import_ui_grid_core2.FEATURE_CSV_EXPORT) return;
|
|
781
784
|
const columns = visibleColumnsRef.current;
|
|
782
|
-
const csv = (0,
|
|
783
|
-
(0,
|
|
785
|
+
const csv = (0, import_ui_grid_core2.exportCsvRows)(columns, pipelineRef.current.visibleRows);
|
|
786
|
+
(0, import_ui_grid_core2.downloadGridCsvFile)(csv, `${(0, import_ui_grid_core2.sanitizeDownloadFilename)(optionsRef.current.id)}.csv`);
|
|
784
787
|
}, []);
|
|
785
788
|
(0, import_react.useEffect)(() => {
|
|
786
789
|
if (initializedGridIdRef.current === options.id) return;
|
|
@@ -795,9 +798,9 @@ function useGridState(options, onRegisterApi) {
|
|
|
795
798
|
setExpandedTreeRows({});
|
|
796
799
|
setColumnOrder(options.columnDefs.map((column) => column.name));
|
|
797
800
|
setGroupByColumns(options.grouping?.groupBy ?? []);
|
|
798
|
-
setPinnedColumns((0,
|
|
801
|
+
setPinnedColumns((0, import_ui_grid_core2.buildInitialPinnedState)(options.columnDefs));
|
|
799
802
|
setCurrentPage(options.paginationCurrentPage ?? 1);
|
|
800
|
-
setPageSize((0,
|
|
803
|
+
setPageSize((0, import_ui_grid_core2.getEffectivePageSize)(options, 0, options.data.length));
|
|
801
804
|
setInfiniteScrollState({
|
|
802
805
|
scrollUp: options.infiniteScrollUp === true,
|
|
803
806
|
scrollDown: options.infiniteScrollDown !== false,
|
|
@@ -809,28 +812,28 @@ function useGridState(options, onRegisterApi) {
|
|
|
809
812
|
);
|
|
810
813
|
setSortState({
|
|
811
814
|
columnName: initialSort?.name ?? null,
|
|
812
|
-
direction: initialSort?.sort?.direction ??
|
|
815
|
+
direction: initialSort?.sort?.direction ?? import_ui_grid_core2.SORT_DIRECTIONS.none
|
|
813
816
|
});
|
|
814
817
|
onRegisterApi?.(gridApi);
|
|
815
|
-
(0,
|
|
818
|
+
(0, import_ui_grid_core2.raiseGridRenderingComplete)(gridApi);
|
|
816
819
|
}, [options.id]);
|
|
817
820
|
(0, import_react.useEffect)(() => {
|
|
818
|
-
(0,
|
|
819
|
-
(0,
|
|
821
|
+
(0, import_ui_grid_core2.raiseGridRowsRendered)(gridApi, pipeline.visibleRows);
|
|
822
|
+
(0, import_ui_grid_core2.raiseGridRowsVisibleChanged)(gridApi, pipeline.visibleRows);
|
|
820
823
|
const newHeight = pipeline.displayItems.length * rowSize;
|
|
821
824
|
if (newHeight !== lastCanvasHeightRef.current) {
|
|
822
|
-
(0,
|
|
825
|
+
(0, import_ui_grid_core2.raiseGridCanvasHeightChanged)(gridApi, lastCanvasHeightRef.current, newHeight);
|
|
823
826
|
lastCanvasHeightRef.current = newHeight;
|
|
824
827
|
}
|
|
825
828
|
}, [pipeline, gridApi, rowSize]);
|
|
826
829
|
(0, import_react.useEffect)(() => {
|
|
827
|
-
if (!
|
|
830
|
+
if (!import_ui_grid_core2.FEATURE_AUTO_RESIZE || !options.enableAutoResize) return;
|
|
828
831
|
const container = gridContainerRef.current;
|
|
829
832
|
if (!container) return;
|
|
830
|
-
const observer = (0,
|
|
833
|
+
const observer = (0, import_ui_grid_core2.observeGridHostSize)(container, ({ height: nextHeight, width: nextWidth }) => {
|
|
831
834
|
if (nextHeight === lastGridHeightRef.current && nextWidth === lastGridWidthRef.current)
|
|
832
835
|
return;
|
|
833
|
-
(0,
|
|
836
|
+
(0, import_ui_grid_core2.raiseGridDimensionChanged)(
|
|
834
837
|
gridApi,
|
|
835
838
|
lastGridHeightRef.current,
|
|
836
839
|
lastGridWidthRef.current,
|
|
@@ -855,7 +858,7 @@ function useGridState(options, onRegisterApi) {
|
|
|
855
858
|
const paginationTotalPages = getTotalPagesValueFn();
|
|
856
859
|
const paginationSelectedPageSize = effectivePageSizeFn(pipeline.totalItems);
|
|
857
860
|
const viewportHeightPx = computeViewportHeightPx(options.viewportHeight, autoViewportHeight);
|
|
858
|
-
const headerLabelFn = (0, import_react.useCallback)((column) => (0,
|
|
861
|
+
const headerLabelFn = (0, import_react.useCallback)((column) => (0, import_ui_grid_core2.headerLabel)(column), []);
|
|
859
862
|
const isGroupItemFn = (0, import_react.useCallback)(
|
|
860
863
|
(item) => item.kind === "group",
|
|
861
864
|
[]
|
|
@@ -870,24 +873,24 @@ function useGridState(options, onRegisterApi) {
|
|
|
870
873
|
[]
|
|
871
874
|
);
|
|
872
875
|
const sortDirectionFn = (0, import_react.useCallback)((column) => {
|
|
873
|
-
return sortStateRef.current.columnName === column.name ? sortStateRef.current.direction :
|
|
876
|
+
return sortStateRef.current.columnName === column.name ? sortStateRef.current.direction : import_ui_grid_core2.SORT_DIRECTIONS.none;
|
|
874
877
|
}, []);
|
|
875
878
|
const sortButtonLabelFn = (0, import_react.useCallback)(
|
|
876
879
|
(column) => {
|
|
877
|
-
return (0,
|
|
880
|
+
return (0, import_ui_grid_core2.gridSortButtonLabel)(sortDirectionFn(column), labels);
|
|
878
881
|
},
|
|
879
882
|
[labels, sortDirectionFn]
|
|
880
883
|
);
|
|
881
884
|
const sortAriaSortFn = (0, import_react.useCallback)(
|
|
882
885
|
(column) => {
|
|
883
|
-
return (0,
|
|
886
|
+
return (0, import_ui_grid_core2.gridSortAriaSort)(sortDirectionFn(column));
|
|
884
887
|
},
|
|
885
888
|
[sortDirectionFn]
|
|
886
889
|
);
|
|
887
890
|
const groupingButtonLabelFn = (0, import_react.useCallback)(
|
|
888
891
|
(column) => {
|
|
889
|
-
return (0,
|
|
890
|
-
(0,
|
|
892
|
+
return (0, import_ui_grid_core2.gridGroupingButtonLabel)(
|
|
893
|
+
(0, import_ui_grid_core2.isGridColumnGrouped)(groupByColumnsRef.current, column),
|
|
891
894
|
labels
|
|
892
895
|
);
|
|
893
896
|
},
|
|
@@ -898,39 +901,39 @@ function useGridState(options, onRegisterApi) {
|
|
|
898
901
|
}, []);
|
|
899
902
|
const filterPlaceholderFn = (0, import_react.useCallback)(
|
|
900
903
|
(column) => {
|
|
901
|
-
return (0,
|
|
904
|
+
return (0, import_ui_grid_core2.gridFilterPlaceholder)((0, import_ui_grid_core2.isGridColumnFilterable)(optionsRef.current, column), labels);
|
|
902
905
|
},
|
|
903
906
|
[labels]
|
|
904
907
|
);
|
|
905
908
|
const isFilterInputDisabledFn = (0, import_react.useCallback)((column) => {
|
|
906
|
-
return !(0,
|
|
909
|
+
return !(0, import_ui_grid_core2.isGridColumnFilterable)(optionsRef.current, column);
|
|
907
910
|
}, []);
|
|
908
911
|
const groupDisclosureLabelFn = (0, import_react.useCallback)(
|
|
909
912
|
(item) => {
|
|
910
|
-
return (0,
|
|
913
|
+
return (0, import_ui_grid_core2.gridGroupDisclosureLabel)(item.collapsed, labels);
|
|
911
914
|
},
|
|
912
915
|
[labels]
|
|
913
916
|
);
|
|
914
917
|
const cellContextFn = (0, import_react.useCallback)(
|
|
915
918
|
(row, column) => {
|
|
916
|
-
return (0,
|
|
919
|
+
return (0, import_ui_grid_core2.buildGridCellContext)(row, column);
|
|
917
920
|
},
|
|
918
921
|
[]
|
|
919
922
|
);
|
|
920
923
|
const displayValueFn = (0, import_react.useCallback)(
|
|
921
924
|
(row, column) => {
|
|
922
|
-
return (0,
|
|
925
|
+
return (0, import_ui_grid_core2.formatGridCellDisplayValue)(cellContextFn(row, column));
|
|
923
926
|
},
|
|
924
927
|
[cellContextFn]
|
|
925
928
|
);
|
|
926
929
|
const isFocusedCellFn = (0, import_react.useCallback)((row, column) => {
|
|
927
|
-
return (0,
|
|
930
|
+
return (0, import_ui_grid_core2.isGridCellPosition)(focusedCellRef.current, row.id, column.name);
|
|
928
931
|
}, []);
|
|
929
932
|
const isEditingCellFn = (0, import_react.useCallback)((row, column) => {
|
|
930
|
-
return (0,
|
|
933
|
+
return (0, import_ui_grid_core2.isGridCellPosition)(editingCellRef.current, row.id, column.name);
|
|
931
934
|
}, []);
|
|
932
935
|
const editorInputTypeFn = (0, import_react.useCallback)((column) => {
|
|
933
|
-
return (0,
|
|
936
|
+
return (0, import_ui_grid_core2.gridEditorInputType)(column);
|
|
934
937
|
}, []);
|
|
935
938
|
const expandedContextFn = (0, import_react.useCallback)(
|
|
936
939
|
(row) => {
|
|
@@ -944,42 +947,42 @@ function useGridState(options, onRegisterApi) {
|
|
|
944
947
|
},
|
|
945
948
|
[]
|
|
946
949
|
);
|
|
947
|
-
const columnWidthFn = (0, import_react.useCallback)((column) => (0,
|
|
950
|
+
const columnWidthFn = (0, import_react.useCallback)((column) => (0, import_ui_grid_core2.gridColumnWidth)(column), []);
|
|
948
951
|
const isColumnSortableFn = (0, import_react.useCallback)((column) => {
|
|
949
|
-
return (0,
|
|
952
|
+
return (0, import_ui_grid_core2.isGridColumnSortable)(optionsRef.current, column);
|
|
950
953
|
}, []);
|
|
951
954
|
const isColumnFilterableFn = (0, import_react.useCallback)((column) => {
|
|
952
|
-
return (0,
|
|
955
|
+
return (0, import_ui_grid_core2.isGridColumnFilterable)(optionsRef.current, column);
|
|
953
956
|
}, []);
|
|
954
957
|
const cellIndentFn = (0, import_react.useCallback)((row, column) => {
|
|
955
|
-
return (0,
|
|
958
|
+
return (0, import_ui_grid_core2.gridCellIndent)(optionsRef.current, visibleColumnsRef.current, row, column);
|
|
956
959
|
}, []);
|
|
957
960
|
const treeToggleLabelFn = (0, import_react.useCallback)(
|
|
958
961
|
(row) => {
|
|
959
|
-
return (0,
|
|
962
|
+
return (0, import_ui_grid_core2.gridTreeToggleLabelForRow)(expandedTreeRowsRef.current, row, labels);
|
|
960
963
|
},
|
|
961
964
|
[labels]
|
|
962
965
|
);
|
|
963
966
|
const isTreeRowExpandedFn = (0, import_react.useCallback)((row) => {
|
|
964
|
-
return (0,
|
|
967
|
+
return (0, import_ui_grid_core2.isGridTreeRowExpanded)(expandedTreeRowsRef.current, row);
|
|
965
968
|
}, []);
|
|
966
969
|
const expandToggleLabelFn = (0, import_react.useCallback)(
|
|
967
970
|
(row) => {
|
|
968
|
-
return (0,
|
|
971
|
+
return (0, import_ui_grid_core2.gridExpandToggleLabelForRow)(row, labels);
|
|
969
972
|
},
|
|
970
973
|
[labels]
|
|
971
974
|
);
|
|
972
975
|
const isGroupedFn = (0, import_react.useCallback)((column) => {
|
|
973
|
-
return (0,
|
|
976
|
+
return (0, import_ui_grid_core2.isGridColumnGrouped)(groupByColumnsRef.current, column);
|
|
974
977
|
}, []);
|
|
975
978
|
const showTreeToggleFn = (0, import_react.useCallback)((row, column) => {
|
|
976
|
-
return (0,
|
|
979
|
+
return (0, import_ui_grid_core2.shouldShowGridTreeToggle)(optionsRef.current, visibleColumnsRef.current, row, column);
|
|
977
980
|
}, []);
|
|
978
981
|
const showExpandToggleFn = (0, import_react.useCallback)((row, column) => {
|
|
979
|
-
return (0,
|
|
982
|
+
return (0, import_ui_grid_core2.shouldShowGridExpandToggle)(optionsRef.current, visibleColumnsRef.current, column);
|
|
980
983
|
}, []);
|
|
981
984
|
const showPaginationControlsFn = (0, import_react.useCallback)(() => {
|
|
982
|
-
return
|
|
985
|
+
return import_ui_grid_core2.FEATURE_PAGINATION && (0, import_ui_grid_core2.shouldShowGridPaginationControls)(optionsRef.current);
|
|
983
986
|
}, []);
|
|
984
987
|
const paginationSummaryFn = (0, import_react.useCallback)(() => {
|
|
985
988
|
const ti = pipelineRef.current.totalItems;
|
|
@@ -989,22 +992,22 @@ function useGridState(options, onRegisterApi) {
|
|
|
989
992
|
return optionsRef.current.paginationPageSizes ?? [];
|
|
990
993
|
}, []);
|
|
991
994
|
const isGroupingEnabledFn = (0, import_react.useCallback)(() => {
|
|
992
|
-
return
|
|
995
|
+
return import_ui_grid_core2.FEATURE_GROUPING && (0, import_ui_grid_core2.isGridGroupingEnabled)(optionsRef.current);
|
|
993
996
|
}, []);
|
|
994
997
|
const isFilteringEnabledFn = (0, import_react.useCallback)(() => {
|
|
995
|
-
return
|
|
998
|
+
return import_ui_grid_core2.FEATURE_FILTERING && (0, import_ui_grid_core2.isGridFilteringEnabled)(optionsRef.current);
|
|
996
999
|
}, []);
|
|
997
1000
|
const toggleSortFn = (0, import_react.useCallback)((column) => {
|
|
998
|
-
if (!
|
|
999
|
-
const currentDirection = sortStateRef.current.columnName === column.name ? sortStateRef.current.direction :
|
|
1000
|
-
const nextDirection = currentDirection ===
|
|
1001
|
-
(0,
|
|
1002
|
-
columnName: nextDirection ===
|
|
1001
|
+
if (!import_ui_grid_core2.FEATURE_SORTING || !(0, import_ui_grid_core2.isGridColumnSortable)(optionsRef.current, column)) return;
|
|
1002
|
+
const currentDirection = sortStateRef.current.columnName === column.name ? sortStateRef.current.direction : import_ui_grid_core2.SORT_DIRECTIONS.none;
|
|
1003
|
+
const nextDirection = currentDirection === import_ui_grid_core2.SORT_DIRECTIONS.none ? import_ui_grid_core2.SORT_DIRECTIONS.asc : currentDirection === import_ui_grid_core2.SORT_DIRECTIONS.asc ? import_ui_grid_core2.SORT_DIRECTIONS.desc : import_ui_grid_core2.SORT_DIRECTIONS.none;
|
|
1004
|
+
(0, import_ui_grid_core2.applyGridSortStateCommand)(gridApiRef.current, (state) => setSortState(state), {
|
|
1005
|
+
columnName: nextDirection === import_ui_grid_core2.SORT_DIRECTIONS.none ? null : column.name,
|
|
1003
1006
|
direction: nextDirection
|
|
1004
1007
|
});
|
|
1005
1008
|
}, []);
|
|
1006
1009
|
const updateFilterFn = (0, import_react.useCallback)((columnName, value) => {
|
|
1007
|
-
(0,
|
|
1010
|
+
(0, import_ui_grid_core2.updateGridFilterCommand)(
|
|
1008
1011
|
gridApiRef.current,
|
|
1009
1012
|
(updater) => setActiveFilters((current) => updater(current)),
|
|
1010
1013
|
() => activeFiltersRef.current,
|
|
@@ -1013,11 +1016,11 @@ function useGridState(options, onRegisterApi) {
|
|
|
1013
1016
|
);
|
|
1014
1017
|
}, []);
|
|
1015
1018
|
const clearAllFiltersFn = (0, import_react.useCallback)(() => {
|
|
1016
|
-
(0,
|
|
1019
|
+
(0, import_ui_grid_core2.clearGridFiltersCommand)(gridApiRef.current, (filters) => setActiveFilters(filters));
|
|
1017
1020
|
}, []);
|
|
1018
1021
|
const toggleGroupingFn = (0, import_react.useCallback)((column, event) => {
|
|
1019
1022
|
event?.stopPropagation();
|
|
1020
|
-
if (!(
|
|
1023
|
+
if (!(import_ui_grid_core2.FEATURE_GROUPING && (0, import_ui_grid_core2.isGridGroupingEnabled)(optionsRef.current))) return;
|
|
1021
1024
|
const current = groupByColumnsRef.current;
|
|
1022
1025
|
const next = current.includes(column.name) ? current.filter((n) => n !== column.name) : [...current, column.name];
|
|
1023
1026
|
groupByColumnsRef.current = next;
|
|
@@ -1032,7 +1035,7 @@ function useGridState(options, onRegisterApi) {
|
|
|
1032
1035
|
}, []);
|
|
1033
1036
|
const focusCellFn = (0, import_react.useCallback)(
|
|
1034
1037
|
(row, column, triggerEvent) => {
|
|
1035
|
-
const nextFocusResult = (0,
|
|
1038
|
+
const nextFocusResult = (0, import_ui_grid_core2.buildGridFocusCellResult)({
|
|
1036
1039
|
currentFocusedCell: focusedCellRef.current,
|
|
1037
1040
|
currentEditingCell: editingCellRef.current,
|
|
1038
1041
|
rowId: row.id,
|
|
@@ -1091,7 +1094,7 @@ function useGridState(options, onRegisterApi) {
|
|
|
1091
1094
|
default:
|
|
1092
1095
|
break;
|
|
1093
1096
|
}
|
|
1094
|
-
if ((0,
|
|
1097
|
+
if ((0, import_ui_grid_core2.isPrintableGridKey)(event.key, event.ctrlKey, event.metaKey, event.altKey) && isCellEditable(row, column, event.nativeEvent)) {
|
|
1095
1098
|
event.preventDefault();
|
|
1096
1099
|
startCellEditFn(row, column, event.nativeEvent, event.key);
|
|
1097
1100
|
}
|
|
@@ -1155,14 +1158,25 @@ function useGridState(options, onRegisterApi) {
|
|
|
1155
1158
|
[toggleTreeRowByRefFn]
|
|
1156
1159
|
);
|
|
1157
1160
|
const moveColumnFn = (0, import_react.useCallback)((fromIndex, toIndex) => {
|
|
1158
|
-
(0,
|
|
1161
|
+
(0, import_ui_grid_core2.moveGridColumnCommand)(
|
|
1159
1162
|
gridApiRef.current,
|
|
1160
|
-
|
|
1163
|
+
import_ui_grid_core2.FEATURE_COLUMN_MOVING && optionsRef.current.enableColumnMoving === true,
|
|
1161
1164
|
(updater) => setColumnOrder((current) => updater(current)),
|
|
1162
1165
|
fromIndex,
|
|
1163
1166
|
toIndex
|
|
1164
1167
|
);
|
|
1165
1168
|
}, []);
|
|
1169
|
+
const moveVisibleColumnFn = (0, import_react.useCallback)((columnName, targetColumnName) => {
|
|
1170
|
+
(0, import_ui_grid_core2.moveGridVisibleColumnCommand)(
|
|
1171
|
+
gridApiRef.current,
|
|
1172
|
+
import_ui_grid_core2.FEATURE_COLUMN_MOVING && optionsRef.current.enableColumnMoving === true,
|
|
1173
|
+
columnOrderRef.current,
|
|
1174
|
+
visibleColumnsRef.current.map((column) => column.name),
|
|
1175
|
+
columnName,
|
|
1176
|
+
targetColumnName,
|
|
1177
|
+
(order) => setColumnOrder(order)
|
|
1178
|
+
);
|
|
1179
|
+
}, []);
|
|
1166
1180
|
const nextPageFn = (0, import_react.useCallback)(() => {
|
|
1167
1181
|
seekPageFn(getCurrentPageValueFn() + 1);
|
|
1168
1182
|
}, [seekPageFn, getCurrentPageValueFn]);
|
|
@@ -1178,17 +1192,17 @@ function useGridState(options, onRegisterApi) {
|
|
|
1178
1192
|
const onViewportScrollFn = (0, import_react.useCallback)((startIndex) => {
|
|
1179
1193
|
if (!scrollingRef.current) {
|
|
1180
1194
|
scrollingRef.current = true;
|
|
1181
|
-
(0,
|
|
1195
|
+
(0, import_ui_grid_core2.raiseGridScrollBegin)(gridApiRef.current);
|
|
1182
1196
|
}
|
|
1183
1197
|
if (scrollEndHandleRef.current) {
|
|
1184
1198
|
window.clearTimeout(scrollEndHandleRef.current);
|
|
1185
1199
|
}
|
|
1186
1200
|
scrollEndHandleRef.current = window.setTimeout(() => {
|
|
1187
1201
|
scrollingRef.current = false;
|
|
1188
|
-
(0,
|
|
1202
|
+
(0, import_ui_grid_core2.raiseGridScrollEnd)(gridApiRef.current);
|
|
1189
1203
|
}, 120);
|
|
1190
|
-
const isInfiniteScrollEnabled =
|
|
1191
|
-
(0,
|
|
1204
|
+
const isInfiniteScrollEnabled = import_ui_grid_core2.FEATURE_INFINITE_SCROLL && (optionsRef.current.infiniteScrollRowsFromEnd !== void 0 || optionsRef.current.infiniteScrollUp === true || optionsRef.current.infiniteScrollDown !== void 0);
|
|
1205
|
+
(0, import_ui_grid_core2.maybeRequestInfiniteScrollCommand)(gridApiRef.current, {
|
|
1192
1206
|
enabled: isInfiniteScrollEnabled,
|
|
1193
1207
|
virtualizationEnabled: pipelineRef.current.virtualizationEnabled,
|
|
1194
1208
|
state: infiniteScrollStateRef.current,
|
|
@@ -1266,16 +1280,16 @@ function useGridState(options, onRegisterApi) {
|
|
|
1266
1280
|
pageSizeOptions: pageSizeOptionsFn,
|
|
1267
1281
|
isCellEditable,
|
|
1268
1282
|
shouldEditOnFocus: shouldEditOnFocusFn,
|
|
1269
|
-
sortingFeature:
|
|
1270
|
-
filteringFeature:
|
|
1271
|
-
groupingFeature:
|
|
1272
|
-
paginationFeature:
|
|
1273
|
-
cellEditFeature:
|
|
1274
|
-
expandableFeature:
|
|
1275
|
-
treeViewFeature:
|
|
1276
|
-
infiniteScrollFeature:
|
|
1277
|
-
columnMovingFeature:
|
|
1278
|
-
csvExportFeature:
|
|
1283
|
+
sortingFeature: import_ui_grid_core2.FEATURE_SORTING,
|
|
1284
|
+
filteringFeature: import_ui_grid_core2.FEATURE_FILTERING,
|
|
1285
|
+
groupingFeature: import_ui_grid_core2.FEATURE_GROUPING,
|
|
1286
|
+
paginationFeature: import_ui_grid_core2.FEATURE_PAGINATION,
|
|
1287
|
+
cellEditFeature: import_ui_grid_core2.FEATURE_CELL_EDIT,
|
|
1288
|
+
expandableFeature: import_ui_grid_core2.FEATURE_EXPANDABLE,
|
|
1289
|
+
treeViewFeature: import_ui_grid_core2.FEATURE_TREE_VIEW,
|
|
1290
|
+
infiniteScrollFeature: import_ui_grid_core2.FEATURE_INFINITE_SCROLL,
|
|
1291
|
+
columnMovingFeature: import_ui_grid_core2.FEATURE_COLUMN_MOVING,
|
|
1292
|
+
csvExportFeature: import_ui_grid_core2.FEATURE_CSV_EXPORT,
|
|
1279
1293
|
isGroupingEnabled: isGroupingEnabledFn,
|
|
1280
1294
|
isFilteringEnabled: isFilteringEnabledFn,
|
|
1281
1295
|
toggleSort: toggleSortFn,
|
|
@@ -1292,6 +1306,7 @@ function useGridState(options, onRegisterApi) {
|
|
|
1292
1306
|
toggleRowExpansion: toggleRowExpansionFn,
|
|
1293
1307
|
toggleTreeRow: toggleTreeRowFn,
|
|
1294
1308
|
moveColumn: moveColumnFn,
|
|
1309
|
+
moveVisibleColumn: moveVisibleColumnFn,
|
|
1295
1310
|
nextPage: nextPageFn,
|
|
1296
1311
|
previousPage: previousPageFn,
|
|
1297
1312
|
onPageSizeChange: onPageSizeChangeFn,
|
|
@@ -1304,7 +1319,7 @@ function useGridState(options, onRegisterApi) {
|
|
|
1304
1319
|
isPinningEnabled: isPinningEnabledFn,
|
|
1305
1320
|
isColumnPinnable: isColumnPinnableFn,
|
|
1306
1321
|
togglePin: togglePinFn,
|
|
1307
|
-
pinningFeature:
|
|
1322
|
+
pinningFeature: import_ui_grid_core2.FEATURE_PINNING
|
|
1308
1323
|
};
|
|
1309
1324
|
}
|
|
1310
1325
|
|
|
@@ -1391,23 +1406,30 @@ function UiGrid({
|
|
|
1391
1406
|
expandableFeature,
|
|
1392
1407
|
treeViewFeature,
|
|
1393
1408
|
csvExportFeature,
|
|
1409
|
+
columnMovingFeature,
|
|
1394
1410
|
paginationCurrentPage,
|
|
1395
1411
|
paginationTotalPages,
|
|
1396
1412
|
paginationSelectedPageSize
|
|
1397
1413
|
} = state;
|
|
1414
|
+
const headerGridRef = import_react3.default.useRef(null);
|
|
1415
|
+
const filterGridRef = import_react3.default.useRef(null);
|
|
1416
|
+
const [headerStickyHeight, setHeaderStickyHeight] = import_react3.default.useState(0);
|
|
1417
|
+
const [filterStickyHeight, setFilterStickyHeight] = import_react3.default.useState(0);
|
|
1418
|
+
const stickyChromeHeight = headerStickyHeight + filterStickyHeight;
|
|
1419
|
+
const bodyViewportHeight = Math.max(
|
|
1420
|
+
rowSize,
|
|
1421
|
+
(options.viewportHeight ?? 560) - stickyChromeHeight
|
|
1422
|
+
);
|
|
1398
1423
|
const virtualScroll = useVirtualScroll({
|
|
1399
1424
|
itemCount: displayItems.length,
|
|
1400
1425
|
itemSize: rowSize,
|
|
1401
|
-
viewportHeight:
|
|
1426
|
+
viewportHeight: bodyViewportHeight,
|
|
1402
1427
|
overscan: 3
|
|
1403
1428
|
});
|
|
1404
|
-
const headerGridRef = import_react3.default.useRef(null);
|
|
1405
|
-
const filterGridRef = import_react3.default.useRef(null);
|
|
1406
1429
|
const [openPinMenuColumn, setOpenPinMenuColumn] = import_react3.default.useState(null);
|
|
1407
|
-
const [
|
|
1408
|
-
const [
|
|
1409
|
-
const
|
|
1410
|
-
const scrollContainerHeight = `${(options.viewportHeight ?? 560) + stickyChromeHeight}px`;
|
|
1430
|
+
const [draggedColumnName, setDraggedColumnName] = import_react3.default.useState(null);
|
|
1431
|
+
const [dropTargetColumnName, setDropTargetColumnName] = import_react3.default.useState(null);
|
|
1432
|
+
const scrollContainerHeight = `${options.viewportHeight ?? 560}px`;
|
|
1411
1433
|
const eventPathIncludesClass = import_react3.default.useCallback((event, className2) => {
|
|
1412
1434
|
const eventPath = typeof event.composedPath === "function" ? event.composedPath() : event.target ? [event.target] : [];
|
|
1413
1435
|
return eventPath.some((target) => {
|
|
@@ -1446,10 +1468,72 @@ function UiGrid({
|
|
|
1446
1468
|
},
|
|
1447
1469
|
[state]
|
|
1448
1470
|
);
|
|
1471
|
+
const handleHeaderDragStart = import_react3.default.useCallback(
|
|
1472
|
+
(column, event) => {
|
|
1473
|
+
if (!columnMovingFeature) {
|
|
1474
|
+
event.preventDefault();
|
|
1475
|
+
return;
|
|
1476
|
+
}
|
|
1477
|
+
setDraggedColumnName(column.name);
|
|
1478
|
+
setDropTargetColumnName(null);
|
|
1479
|
+
event.dataTransfer.effectAllowed = "move";
|
|
1480
|
+
event.dataTransfer.setData("text/plain", column.name);
|
|
1481
|
+
},
|
|
1482
|
+
[columnMovingFeature]
|
|
1483
|
+
);
|
|
1484
|
+
const handleHeaderDragOver = import_react3.default.useCallback(
|
|
1485
|
+
(column, event) => {
|
|
1486
|
+
if (!columnMovingFeature || !draggedColumnName || draggedColumnName === column.name) {
|
|
1487
|
+
return;
|
|
1488
|
+
}
|
|
1489
|
+
event.preventDefault();
|
|
1490
|
+
event.dataTransfer.dropEffect = "move";
|
|
1491
|
+
setDropTargetColumnName(column.name);
|
|
1492
|
+
},
|
|
1493
|
+
[columnMovingFeature, draggedColumnName]
|
|
1494
|
+
);
|
|
1495
|
+
const handleHeaderDrop = import_react3.default.useCallback(
|
|
1496
|
+
(column, event) => {
|
|
1497
|
+
event.preventDefault();
|
|
1498
|
+
if (!columnMovingFeature) {
|
|
1499
|
+
return;
|
|
1500
|
+
}
|
|
1501
|
+
const sourceColumnName = draggedColumnName ?? event.dataTransfer.getData("text/plain");
|
|
1502
|
+
setDraggedColumnName(null);
|
|
1503
|
+
setDropTargetColumnName(null);
|
|
1504
|
+
if (!sourceColumnName || sourceColumnName === column.name) {
|
|
1505
|
+
return;
|
|
1506
|
+
}
|
|
1507
|
+
state.moveVisibleColumn(sourceColumnName, column.name);
|
|
1508
|
+
},
|
|
1509
|
+
[columnMovingFeature, draggedColumnName, state]
|
|
1510
|
+
);
|
|
1511
|
+
const handleHeaderDragEnd = import_react3.default.useCallback(() => {
|
|
1512
|
+
setDraggedColumnName(null);
|
|
1513
|
+
setDropTargetColumnName(null);
|
|
1514
|
+
}, []);
|
|
1449
1515
|
import_react3.default.useLayoutEffect(() => {
|
|
1450
1516
|
setHeaderStickyHeight(headerGridRef.current?.offsetHeight ?? 0);
|
|
1451
1517
|
setFilterStickyHeight(filterGridRef.current?.offsetHeight ?? 0);
|
|
1452
1518
|
}, [visibleColumns, filteringFeature, options.enableFiltering]);
|
|
1519
|
+
import_react3.default.useLayoutEffect(() => {
|
|
1520
|
+
const headerElement = headerGridRef.current;
|
|
1521
|
+
const filterElement = filterGridRef.current;
|
|
1522
|
+
if (typeof ResizeObserver === "undefined" || !headerElement && !filterElement) {
|
|
1523
|
+
return;
|
|
1524
|
+
}
|
|
1525
|
+
const observer = new ResizeObserver(() => {
|
|
1526
|
+
setHeaderStickyHeight(headerGridRef.current?.offsetHeight ?? 0);
|
|
1527
|
+
setFilterStickyHeight(filterGridRef.current?.offsetHeight ?? 0);
|
|
1528
|
+
});
|
|
1529
|
+
if (headerElement) {
|
|
1530
|
+
observer.observe(headerElement);
|
|
1531
|
+
}
|
|
1532
|
+
if (filterElement) {
|
|
1533
|
+
observer.observe(filterElement);
|
|
1534
|
+
}
|
|
1535
|
+
return () => observer.disconnect();
|
|
1536
|
+
}, []);
|
|
1453
1537
|
import_react3.default.useEffect(() => {
|
|
1454
1538
|
if (!openPinMenuColumn) {
|
|
1455
1539
|
return;
|
|
@@ -1570,12 +1654,21 @@ function UiGrid({
|
|
|
1570
1654
|
"aria-label": state.treeToggleLabel(rowItem.row),
|
|
1571
1655
|
"aria-expanded": state.isTreeRowExpanded(rowItem.row),
|
|
1572
1656
|
onClick: (e) => state.toggleTreeRow(rowItem.row, e),
|
|
1573
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1574
|
-
"
|
|
1657
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1658
|
+
"svg",
|
|
1575
1659
|
{
|
|
1576
|
-
|
|
1660
|
+
className: "toggle-icon",
|
|
1661
|
+
viewBox: "0 0 24 24",
|
|
1662
|
+
"aria-hidden": "true",
|
|
1663
|
+
focusable: false,
|
|
1664
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1665
|
+
"path",
|
|
1666
|
+
{
|
|
1667
|
+
d: state.isTreeRowExpanded(rowItem.row) ? "M7 10l5 5 5-5z" : "M10 7l5 5-5 5z"
|
|
1668
|
+
}
|
|
1669
|
+
)
|
|
1577
1670
|
}
|
|
1578
|
-
)
|
|
1671
|
+
)
|
|
1579
1672
|
}
|
|
1580
1673
|
),
|
|
1581
1674
|
expandableFeature && state.showExpandToggle(rowItem.row, column) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
@@ -1587,7 +1680,16 @@ function UiGrid({
|
|
|
1587
1680
|
"aria-label": state.expandToggleLabel(rowItem.row),
|
|
1588
1681
|
"aria-expanded": rowItem.row.expanded,
|
|
1589
1682
|
onClick: (e) => state.toggleRowExpansion(rowItem.row, e),
|
|
1590
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1683
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1684
|
+
"svg",
|
|
1685
|
+
{
|
|
1686
|
+
className: "toggle-icon",
|
|
1687
|
+
viewBox: "0 0 24 24",
|
|
1688
|
+
"aria-hidden": "true",
|
|
1689
|
+
focusable: false,
|
|
1690
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: rowItem.row.expanded ? "M7 10l5 5 5-5z" : "M10 7l5 5-5 5z" })
|
|
1691
|
+
}
|
|
1692
|
+
)
|
|
1591
1693
|
}
|
|
1592
1694
|
),
|
|
1593
1695
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "cell-value", children: cellEditFeature && state.isEditingCell(rowItem.row, column) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
@@ -1739,10 +1841,20 @@ function UiGrid({
|
|
|
1739
1841
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1740
1842
|
"div",
|
|
1741
1843
|
{
|
|
1742
|
-
className: `header-cell ui-grid-header-cell${sortingFeature && state.sortDirection(column) !== "none" ? " is-active" : ""}${pinned ? " is-pinned" : ""}${pinMenuOpen ? " is-pin-menu-open" : ""}`,
|
|
1844
|
+
className: `header-cell ui-grid-header-cell${sortingFeature && state.sortDirection(column) !== "none" ? " is-active" : ""}${pinned ? " is-pinned" : ""}${pinMenuOpen ? " is-pin-menu-open" : ""}${draggedColumnName === column.name ? " is-dragging" : ""}${dropTargetColumnName === column.name ? " is-drag-target" : ""}`,
|
|
1743
1845
|
"data-part": "header-cell",
|
|
1744
1846
|
role: "columnheader",
|
|
1745
1847
|
"aria-sort": sortingFeature ? state.sortAriaSort(column) : void 0,
|
|
1848
|
+
draggable: columnMovingFeature,
|
|
1849
|
+
onDragStart: (event) => handleHeaderDragStart(column, event),
|
|
1850
|
+
onDragOver: (event) => handleHeaderDragOver(column, event),
|
|
1851
|
+
onDrop: (event) => handleHeaderDrop(column, event),
|
|
1852
|
+
onDragEnd: handleHeaderDragEnd,
|
|
1853
|
+
onDragLeave: () => {
|
|
1854
|
+
if (dropTargetColumnName === column.name) {
|
|
1855
|
+
setDropTargetColumnName(null);
|
|
1856
|
+
}
|
|
1857
|
+
},
|
|
1746
1858
|
style: {
|
|
1747
1859
|
position: pinned ? "sticky" : void 0,
|
|
1748
1860
|
left: pinOffset?.side === "left" ? pinOffset.offset : void 0,
|
|
@@ -1782,71 +1894,78 @@ function UiGrid({
|
|
|
1782
1894
|
]
|
|
1783
1895
|
}
|
|
1784
1896
|
),
|
|
1785
|
-
state.pinningFeature && state.isPinningEnabled() && state.isColumnPinnable(column) && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
{
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
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
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1897
|
+
state.pinningFeature && state.isPinningEnabled() && state.isColumnPinnable(column) && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1898
|
+
"div",
|
|
1899
|
+
{
|
|
1900
|
+
className: `pin-control${pinMenuOpen ? " pin-control-open" : ""}`,
|
|
1901
|
+
onClick: (event) => event.stopPropagation(),
|
|
1902
|
+
children: [
|
|
1903
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1904
|
+
"button",
|
|
1905
|
+
{
|
|
1906
|
+
type: "button",
|
|
1907
|
+
className: `chip-action pin-trigger${pinned || pinMenuOpen ? " chip-action-active" : ""}`,
|
|
1908
|
+
"data-part": "pin-toggle",
|
|
1909
|
+
"aria-label": pinButtonLabel(column),
|
|
1910
|
+
title: pinButtonLabel(column),
|
|
1911
|
+
"aria-haspopup": pinned ? void 0 : "menu",
|
|
1912
|
+
"aria-expanded": pinned ? void 0 : pinMenuOpen,
|
|
1913
|
+
onClick: (event) => onPinTrigger(column, event),
|
|
1914
|
+
children: [
|
|
1915
|
+
/* @__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" }) }),
|
|
1916
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "sr-only ui-grid-sr-only", children: pinButtonLabel(column) })
|
|
1917
|
+
]
|
|
1918
|
+
}
|
|
1919
|
+
),
|
|
1920
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1921
|
+
"div",
|
|
1922
|
+
{
|
|
1923
|
+
className: "pin-menu",
|
|
1924
|
+
"data-part": "pin-menu",
|
|
1925
|
+
role: "menu",
|
|
1926
|
+
"aria-label": "Pin options",
|
|
1927
|
+
"aria-hidden": !pinMenuOpen,
|
|
1928
|
+
children: [
|
|
1929
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1930
|
+
"button",
|
|
1931
|
+
{
|
|
1932
|
+
type: "button",
|
|
1933
|
+
className: "pin-menu-action",
|
|
1934
|
+
"data-part": "pin-left-action",
|
|
1935
|
+
role: "menuitem",
|
|
1936
|
+
"aria-label": labels.pinLeft,
|
|
1937
|
+
title: labels.pinLeft,
|
|
1938
|
+
tabIndex: pinMenuOpen ? 0 : -1,
|
|
1939
|
+
onClick: (event) => choosePinDirection(column, "left", event),
|
|
1940
|
+
children: [
|
|
1941
|
+
/* @__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" }) }),
|
|
1942
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "sr-only ui-grid-sr-only", children: labels.pinLeft })
|
|
1943
|
+
]
|
|
1944
|
+
}
|
|
1945
|
+
),
|
|
1946
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1947
|
+
"button",
|
|
1948
|
+
{
|
|
1949
|
+
type: "button",
|
|
1950
|
+
className: "pin-menu-action",
|
|
1951
|
+
"data-part": "pin-right-action",
|
|
1952
|
+
role: "menuitem",
|
|
1953
|
+
"aria-label": labels.pinRight,
|
|
1954
|
+
title: labels.pinRight,
|
|
1955
|
+
tabIndex: pinMenuOpen ? 0 : -1,
|
|
1956
|
+
onClick: (event) => choosePinDirection(column, "right", event),
|
|
1957
|
+
children: [
|
|
1958
|
+
/* @__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" }) }),
|
|
1959
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "sr-only ui-grid-sr-only", children: labels.pinRight })
|
|
1960
|
+
]
|
|
1961
|
+
}
|
|
1962
|
+
)
|
|
1963
|
+
]
|
|
1964
|
+
}
|
|
1965
|
+
)
|
|
1966
|
+
]
|
|
1967
|
+
}
|
|
1968
|
+
)
|
|
1850
1969
|
] })
|
|
1851
1970
|
]
|
|
1852
1971
|
},
|
|
@@ -1861,7 +1980,10 @@ function UiGrid({
|
|
|
1861
1980
|
className: "filter-grid ui-grid-header",
|
|
1862
1981
|
"data-part": "filters",
|
|
1863
1982
|
ref: filterGridRef,
|
|
1864
|
-
style: {
|
|
1983
|
+
style: {
|
|
1984
|
+
gridTemplateColumns,
|
|
1985
|
+
["--ui-grid-header-sticky-top"]: `${headerStickyHeight}px`
|
|
1986
|
+
},
|
|
1865
1987
|
children: visibleColumns.map((column) => {
|
|
1866
1988
|
const pinned = state.isPinned(column);
|
|
1867
1989
|
const pinOffset = pinned ? state.pinnedOffset(column) : null;
|
|
@@ -1900,21 +2022,28 @@ function UiGrid({
|
|
|
1900
2022
|
})
|
|
1901
2023
|
}
|
|
1902
2024
|
),
|
|
1903
|
-
displayItems.length > 0 ? virtualizationEnabled ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
2025
|
+
displayItems.length > 0 ? virtualizationEnabled ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1904
2026
|
"div",
|
|
1905
2027
|
{
|
|
1906
|
-
className: "
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
2028
|
+
className: "grid-virtual-spacer",
|
|
2029
|
+
style: { height: `${virtualScroll.totalHeight}px` },
|
|
2030
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
2031
|
+
"div",
|
|
2032
|
+
{
|
|
2033
|
+
className: "body-grid ui-grid-canvas grid-virtual-body",
|
|
2034
|
+
"data-part": "body",
|
|
2035
|
+
role: "rowgroup",
|
|
2036
|
+
style: {
|
|
2037
|
+
gridTemplateColumns,
|
|
2038
|
+
position: "absolute",
|
|
2039
|
+
top: `${virtualScroll.offsetY}px`,
|
|
2040
|
+
left: 0
|
|
2041
|
+
},
|
|
2042
|
+
children: itemsToRender.map(renderDisplayItem)
|
|
2043
|
+
}
|
|
2044
|
+
)
|
|
1916
2045
|
}
|
|
1917
|
-
)
|
|
2046
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1918
2047
|
"div",
|
|
1919
2048
|
{
|
|
1920
2049
|
className: "body-grid ui-grid-canvas",
|
|
@@ -2026,12 +2155,31 @@ function mountUiGrid(container, props) {
|
|
|
2026
2155
|
return root;
|
|
2027
2156
|
}
|
|
2028
2157
|
|
|
2158
|
+
// src/vanillaAdapter.ts
|
|
2159
|
+
async function mountUiGridCustomElement(container, mountOptions) {
|
|
2160
|
+
const tagName = mountOptions.tagName ?? "ui-grid-element";
|
|
2161
|
+
if (mountOptions.ensureDefined) {
|
|
2162
|
+
await mountOptions.ensureDefined(tagName);
|
|
2163
|
+
}
|
|
2164
|
+
const element = document.createElement(tagName);
|
|
2165
|
+
element.options = mountOptions.options;
|
|
2166
|
+
container.replaceChildren(element);
|
|
2167
|
+
return {
|
|
2168
|
+
element,
|
|
2169
|
+
unmount: () => {
|
|
2170
|
+
if (container.firstElementChild === element) {
|
|
2171
|
+
container.replaceChildren();
|
|
2172
|
+
}
|
|
2173
|
+
}
|
|
2174
|
+
};
|
|
2175
|
+
}
|
|
2176
|
+
|
|
2029
2177
|
// src/rustWasmGridEngine.ts
|
|
2030
|
-
var
|
|
2178
|
+
var import_ui_grid_core3 = require("@ornery/ui-grid-core");
|
|
2031
2179
|
var uiGridWasmModulePath = "../../../dist/ui-grid-wasm-web/ui_grid_wasm.js";
|
|
2032
2180
|
var uiGridWasmBinaryPath = "/dist/ui-grid-wasm-web/ui_grid_wasm_bg.wasm";
|
|
2033
2181
|
function registerReactUiGridWasmEngineFromModule(module2) {
|
|
2034
|
-
(0,
|
|
2182
|
+
(0, import_ui_grid_core3.registerRustWasmGridEngine)({
|
|
2035
2183
|
buildPipeline(context) {
|
|
2036
2184
|
return module2.build_pipeline_js(context);
|
|
2037
2185
|
}
|
|
@@ -2047,7 +2195,7 @@ async function enableReactUiGridWasmEngine() {
|
|
|
2047
2195
|
}
|
|
2048
2196
|
|
|
2049
2197
|
// src/index.ts
|
|
2050
|
-
var
|
|
2198
|
+
var import_ui_grid_core4 = require("@ornery/ui-grid-core");
|
|
2051
2199
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2052
2200
|
0 && (module.exports = {
|
|
2053
2201
|
DEFAULT_GRID_LABELS,
|
|
@@ -2058,6 +2206,7 @@ var import_ui_grid4 = require("@ornery/ui-grid");
|
|
|
2058
2206
|
enableReactUiGridWasmEngine,
|
|
2059
2207
|
formatPaginationSummary,
|
|
2060
2208
|
mountUiGrid,
|
|
2209
|
+
mountUiGridCustomElement,
|
|
2061
2210
|
orderVisibleColumns,
|
|
2062
2211
|
registerReactUiGridWasmEngineFromModule,
|
|
2063
2212
|
resolveBenchmarkIterations,
|