@gridkitjs/core 0.0.0-dev-20261109133348 → 0.0.0-dev-20261112192401
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/index.d.ts +21 -14
- package/dist/index.js +229 -214
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -2572,11 +2572,10 @@ interface ResolvedGroupSummaryRow {
|
|
|
2572
2572
|
readonly aggregates: AggregateResults;
|
|
2573
2573
|
}
|
|
2574
2574
|
/**
|
|
2575
|
-
* One entry of a grouped result:
|
|
2576
|
-
*
|
|
2577
|
-
*
|
|
2578
|
-
*
|
|
2579
|
-
* Discriminate with `"kind" in entry`, then `entry.kind`.
|
|
2575
|
+
* One entry of a grouped result: a data row (`kind: "data"`), a group header
|
|
2576
|
+
* (`kind: "group"`), or — only when `groupAggregateDisplay: "row"` is
|
|
2577
|
+
* active — that group's own summary row (`kind: "group-summary"`).
|
|
2578
|
+
* Discriminate with `entry.kind`.
|
|
2580
2579
|
*/
|
|
2581
2580
|
type DisplayRow<Row> = ResolvedRow<Row> | ResolvedGroupRow | ResolvedGroupSummaryRow;
|
|
2582
2581
|
/** A reducer this package computes without a custom `AggregateFn`. */
|
|
@@ -2830,6 +2829,7 @@ interface SelectionDiff {
|
|
|
2830
2829
|
* itself rather than an id it has to look up.
|
|
2831
2830
|
*/
|
|
2832
2831
|
interface ResolvedRow<Row> {
|
|
2832
|
+
readonly kind: "data";
|
|
2833
2833
|
readonly rowId: string;
|
|
2834
2834
|
readonly row: Row;
|
|
2835
2835
|
/** Position among the rows as rendered, matching `CellTemplateContext`. */
|
|
@@ -3295,16 +3295,17 @@ declare function buildKeyShortcuts(capabilities: KeyShortcutCapabilities): strin
|
|
|
3295
3295
|
declare function accessDotted(obj: unknown, path: string): unknown;
|
|
3296
3296
|
|
|
3297
3297
|
/**
|
|
3298
|
-
* The
|
|
3299
|
-
*
|
|
3300
|
-
* of its own, and every other move is plain arithmetic.
|
|
3298
|
+
* The cell the grid's single tab stop sits on: a header cell, or a cell of
|
|
3299
|
+
* body row `rowIndex`. A body focus's `rowIndex` counts from `0`.
|
|
3301
3300
|
*/
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3301
|
+
type GridFocus = {
|
|
3302
|
+
readonly area: "header";
|
|
3303
|
+
readonly columnIndex: number;
|
|
3304
|
+
} | {
|
|
3305
|
+
readonly area: "body";
|
|
3305
3306
|
readonly rowIndex: number;
|
|
3306
3307
|
readonly columnIndex: number;
|
|
3307
|
-
}
|
|
3308
|
+
};
|
|
3308
3309
|
/** The modifier keys held with a navigation key press. */
|
|
3309
3310
|
interface NavigationModifiers {
|
|
3310
3311
|
readonly ctrlKey: boolean;
|
|
@@ -3312,10 +3313,16 @@ interface NavigationModifiers {
|
|
|
3312
3313
|
readonly altKey: boolean;
|
|
3313
3314
|
readonly shiftKey: boolean;
|
|
3314
3315
|
}
|
|
3316
|
+
/** The header's cell at `columnIndex`. */
|
|
3317
|
+
declare function headerFocus(columnIndex: number): GridFocus;
|
|
3318
|
+
/** Body row `rowIndex`'s cell at `columnIndex`. */
|
|
3319
|
+
declare function bodyFocus(rowIndex: number, columnIndex: number): GridFocus;
|
|
3315
3320
|
/**
|
|
3316
3321
|
* Holds a coordinate inside the grid, so that a focus surviving a column
|
|
3317
3322
|
* removal or a shorter page never leaves the grid with no tab stop at all —
|
|
3318
|
-
* which is a grid a keyboard cannot reach.
|
|
3323
|
+
* which is a grid a keyboard cannot reach. A body focus below the last row
|
|
3324
|
+
* moves up to it; one above the first row, or in a grid with no rows, moves
|
|
3325
|
+
* to the header.
|
|
3319
3326
|
*/
|
|
3320
3327
|
declare function clampFocus(focus: GridFocus, rowCount: number, columnCount: number): GridFocus;
|
|
3321
3328
|
/**
|
|
@@ -4416,4 +4423,4 @@ declare const excelFilter: {
|
|
|
4416
4423
|
};
|
|
4417
4424
|
};
|
|
4418
4425
|
|
|
4419
|
-
export { ALL_COLLAPSED, ALL_EXPANDED, type AggregateFn, type AggregateResults, type AggregateSpec, type AggregateState, type Borders, type BuiltInAggregate, type BuiltInCommandIcon, type BuiltInCommandId, type CellSelectEvent, type CellSelectionChangeEvent, type CellSelectionMode, type CellSelectionState, type CellTemplateContext, type ColumnAlignment, type ColumnChooserEntry, type ColumnChooserInput, type ColumnChooserModel, type ColumnChooserToggle, type ColumnConstraints, type ColumnDefinition, type ColumnFilterMenuOptions, type ColumnFilterShape, type ColumnOrderEvent, type ColumnOrderState, type ColumnResizeEvent, type ColumnResizeSession, type ColumnResolveOptions, type ColumnSelectEvent, type ColumnSelectionChangeEvent, type ColumnSizeDefaults, type ColumnSizingState, type ColumnSortEntry, type ColumnSortEvent, type ColumnSortState, type ColumnType, type ColumnValueCacheQuery, type ColumnValueOption, type ColumnValueOptions, type ColumnValueOptionsCache, type ColumnValueQuery, type ColumnVisibilityEvent, type ColumnVisibilityState, type ColumnWrapConfig, type ColumnsSelectEvent, type ConditionRowDraft, type ConditionsDraft, type ContextMenuOpenChangeEvent, type CopyContent, type CopyRequest, type CopySource, type CsvOptions, DEFAULT_COLUMN_SIZES, DEFAULT_FILTER_VALUE_LIMIT, type DataColumn, type DisplayRow, type DropSide, type ExportCell, type ExportColumn, type ExportDataRow, type ExportFile, type ExportFileSource, type ExportGroupRow, type ExportGroupSummaryRow, type ExportOptions, type ExportRow, type ExportScalar, type ExportSource, type ExportTable, type ExportTotalRow, type ExportWriteContext, type ExportWriter, type FieldPath, type FilterChangeEvent, type FilterChecklist, type FilterChecklistItem, type FilterChecklistOptions, type FilterEditorAction, type FilterEditorDraft, type FilterEditorDraftBase, type FilterEntry, type FilterMenuUi, type FilterOperator, type FilterOperatorFamily, type FilterPredicate, type FilterScalar, type FilterState, type FooterTemplateContext, type FormatLocale, type GridCommand, type GridCommandActions, type GridCommandContext, type GridCommandContextInput, type GridCommandEvent, type GridCommandHost, type GridCommandSource, type GridCommandTarget, type GridContextMenuArea, type GridContextMenuEntries, type GridContextMenuOptions, type GridContextMenuRequest, type GridContextMenuTarget, type GridController, type GridControllerOptions, type GridExportOptions, type GridFilterMenuOptions, type GridFocus, type GridMessages, type GridOptions, type GridPanelKind, type GridState, type GridToolbarOptions, type GridToolbarTarget, type GridView, type GridViewInput, type GridViewOptions, type GridViewState, type GroupAggregateDisplay, type GroupByBarVisibility, type GroupByEntry, type GroupByEvent, type GroupByState, type GroupExpansionEvent, type GroupExpansionState, type GroupFilterEntry,
|
|
4426
|
+
export { ALL_COLLAPSED, ALL_EXPANDED, type AggregateFn, type AggregateResults, type AggregateSpec, type AggregateState, type Borders, type BuiltInAggregate, type BuiltInCommandIcon, type BuiltInCommandId, type CellSelectEvent, type CellSelectionChangeEvent, type CellSelectionMode, type CellSelectionState, type CellTemplateContext, type ColumnAlignment, type ColumnChooserEntry, type ColumnChooserInput, type ColumnChooserModel, type ColumnChooserToggle, type ColumnConstraints, type ColumnDefinition, type ColumnFilterMenuOptions, type ColumnFilterShape, type ColumnOrderEvent, type ColumnOrderState, type ColumnResizeEvent, type ColumnResizeSession, type ColumnResolveOptions, type ColumnSelectEvent, type ColumnSelectionChangeEvent, type ColumnSizeDefaults, type ColumnSizingState, type ColumnSortEntry, type ColumnSortEvent, type ColumnSortState, type ColumnType, type ColumnValueCacheQuery, type ColumnValueOption, type ColumnValueOptions, type ColumnValueOptionsCache, type ColumnValueQuery, type ColumnVisibilityEvent, type ColumnVisibilityState, type ColumnWrapConfig, type ColumnsSelectEvent, type ConditionRowDraft, type ConditionsDraft, type ContextMenuOpenChangeEvent, type CopyContent, type CopyRequest, type CopySource, type CsvOptions, DEFAULT_COLUMN_SIZES, DEFAULT_FILTER_VALUE_LIMIT, type DataColumn, type DisplayRow, type DropSide, type ExportCell, type ExportColumn, type ExportDataRow, type ExportFile, type ExportFileSource, type ExportGroupRow, type ExportGroupSummaryRow, type ExportOptions, type ExportRow, type ExportScalar, type ExportSource, type ExportTable, type ExportTotalRow, type ExportWriteContext, type ExportWriter, type FieldPath, type FilterChangeEvent, type FilterChecklist, type FilterChecklistItem, type FilterChecklistOptions, type FilterEditorAction, type FilterEditorDraft, type FilterEditorDraftBase, type FilterEntry, type FilterMenuUi, type FilterOperator, type FilterOperatorFamily, type FilterPredicate, type FilterScalar, type FilterState, type FooterTemplateContext, type FormatLocale, type GridCommand, type GridCommandActions, type GridCommandContext, type GridCommandContextInput, type GridCommandEvent, type GridCommandHost, type GridCommandSource, type GridCommandTarget, type GridContextMenuArea, type GridContextMenuEntries, type GridContextMenuOptions, type GridContextMenuRequest, type GridContextMenuTarget, type GridController, type GridControllerOptions, type GridExportOptions, type GridFilterMenuOptions, type GridFocus, type GridMessages, type GridOptions, type GridPanelKind, type GridState, type GridToolbarOptions, type GridToolbarTarget, type GridView, type GridViewInput, type GridViewOptions, type GridViewState, type GroupAggregateDisplay, type GroupByBarVisibility, type GroupByEntry, type GroupByEvent, type GroupByState, type GroupExpansionEvent, type GroupExpansionState, type GroupFilterEntry, type HoverableConfig, type HtmlTableOptions, type JsonOptions, KEYBOARD_STEP, type KeyShortcutCapabilities, type MenuEntry, type MenuItemEntry, type MenuMove, type MenuResolveOptions, type MenuSubmenuEntry, type NavigationModifiers, type OperatorFilterEntry, type PaginateRowsOptions, type PaginatedRows, type PaginationChangeEvent, type PaginationState, type PaginationUnit, type PaginationWindowEntry, type ParsedConditionRows, type PredicateFilterEntry, type PrintDocument, type PrintOptions, type PrintOrientation, type PrintPage, type PrintSource, type ResizeMode, type ResolvedColumn, type ResolvedColumnFilterMenu, type ResolvedGroupRow, type ResolvedGroupSummaryRow, type ResolvedMenuEntry, type ResolvedMenuItem, type ResolvedMenuSeparator, type ResolvedMenuSubmenu, type ResolvedRow, type ResolvedToolbarButton, type ResolvedToolbarCustom, type ResolvedToolbarItem, type ResolvedToolbarMenu, type ResolvedToolbarSearch, type ResolvedToolbarSpacer, type RowHeights, type RowPointerEvent, type RowProps, type RowSelectEvent, type RowSelectionChangeEvent, type RowsSelectEvent, type SelectAllState, type SelectIntent, type SelectableConfig, type SelectedCell, type SelectedCellRef, type SelectedColumn, type SelectionCallbacks, type SelectionDiff, type SelectionDiffEvent, type SelectionMode, type SelectionState, type SerializedFilterEntry, type SerializedFilterScalar, type SerializedFilterState, type SerializedGridState, type SerializedGroupFilterEntry, type SerializedOperatorFilterEntry, type SerializedValueFilterEntry, type SortDirection, type TextFilterEntry, type ToolbarCustomEntry, type ToolbarEntry, type ToolbarFitInput, type ToolbarItemAttributes, type ToolbarResolveOptions, type ToolbarSplit, type TsvOptions, type ValueFilterEntry, type ValuesDraft, type VisibleRange, accessDotted, alignmentForType, applyColumnOrder, applyColumnResize, applyColumnVisibility, applySelectionIntent, beginColumnResize, bodyFocus, buildExportTable, buildKeyShortcuts, buildPrintDocument, builtInCommands, clampColumnWidth, clampFocus, clearAllFilters, clearSelection, collapseAllGroups, columnValueOptions, compareValues, computeAggregates, conditionRowsFrom, conditionsFromRows, contextMenuEntries, copyContent, createColumnValueOptionsCache, createCommandContext, createDefaultMessages, createGridController, createGridViewResolver, csvWriter, defaultContextMenu, defaultFilterOperators, defaultMessages, defaultToolbar, defineColumnsFromRows, describeColumnFilter, diffSelection, draftToFilter, excelFilter, expandAllGroups, exportFile, exportPrintDocument, filterChecklist, filterDraftChanged, filterEditorReducer, filterOperandArity, filterOperatorFamily, filterQueryFor, filterRows, fitColumnsToWidth, fitToolbarItems, formatAggregateValue, formatCellValue, formatFilterOperand, formatGroupValue, getColumnId, groupRowId, groupRows, hasContextMenu, headerFocus, initialFilterEditorDraft, intentOf, isColumnFiltered, isColumnVisible, isGroupExpanded, isPinnedToolbarItem, isSameCell, jsonWriter, matchesQuery, moveColumnBefore, moveGroupByBefore, movesColumn, movesGroupBy, nextFocusForKey, nextMenuIndex, paginateRows, paginationWindow, parseFilterOperand, resolveCell, resolveColumnChooser, resolveColumnConstraints, resolveColumnFilterMenu, resolveColumnHeaderText, resolveColumnLabel, resolveColumnWidths, resolveColumns, resolveCommands, resolveDataColumns, resolveDropBefore, resolveExportWriters, resolveGridView, resolveKeyboardDropTarget, resolveMenu, resolveMessages, resolveRowId, resolveRows, resolveShownRows, resolveToolbar, revertColumnSize, runCommand, searchTextOf, selectAll, selectAllState, selectCell, selectOnly, selectRange, serializeGridState, setColumnFilter, setColumnVisibility, setSearchText, sizeColumnToContent, sortDirectionFor, sortPriorityFor, sortRows, splitToolbarItems, toConditionsDraft, toCsv, toHtmlTable, toJson, toTsv, toValuesDraft, toggleCellSelection, toggleColumnSort, toggleGroupExpansion, toggleSelection, toolbarEntries, totalColumnWidth, typeaheadIndex, visibleFilterOptions, visibleRange, withGroupAggregates };
|
package/dist/index.js
CHANGED
|
@@ -424,85 +424,6 @@ function resolveKeyboardDropTarget(orderedIds, columnId, direction) {
|
|
|
424
424
|
return orderedIds[targetIndex] ?? null;
|
|
425
425
|
}
|
|
426
426
|
|
|
427
|
-
// src/util/paging.ts
|
|
428
|
-
var NO_HEADERS = [];
|
|
429
|
-
function groupUnitsOf(rows) {
|
|
430
|
-
const units = [];
|
|
431
|
-
let start = 0;
|
|
432
|
-
let openedByGroup = false;
|
|
433
|
-
for (let index = 0; index < rows.length; index++) {
|
|
434
|
-
const entry = rows[index];
|
|
435
|
-
if (entry === void 0) {
|
|
436
|
-
continue;
|
|
437
|
-
}
|
|
438
|
-
const isTopLevelHeader = "kind" in entry && entry.kind === "group" && entry.level === 0;
|
|
439
|
-
const isBoundary = index !== start && (isTopLevelHeader || !openedByGroup);
|
|
440
|
-
if (isBoundary) {
|
|
441
|
-
units.push({ start, end: index, headers: NO_HEADERS });
|
|
442
|
-
start = index;
|
|
443
|
-
openedByGroup = isTopLevelHeader;
|
|
444
|
-
} else if (index === start) {
|
|
445
|
-
openedByGroup = isTopLevelHeader;
|
|
446
|
-
}
|
|
447
|
-
}
|
|
448
|
-
if (start < rows.length) {
|
|
449
|
-
units.push({ start, end: rows.length, headers: NO_HEADERS });
|
|
450
|
-
}
|
|
451
|
-
return units;
|
|
452
|
-
}
|
|
453
|
-
function rowUnitsOf(rows) {
|
|
454
|
-
const units = [];
|
|
455
|
-
let open = NO_HEADERS;
|
|
456
|
-
for (let index = 0; index < rows.length; index++) {
|
|
457
|
-
const entry = rows[index];
|
|
458
|
-
if (entry === void 0) {
|
|
459
|
-
continue;
|
|
460
|
-
}
|
|
461
|
-
if (!("kind" in entry)) {
|
|
462
|
-
units.push({ start: index, end: index + 1, headers: open });
|
|
463
|
-
} else if (entry.kind === "group") {
|
|
464
|
-
const ancestors = open.slice(0, entry.level);
|
|
465
|
-
open = entry.expanded ? [...ancestors, entry] : ancestors;
|
|
466
|
-
if (!entry.expanded) {
|
|
467
|
-
units.push({ start: index, end: index + 1, headers: ancestors });
|
|
468
|
-
}
|
|
469
|
-
} else {
|
|
470
|
-
const last = units.at(-1);
|
|
471
|
-
if (last !== void 0) {
|
|
472
|
-
units[units.length - 1] = { ...last, end: index + 1 };
|
|
473
|
-
}
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
|
-
return units;
|
|
477
|
-
}
|
|
478
|
-
function paginateRows(rows, pagination, options = {}) {
|
|
479
|
-
const pageSize = Math.max(1, pagination.pageSize);
|
|
480
|
-
const units = options.unit === "row" ? rowUnitsOf(rows) : groupUnitsOf(rows);
|
|
481
|
-
const pageCount = Math.ceil(units.length / pageSize);
|
|
482
|
-
if (pageCount === 0) {
|
|
483
|
-
return { rows: [], pageCount: 0, pageIndex: 0 };
|
|
484
|
-
}
|
|
485
|
-
const pageIndex = Math.min(Math.max(pagination.pageIndex, 0), pageCount - 1);
|
|
486
|
-
const firstUnit = units[pageIndex * pageSize];
|
|
487
|
-
const lastUnit = units[Math.min(pageIndex * pageSize + pageSize, units.length) - 1];
|
|
488
|
-
if (firstUnit === void 0 || lastUnit === void 0) {
|
|
489
|
-
return { rows: [], pageCount, pageIndex };
|
|
490
|
-
}
|
|
491
|
-
const page = [
|
|
492
|
-
...firstUnit.headers,
|
|
493
|
-
...rows.slice(firstUnit.start, lastUnit.end)
|
|
494
|
-
];
|
|
495
|
-
const renumbered = page.map(
|
|
496
|
-
(entry, index) => entry.rowIndex === index ? entry : { ...entry, rowIndex: index }
|
|
497
|
-
);
|
|
498
|
-
return { rows: renumbered, pageCount, pageIndex };
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
// src/util/report.ts
|
|
502
|
-
function reportError(message) {
|
|
503
|
-
console.error(`GridKit: ${message}`);
|
|
504
|
-
}
|
|
505
|
-
|
|
506
427
|
// src/util/filterOperators.ts
|
|
507
428
|
var matchNothing = () => false;
|
|
508
429
|
function kindOf(type) {
|
|
@@ -833,6 +754,136 @@ function filterRows(rows, filter, columns) {
|
|
|
833
754
|
return renumberRows(filtered);
|
|
834
755
|
}
|
|
835
756
|
|
|
757
|
+
// src/util/rows.ts
|
|
758
|
+
function resolveShownRows(rows, filter, sort, columns) {
|
|
759
|
+
return sortRows(filterRows(rows, filter, columns), sort, columns);
|
|
760
|
+
}
|
|
761
|
+
function unknownDisplayRow(entry) {
|
|
762
|
+
const { kind } = entry;
|
|
763
|
+
throw new TypeError(
|
|
764
|
+
`GridKit: \`${String(kind)}\` is not a display row kind.`
|
|
765
|
+
);
|
|
766
|
+
}
|
|
767
|
+
function resolveRows(rowsById, ids) {
|
|
768
|
+
return ids.map((id) => rowsById.get(id)).filter((row) => row !== void 0);
|
|
769
|
+
}
|
|
770
|
+
function resolveColumns(columns, ids) {
|
|
771
|
+
return ids.map((id) => {
|
|
772
|
+
const columnIndex = columns.findIndex((entry) => entry.id === id);
|
|
773
|
+
const column = columns[columnIndex];
|
|
774
|
+
return column === void 0 ? void 0 : { columnId: id, column, columnIndex };
|
|
775
|
+
}).filter((column) => column !== void 0);
|
|
776
|
+
}
|
|
777
|
+
function resolveCell(rowsById, columns, cell) {
|
|
778
|
+
if (cell === null) {
|
|
779
|
+
return null;
|
|
780
|
+
}
|
|
781
|
+
const entry = rowsById.get(cell.rowId);
|
|
782
|
+
const columnIndex = columns.findIndex(
|
|
783
|
+
(candidate) => candidate.id === cell.columnId
|
|
784
|
+
);
|
|
785
|
+
const column = columns[columnIndex];
|
|
786
|
+
if (entry === void 0 || column === void 0) {
|
|
787
|
+
return null;
|
|
788
|
+
}
|
|
789
|
+
return {
|
|
790
|
+
rowId: cell.rowId,
|
|
791
|
+
columnId: cell.columnId,
|
|
792
|
+
row: entry.row,
|
|
793
|
+
column,
|
|
794
|
+
rowIndex: entry.rowIndex,
|
|
795
|
+
columnIndex,
|
|
796
|
+
value: accessDotted(entry.row, column.column.field)
|
|
797
|
+
};
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
// src/util/paging.ts
|
|
801
|
+
var NO_HEADERS = [];
|
|
802
|
+
function groupUnitsOf(rows) {
|
|
803
|
+
const units = [];
|
|
804
|
+
let start = 0;
|
|
805
|
+
let openedByGroup = false;
|
|
806
|
+
for (let index = 0; index < rows.length; index++) {
|
|
807
|
+
const entry = rows[index];
|
|
808
|
+
if (entry === void 0) {
|
|
809
|
+
continue;
|
|
810
|
+
}
|
|
811
|
+
const isTopLevelHeader = entry.kind === "group" && entry.level === 0;
|
|
812
|
+
const isBoundary = index !== start && (isTopLevelHeader || !openedByGroup);
|
|
813
|
+
if (isBoundary) {
|
|
814
|
+
units.push({ start, end: index, headers: NO_HEADERS });
|
|
815
|
+
start = index;
|
|
816
|
+
openedByGroup = isTopLevelHeader;
|
|
817
|
+
} else if (index === start) {
|
|
818
|
+
openedByGroup = isTopLevelHeader;
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
if (start < rows.length) {
|
|
822
|
+
units.push({ start, end: rows.length, headers: NO_HEADERS });
|
|
823
|
+
}
|
|
824
|
+
return units;
|
|
825
|
+
}
|
|
826
|
+
function rowUnitsOf(rows) {
|
|
827
|
+
const units = [];
|
|
828
|
+
let open = NO_HEADERS;
|
|
829
|
+
for (let index = 0; index < rows.length; index++) {
|
|
830
|
+
const entry = rows[index];
|
|
831
|
+
if (entry === void 0) {
|
|
832
|
+
continue;
|
|
833
|
+
}
|
|
834
|
+
switch (entry.kind) {
|
|
835
|
+
case "data":
|
|
836
|
+
units.push({ start: index, end: index + 1, headers: open });
|
|
837
|
+
break;
|
|
838
|
+
case "group": {
|
|
839
|
+
const ancestors = open.slice(0, entry.level);
|
|
840
|
+
open = entry.expanded ? [...ancestors, entry] : ancestors;
|
|
841
|
+
if (!entry.expanded) {
|
|
842
|
+
units.push({ start: index, end: index + 1, headers: ancestors });
|
|
843
|
+
}
|
|
844
|
+
break;
|
|
845
|
+
}
|
|
846
|
+
case "group-summary": {
|
|
847
|
+
const last = units.at(-1);
|
|
848
|
+
if (last !== void 0) {
|
|
849
|
+
units[units.length - 1] = { ...last, end: index + 1 };
|
|
850
|
+
}
|
|
851
|
+
break;
|
|
852
|
+
}
|
|
853
|
+
default:
|
|
854
|
+
unknownDisplayRow(entry);
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
return units;
|
|
858
|
+
}
|
|
859
|
+
function paginateRows(rows, pagination, options = {}) {
|
|
860
|
+
const pageSize = Math.max(1, pagination.pageSize);
|
|
861
|
+
const units = options.unit === "row" ? rowUnitsOf(rows) : groupUnitsOf(rows);
|
|
862
|
+
const pageCount = Math.ceil(units.length / pageSize);
|
|
863
|
+
if (pageCount === 0) {
|
|
864
|
+
return { rows: [], pageCount: 0, pageIndex: 0 };
|
|
865
|
+
}
|
|
866
|
+
const pageIndex = Math.min(Math.max(pagination.pageIndex, 0), pageCount - 1);
|
|
867
|
+
const firstUnit = units[pageIndex * pageSize];
|
|
868
|
+
const lastUnit = units[Math.min(pageIndex * pageSize + pageSize, units.length) - 1];
|
|
869
|
+
if (firstUnit === void 0 || lastUnit === void 0) {
|
|
870
|
+
return { rows: [], pageCount, pageIndex };
|
|
871
|
+
}
|
|
872
|
+
const page = [
|
|
873
|
+
...firstUnit.headers,
|
|
874
|
+
...rows.slice(firstUnit.start, lastUnit.end)
|
|
875
|
+
];
|
|
876
|
+
const renumbered = page.map(
|
|
877
|
+
(entry, index) => entry.rowIndex === index ? entry : { ...entry, rowIndex: index }
|
|
878
|
+
);
|
|
879
|
+
return { rows: renumbered, pageCount, pageIndex };
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
// src/util/report.ts
|
|
883
|
+
function reportError(message) {
|
|
884
|
+
console.error(`GridKit: ${message}`);
|
|
885
|
+
}
|
|
886
|
+
|
|
836
887
|
// src/util/serialize.ts
|
|
837
888
|
function serializeScalar(scalar) {
|
|
838
889
|
return scalar instanceof Date ? scalar.toISOString() : scalar;
|
|
@@ -1207,11 +1258,11 @@ function appendAggregatedSpan(displayRows, start, levelFloor, flatRows, groupBy,
|
|
|
1207
1258
|
index++;
|
|
1208
1259
|
continue;
|
|
1209
1260
|
}
|
|
1210
|
-
if (levelFloor !== null &&
|
|
1261
|
+
if (levelFloor !== null && entry.kind === "group" && entry.level <= levelFloor) {
|
|
1211
1262
|
break;
|
|
1212
1263
|
}
|
|
1213
1264
|
index++;
|
|
1214
|
-
if (
|
|
1265
|
+
if (entry.kind !== "group") {
|
|
1215
1266
|
out.push(entry);
|
|
1216
1267
|
continue;
|
|
1217
1268
|
}
|
|
@@ -1266,43 +1317,6 @@ function withGroupAggregates(displayRows, flatRows, groupBy, specs, columns, dis
|
|
|
1266
1317
|
return renumberRows(out);
|
|
1267
1318
|
}
|
|
1268
1319
|
|
|
1269
|
-
// src/util/rows.ts
|
|
1270
|
-
function resolveShownRows(rows, filter, sort, columns) {
|
|
1271
|
-
return sortRows(filterRows(rows, filter, columns), sort, columns);
|
|
1272
|
-
}
|
|
1273
|
-
function resolveRows(rowsById, ids) {
|
|
1274
|
-
return ids.map((id) => rowsById.get(id)).filter((row) => row !== void 0);
|
|
1275
|
-
}
|
|
1276
|
-
function resolveColumns(columns, ids) {
|
|
1277
|
-
return ids.map((id) => {
|
|
1278
|
-
const columnIndex = columns.findIndex((entry) => entry.id === id);
|
|
1279
|
-
const column = columns[columnIndex];
|
|
1280
|
-
return column === void 0 ? void 0 : { columnId: id, column, columnIndex };
|
|
1281
|
-
}).filter((column) => column !== void 0);
|
|
1282
|
-
}
|
|
1283
|
-
function resolveCell(rowsById, columns, cell) {
|
|
1284
|
-
if (cell === null) {
|
|
1285
|
-
return null;
|
|
1286
|
-
}
|
|
1287
|
-
const entry = rowsById.get(cell.rowId);
|
|
1288
|
-
const columnIndex = columns.findIndex(
|
|
1289
|
-
(candidate) => candidate.id === cell.columnId
|
|
1290
|
-
);
|
|
1291
|
-
const column = columns[columnIndex];
|
|
1292
|
-
if (entry === void 0 || column === void 0) {
|
|
1293
|
-
return null;
|
|
1294
|
-
}
|
|
1295
|
-
return {
|
|
1296
|
-
rowId: cell.rowId,
|
|
1297
|
-
columnId: cell.columnId,
|
|
1298
|
-
row: entry.row,
|
|
1299
|
-
column,
|
|
1300
|
-
rowIndex: entry.rowIndex,
|
|
1301
|
-
columnIndex,
|
|
1302
|
-
value: accessDotted(entry.row, column.column.field)
|
|
1303
|
-
};
|
|
1304
|
-
}
|
|
1305
|
-
|
|
1306
1320
|
// src/util/visibility.ts
|
|
1307
1321
|
function isColumnVisible(column, visibility) {
|
|
1308
1322
|
return visibility[getColumnId(column)] ?? column.hidden !== true;
|
|
@@ -1331,6 +1345,7 @@ function setColumnVisibility(columns, visibility, columnIds, visible) {
|
|
|
1331
1345
|
var NO_AGGREGATES = [];
|
|
1332
1346
|
function identifyRows(rows, getRowId) {
|
|
1333
1347
|
return rows.map((row, rowIndex) => ({
|
|
1348
|
+
kind: "data",
|
|
1334
1349
|
rowId: resolveRowId(row, rowIndex, getRowId),
|
|
1335
1350
|
row,
|
|
1336
1351
|
rowIndex,
|
|
@@ -1356,7 +1371,9 @@ function paginate(displayRows, paginated, pagination, unit) {
|
|
|
1356
1371
|
return paginated ? paginateRows(displayRows, pagination, { unit }) : { rows: displayRows, pageCount: 1, pageIndex: 0 };
|
|
1357
1372
|
}
|
|
1358
1373
|
function narrowToDataRows(pageRows, rows, reshaped) {
|
|
1359
|
-
return reshaped ? pageRows.filter(
|
|
1374
|
+
return reshaped ? pageRows.filter(
|
|
1375
|
+
(entry) => entry.kind === "data"
|
|
1376
|
+
) : rows;
|
|
1360
1377
|
}
|
|
1361
1378
|
function createGridViewResolver() {
|
|
1362
1379
|
const identify = memoizeLast(identifyRows);
|
|
@@ -2517,7 +2534,7 @@ function formatGroupValue(value, column, locale, messages) {
|
|
|
2517
2534
|
// src/export/buildExportTable.ts
|
|
2518
2535
|
var EMPTY_CELL = { value: null, text: "" };
|
|
2519
2536
|
function isDataRow(entry) {
|
|
2520
|
-
return
|
|
2537
|
+
return entry.kind === "data";
|
|
2521
2538
|
}
|
|
2522
2539
|
function pickColumns(view, selection) {
|
|
2523
2540
|
let picked;
|
|
@@ -2617,30 +2634,33 @@ function groupLabel(entry, source) {
|
|
|
2617
2634
|
return `${resolveColumnHeaderText(column)}: ${value}`;
|
|
2618
2635
|
}
|
|
2619
2636
|
function toExportRow(entry, source, context) {
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2637
|
+
switch (entry.kind) {
|
|
2638
|
+
case "data":
|
|
2639
|
+
return {
|
|
2640
|
+
kind: "data",
|
|
2641
|
+
rowId: entry.rowId,
|
|
2642
|
+
cells: context.columns.map(
|
|
2643
|
+
(column) => dataCell(entry.row, column.column, context)
|
|
2644
|
+
)
|
|
2645
|
+
};
|
|
2646
|
+
case "group":
|
|
2647
|
+
return {
|
|
2648
|
+
kind: "group",
|
|
2649
|
+
level: entry.level,
|
|
2650
|
+
groupId: entry.groupId,
|
|
2651
|
+
label: groupLabel(entry, source),
|
|
2652
|
+
count: entry.count,
|
|
2653
|
+
cells: context.display === "inline" ? aggregateCells(entry.aggregates, context) : context.columns.map(() => EMPTY_CELL)
|
|
2654
|
+
};
|
|
2655
|
+
case "group-summary":
|
|
2656
|
+
return {
|
|
2657
|
+
kind: "groupSummary",
|
|
2658
|
+
level: entry.level,
|
|
2659
|
+
cells: aggregateCells(entry.aggregates, context)
|
|
2660
|
+
};
|
|
2661
|
+
default:
|
|
2662
|
+
return unknownDisplayRow(entry);
|
|
2638
2663
|
}
|
|
2639
|
-
return {
|
|
2640
|
-
kind: "groupSummary",
|
|
2641
|
-
level: entry.level,
|
|
2642
|
-
cells: aggregateCells(entry.aggregates, context)
|
|
2643
|
-
};
|
|
2644
2664
|
}
|
|
2645
2665
|
function specsByColumnOf(specs) {
|
|
2646
2666
|
const byColumn = /* @__PURE__ */ new Map();
|
|
@@ -4532,101 +4552,95 @@ function setSearchText(filter, text) {
|
|
|
4532
4552
|
}
|
|
4533
4553
|
|
|
4534
4554
|
// src/util/navigation.ts
|
|
4535
|
-
|
|
4555
|
+
function headerFocus(columnIndex) {
|
|
4556
|
+
return { area: "header", columnIndex };
|
|
4557
|
+
}
|
|
4558
|
+
function bodyFocus(rowIndex, columnIndex) {
|
|
4559
|
+
return { area: "body", rowIndex, columnIndex };
|
|
4560
|
+
}
|
|
4536
4561
|
function clampFocus(focus, rowCount, columnCount2) {
|
|
4537
|
-
|
|
4538
|
-
|
|
4539
|
-
|
|
4540
|
-
|
|
4541
|
-
|
|
4542
|
-
|
|
4543
|
-
|
|
4562
|
+
const columnIndex = Math.min(
|
|
4563
|
+
Math.max(focus.columnIndex, 0),
|
|
4564
|
+
Math.max(columnCount2 - 1, 0)
|
|
4565
|
+
);
|
|
4566
|
+
switch (focus.area) {
|
|
4567
|
+
case "header":
|
|
4568
|
+
return headerFocus(columnIndex);
|
|
4569
|
+
case "body": {
|
|
4570
|
+
const rowIndex = Math.min(focus.rowIndex, rowCount - 1);
|
|
4571
|
+
return rowIndex < 0 ? headerFocus(columnIndex) : bodyFocus(rowIndex, columnIndex);
|
|
4572
|
+
}
|
|
4573
|
+
}
|
|
4544
4574
|
}
|
|
4545
4575
|
function noRowsSkippable() {
|
|
4546
4576
|
return false;
|
|
4547
4577
|
}
|
|
4548
|
-
function
|
|
4549
|
-
|
|
4550
|
-
|
|
4551
|
-
|
|
4552
|
-
|
|
4578
|
+
function linePosition(focus) {
|
|
4579
|
+
return focus.area === "header" ? -1 : focus.rowIndex;
|
|
4580
|
+
}
|
|
4581
|
+
function focusAtLine(line2, columnIndex) {
|
|
4582
|
+
return line2 < 0 ? headerFocus(columnIndex) : bodyFocus(line2, columnIndex);
|
|
4583
|
+
}
|
|
4584
|
+
function skipSkippableRows(target, direction, rowCount, isSkippableRow, fallback) {
|
|
4585
|
+
if (target.area === "header") {
|
|
4586
|
+
return target;
|
|
4587
|
+
}
|
|
4588
|
+
let rowIndex = target.rowIndex;
|
|
4589
|
+
while (rowIndex < rowCount && isSkippableRow(rowIndex)) {
|
|
4590
|
+
const stepped = rowIndex + direction;
|
|
4591
|
+
if (stepped >= rowCount) {
|
|
4553
4592
|
return fallback;
|
|
4554
4593
|
}
|
|
4555
|
-
|
|
4594
|
+
if (stepped < 0) {
|
|
4595
|
+
return headerFocus(target.columnIndex);
|
|
4596
|
+
}
|
|
4597
|
+
rowIndex = stepped;
|
|
4556
4598
|
}
|
|
4557
|
-
return
|
|
4599
|
+
return bodyFocus(rowIndex, target.columnIndex);
|
|
4558
4600
|
}
|
|
4559
4601
|
function nextFocusForKey(key, modifiers, focus, rowCount, columnCount2, pageSize, isSkippableRow = noRowsSkippable) {
|
|
4560
4602
|
if (modifiers.altKey) {
|
|
4561
4603
|
return null;
|
|
4562
4604
|
}
|
|
4563
|
-
const {
|
|
4605
|
+
const { columnIndex } = focus;
|
|
4606
|
+
function moveRows(rows) {
|
|
4607
|
+
return skipSkippableRows(
|
|
4608
|
+
focusAtLine(linePosition(focus) + rows, columnIndex),
|
|
4609
|
+
rows < 0 ? -1 : 1,
|
|
4610
|
+
rowCount,
|
|
4611
|
+
isSkippableRow,
|
|
4612
|
+
focus
|
|
4613
|
+
);
|
|
4614
|
+
}
|
|
4564
4615
|
switch (key) {
|
|
4565
4616
|
case "ArrowLeft":
|
|
4566
4617
|
if (modifiers.ctrlKey) return null;
|
|
4567
|
-
return {
|
|
4618
|
+
return { ...focus, columnIndex: columnIndex - 1 };
|
|
4568
4619
|
case "ArrowRight":
|
|
4569
4620
|
if (modifiers.ctrlKey) return null;
|
|
4570
|
-
return {
|
|
4621
|
+
return { ...focus, columnIndex: columnIndex + 1 };
|
|
4571
4622
|
case "ArrowUp":
|
|
4572
|
-
return
|
|
4573
|
-
rowIndex: skipSkippableRows(
|
|
4574
|
-
rowIndex - 1,
|
|
4575
|
-
-1,
|
|
4576
|
-
rowCount,
|
|
4577
|
-
isSkippableRow,
|
|
4578
|
-
rowIndex
|
|
4579
|
-
),
|
|
4580
|
-
columnIndex
|
|
4581
|
-
};
|
|
4623
|
+
return moveRows(-1);
|
|
4582
4624
|
case "ArrowDown":
|
|
4583
|
-
return
|
|
4584
|
-
rowIndex: skipSkippableRows(
|
|
4585
|
-
rowIndex + 1,
|
|
4586
|
-
1,
|
|
4587
|
-
rowCount,
|
|
4588
|
-
isSkippableRow,
|
|
4589
|
-
rowIndex
|
|
4590
|
-
),
|
|
4591
|
-
columnIndex
|
|
4592
|
-
};
|
|
4625
|
+
return moveRows(1);
|
|
4593
4626
|
// Ctrl takes Home and End to the grid's ends rather than the row's, which
|
|
4594
4627
|
// is the one place Ctrl is navigation rather than reorder.
|
|
4595
4628
|
case "Home":
|
|
4596
|
-
return modifiers.ctrlKey ?
|
|
4597
|
-
case "End":
|
|
4598
|
-
|
|
4599
|
-
|
|
4600
|
-
|
|
4601
|
-
|
|
4602
|
-
|
|
4603
|
-
|
|
4604
|
-
|
|
4605
|
-
|
|
4606
|
-
|
|
4607
|
-
} : { rowIndex, columnIndex: columnCount2 - 1 };
|
|
4629
|
+
return modifiers.ctrlKey ? headerFocus(0) : { ...focus, columnIndex: 0 };
|
|
4630
|
+
case "End": {
|
|
4631
|
+
const rowEnd = { ...focus, columnIndex: columnCount2 - 1 };
|
|
4632
|
+
return modifiers.ctrlKey ? skipSkippableRows(
|
|
4633
|
+
focusAtLine(rowCount - 1, columnCount2 - 1),
|
|
4634
|
+
-1,
|
|
4635
|
+
rowCount,
|
|
4636
|
+
isSkippableRow,
|
|
4637
|
+
rowEnd
|
|
4638
|
+
) : rowEnd;
|
|
4639
|
+
}
|
|
4608
4640
|
case "PageUp":
|
|
4609
|
-
return
|
|
4610
|
-
rowIndex: skipSkippableRows(
|
|
4611
|
-
rowIndex - pageSize,
|
|
4612
|
-
-1,
|
|
4613
|
-
rowCount,
|
|
4614
|
-
isSkippableRow,
|
|
4615
|
-
rowIndex
|
|
4616
|
-
),
|
|
4617
|
-
columnIndex
|
|
4618
|
-
};
|
|
4641
|
+
return moveRows(-pageSize);
|
|
4619
4642
|
case "PageDown":
|
|
4620
|
-
return
|
|
4621
|
-
rowIndex: skipSkippableRows(
|
|
4622
|
-
rowIndex + pageSize,
|
|
4623
|
-
1,
|
|
4624
|
-
rowCount,
|
|
4625
|
-
isSkippableRow,
|
|
4626
|
-
rowIndex
|
|
4627
|
-
),
|
|
4628
|
-
columnIndex
|
|
4629
|
-
};
|
|
4643
|
+
return moveRows(pageSize);
|
|
4630
4644
|
default:
|
|
4631
4645
|
return null;
|
|
4632
4646
|
}
|
|
@@ -4896,7 +4910,6 @@ export {
|
|
|
4896
4910
|
ALL_EXPANDED,
|
|
4897
4911
|
DEFAULT_COLUMN_SIZES,
|
|
4898
4912
|
DEFAULT_FILTER_VALUE_LIMIT,
|
|
4899
|
-
HEADER_ROW,
|
|
4900
4913
|
KEYBOARD_STEP,
|
|
4901
4914
|
accessDotted,
|
|
4902
4915
|
alignmentForType,
|
|
@@ -4905,6 +4918,7 @@ export {
|
|
|
4905
4918
|
applyColumnVisibility,
|
|
4906
4919
|
applySelectionIntent,
|
|
4907
4920
|
beginColumnResize,
|
|
4921
|
+
bodyFocus,
|
|
4908
4922
|
buildExportTable,
|
|
4909
4923
|
buildKeyShortcuts,
|
|
4910
4924
|
buildPrintDocument,
|
|
@@ -4956,6 +4970,7 @@ export {
|
|
|
4956
4970
|
groupRowId,
|
|
4957
4971
|
groupRows,
|
|
4958
4972
|
hasContextMenu,
|
|
4973
|
+
headerFocus,
|
|
4959
4974
|
initialFilterEditorDraft,
|
|
4960
4975
|
intentOf,
|
|
4961
4976
|
isColumnFiltered,
|