@gridkitjs/react 0.0.0-dev-20261111180407 → 0.0.0-dev-20261112193051
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 +9 -13
- package/dist/index.js +89 -99
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode, Ref, RefObject } from 'react';
|
|
3
|
-
import { ExportWriter, GridExportOptions, PrintOptions, CellSelectEvent as CellSelectEvent$1, CellSelectionChangeEvent as CellSelectionChangeEvent$1, ColumnDefinition as ColumnDefinition$1, ColumnSelectEvent as ColumnSelectEvent$1, ColumnSelectionChangeEvent as ColumnSelectionChangeEvent$1, ColumnsSelectEvent as ColumnsSelectEvent$1, DataColumn as DataColumn$1, GridOptions, PaginationState, SelectionCallbacks as SelectionCallbacks$1, ResolvedRow, DisplayRow, ResolvedColumn as ResolvedColumn$1, ColumnSizingState, ColumnOrderState, ColumnVisibilityState, ColumnSortState, FilterState, GroupByState, GroupExpansionState, AggregateResults, SelectionState, CellSelectionState, GridState, SerializedGridState, GridContextMenuTarget, GridCommandTarget, SelectedCell as SelectedCell$1, SelectedColumn as SelectedColumn$1 } from '@gridkitjs/core';
|
|
4
|
-
export { Borders, CellSelectionMode, CellSelectionState, CellTemplateContext, ColumnResizeEvent, ColumnSizeDefaults, ColumnSizingState, ColumnVisibilityEvent, ColumnVisibilityState, ContextMenuOpenChangeEvent, ExportFile, ExportOptions, ExportWriter, FilterChangeEvent, FilterEntry, FilterState, GridCommand, GridCommandEvent, GridCommandTarget, GridContextMenuOptions, GridContextMenuRequest, GridContextMenuTarget, GridExportOptions, GridMessages, GridOptions, GridState, GridToolbarOptions, GroupByBarVisibility, HoverableConfig, MenuEntry, PaginationUnit, PrintOptions, ResizeMode, ResolvedRow, RowPointerEvent, RowProps, RowSelectEvent, RowSelectionChangeEvent, RowsSelectEvent, SelectableConfig, SelectedCellRef, SelectionMode, SelectionState, SerializedGridState, ToolbarEntry, ToolbarItemAttributes, excelFilter, serializeGridState } from '@gridkitjs/core';
|
|
3
|
+
import { ExportWriter, GridExportOptions, PrintOptions, CellSelectEvent as CellSelectEvent$1, CellSelectionChangeEvent as CellSelectionChangeEvent$1, ColumnDefinition as ColumnDefinition$1, ColumnSelectEvent as ColumnSelectEvent$1, ColumnSelectionChangeEvent as ColumnSelectionChangeEvent$1, ColumnsSelectEvent as ColumnsSelectEvent$1, DataColumn as DataColumn$1, GridOptions, PaginationState, SelectionCallbacks as SelectionCallbacks$1, ResolvedRow, DisplayRow, ResolvedColumn as ResolvedColumn$1, ColumnSizingState, ColumnOrderState, ColumnVisibilityState, ColumnSortState, FilterState, GroupByState, GroupExpansionState, AggregateResults, SelectionState, CellSelectionState, GridFocus, GridState, SerializedGridState, GridContextMenuTarget, GridCommandTarget, SelectedCell as SelectedCell$1, SelectedColumn as SelectedColumn$1 } from '@gridkitjs/core';
|
|
4
|
+
export { Borders, CellSelectionMode, CellSelectionState, CellTemplateContext, ColumnResizeEvent, ColumnSizeDefaults, ColumnSizingState, ColumnVisibilityEvent, ColumnVisibilityState, ContextMenuOpenChangeEvent, ExportFile, ExportOptions, ExportWriter, FilterChangeEvent, FilterEntry, FilterState, GridCommand, GridCommandEvent, GridCommandTarget, GridContextMenuOptions, GridContextMenuRequest, GridContextMenuTarget, GridExportOptions, GridFocus, GridMessages, GridOptions, GridState, GridToolbarOptions, GroupByBarVisibility, HoverableConfig, MenuEntry, PaginationUnit, PrintOptions, ResizeMode, ResolvedRow, RowPointerEvent, RowProps, RowSelectEvent, RowSelectionChangeEvent, RowsSelectEvent, SelectableConfig, SelectedCellRef, SelectionMode, SelectionState, SerializedGridState, ToolbarEntry, ToolbarItemAttributes, excelFilter, serializeGridState } from '@gridkitjs/core';
|
|
5
5
|
|
|
6
6
|
/** What `DataGridApi` carries for exporting. */
|
|
7
7
|
interface GridExportApi {
|
|
@@ -145,13 +145,10 @@ interface DataGridApi<Row> extends GridExportApi, GridPrintApi, GridPanelApi {
|
|
|
145
145
|
getColumnSelection(): SelectionState;
|
|
146
146
|
getCellSelection(): CellSelectionState;
|
|
147
147
|
/**
|
|
148
|
-
* The cell currently holding the grid's single tab stop,
|
|
149
|
-
* `focusCell` takes
|
|
148
|
+
* The cell currently holding the grid's single tab stop, in the shape
|
|
149
|
+
* `focusCell` takes. Returns the same object until the focus moves.
|
|
150
150
|
*/
|
|
151
|
-
getFocusedCell():
|
|
152
|
-
rowIndex: number;
|
|
153
|
-
columnIndex: number;
|
|
154
|
-
};
|
|
151
|
+
getFocusedCell(): GridFocus;
|
|
155
152
|
/**
|
|
156
153
|
* Every slice of state as the grid applies it, in one object — what
|
|
157
154
|
* `restoreState` takes back. Pass it through `serializeGridState` before
|
|
@@ -166,12 +163,11 @@ interface DataGridApi<Row> extends GridExportApi, GridPrintApi, GridPanelApi {
|
|
|
166
163
|
*/
|
|
167
164
|
restoreState(saved: Partial<GridState<Row>> | Partial<SerializedGridState<Row>>): void;
|
|
168
165
|
/**
|
|
169
|
-
* Moves the grid's tab stop, and the browser's focus, to
|
|
170
|
-
* `
|
|
171
|
-
* `
|
|
172
|
-
* the grid.
|
|
166
|
+
* Moves the grid's tab stop, and the browser's focus, to a cell:
|
|
167
|
+
* `{ area: "body", rowIndex, columnIndex }` or
|
|
168
|
+
* `{ area: "header", columnIndex }`. Either index is held inside the grid.
|
|
173
169
|
*/
|
|
174
|
-
focusCell(
|
|
170
|
+
focusCell(focus: GridFocus): void;
|
|
175
171
|
clearSelection(): void;
|
|
176
172
|
selectAllRows(): void;
|
|
177
173
|
/**
|
package/dist/index.js
CHANGED
|
@@ -10,7 +10,6 @@ import {
|
|
|
10
10
|
useState as useState18
|
|
11
11
|
} from "react";
|
|
12
12
|
import {
|
|
13
|
-
bodyFocus as bodyFocus3,
|
|
14
13
|
headerFocus as headerFocus3,
|
|
15
14
|
moveColumnBefore,
|
|
16
15
|
resolveColumnHeaderText as resolveColumnHeaderText2,
|
|
@@ -842,14 +841,14 @@ import { Fragment, jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
|
842
841
|
function groupAriaMeta(rows) {
|
|
843
842
|
const totals = /* @__PURE__ */ new Map();
|
|
844
843
|
for (const entry of rows) {
|
|
845
|
-
if (
|
|
844
|
+
if (entry.kind !== "group") continue;
|
|
846
845
|
const parentKey = groupRowId(entry.path.slice(0, -1));
|
|
847
846
|
totals.set(parentKey, (totals.get(parentKey) ?? 0) + 1);
|
|
848
847
|
}
|
|
849
848
|
const seen = /* @__PURE__ */ new Map();
|
|
850
849
|
const meta = /* @__PURE__ */ new Map();
|
|
851
850
|
for (const entry of rows) {
|
|
852
|
-
if (
|
|
851
|
+
if (entry.kind !== "group") continue;
|
|
853
852
|
const parentKey = groupRowId(entry.path.slice(0, -1));
|
|
854
853
|
const posinset = (seen.get(parentKey) ?? 0) + 1;
|
|
855
854
|
seen.set(parentKey, posinset);
|
|
@@ -892,14 +891,14 @@ function GridBody({
|
|
|
892
891
|
const [resolveRowProps] = useState2(() => createRowPropsResolver());
|
|
893
892
|
const rowPropsOf = resolveRowProps(
|
|
894
893
|
visibleRows.filter(
|
|
895
|
-
(entry) =>
|
|
894
|
+
(entry) => entry.kind === "data"
|
|
896
895
|
),
|
|
897
896
|
getRowProps
|
|
898
897
|
);
|
|
899
898
|
function targetOf(target) {
|
|
900
899
|
const position = bodyCellFrom(target);
|
|
901
900
|
const entry = position === null ? void 0 : rows[position.rowIndex];
|
|
902
|
-
if (position === null || entry
|
|
901
|
+
if (position === null || entry?.kind !== "data") {
|
|
903
902
|
return null;
|
|
904
903
|
}
|
|
905
904
|
return { position, rowId: entry.rowId };
|
|
@@ -915,7 +914,7 @@ function GridBody({
|
|
|
915
914
|
function rowPointerEventOf(event) {
|
|
916
915
|
const target = bodyRowFrom(event.target);
|
|
917
916
|
const entry = target === null ? void 0 : rows[target.rowIndex];
|
|
918
|
-
if (target === null || entry
|
|
917
|
+
if (target === null || entry?.kind !== "data") {
|
|
919
918
|
return null;
|
|
920
919
|
}
|
|
921
920
|
return {
|
|
@@ -1016,75 +1015,82 @@ function GridBody({
|
|
|
1016
1015
|
}
|
|
1017
1016
|
) }),
|
|
1018
1017
|
visibleRows.map((entry) => {
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1018
|
+
switch (entry.kind) {
|
|
1019
|
+
case "data": {
|
|
1020
|
+
const rowProps = rowPropsOf(entry.rowId);
|
|
1021
|
+
return /* @__PURE__ */ jsx7(
|
|
1022
|
+
GridRow_default,
|
|
1023
|
+
{
|
|
1024
|
+
ref: virtualRange?.measureRow(entry.rowIndex),
|
|
1025
|
+
columns,
|
|
1026
|
+
rowId: entry.rowId,
|
|
1027
|
+
row: entry.row,
|
|
1028
|
+
rowIndex: entry.rowIndex,
|
|
1029
|
+
datasetIndex: entry.datasetIndex,
|
|
1030
|
+
activeColumnId,
|
|
1031
|
+
selectedColumnIds: selection.selectedColumnIds,
|
|
1032
|
+
selected: selection.selectedRowIds.has(entry.rowId),
|
|
1033
|
+
selectedColumnId: selectedCell?.rowId === entry.rowId ? selectedCell.columnId : null,
|
|
1034
|
+
focusedColumnIndex: focusedColumnInRow(
|
|
1035
|
+
nav.focus,
|
|
1036
|
+
entry.rowIndex
|
|
1037
|
+
),
|
|
1038
|
+
rowsSelectable: rowMode !== false,
|
|
1039
|
+
cellsSelectable: cellMode !== false,
|
|
1040
|
+
contextMenu: cellMenu,
|
|
1041
|
+
locale,
|
|
1042
|
+
cellMessages,
|
|
1043
|
+
rowClassName: rowProps.className,
|
|
1044
|
+
rowAttributes: rowProps.attributes
|
|
1045
|
+
},
|
|
1046
|
+
entry.rowId
|
|
1047
|
+
);
|
|
1048
|
+
}
|
|
1049
|
+
case "group-summary":
|
|
1050
|
+
return /* @__PURE__ */ jsx7(
|
|
1051
|
+
GridGroupSummaryRow_default,
|
|
1052
|
+
{
|
|
1053
|
+
ref: virtualRange?.measureRow(entry.rowIndex),
|
|
1054
|
+
groupId: entry.groupId,
|
|
1055
|
+
level: entry.level,
|
|
1056
|
+
rowIndex: entry.rowIndex,
|
|
1057
|
+
datasetIndex: entry.datasetIndex,
|
|
1058
|
+
results: entry.aggregates,
|
|
1059
|
+
aggregates,
|
|
1060
|
+
columns,
|
|
1061
|
+
locale
|
|
1062
|
+
},
|
|
1063
|
+
`${entry.groupId}-summary`
|
|
1064
|
+
);
|
|
1065
|
+
case "group":
|
|
1066
|
+
return /* @__PURE__ */ jsx7(
|
|
1067
|
+
GridGroupRow_default,
|
|
1068
|
+
{
|
|
1069
|
+
ref: virtualRange?.measureRow(entry.rowIndex),
|
|
1070
|
+
columnCount: columns.length,
|
|
1071
|
+
groupId: entry.groupId,
|
|
1072
|
+
level: entry.level,
|
|
1073
|
+
groupColumn: definitions.get(entry.columnId) ?? { field: entry.columnId },
|
|
1074
|
+
value: entry.value,
|
|
1075
|
+
expanded: entry.expanded,
|
|
1076
|
+
count: entry.count,
|
|
1077
|
+
rowIndex: entry.rowIndex,
|
|
1078
|
+
datasetIndex: entry.datasetIndex,
|
|
1079
|
+
posinset: ariaMeta.get(entry.groupId)?.posinset ?? 1,
|
|
1080
|
+
setsize: ariaMeta.get(entry.groupId)?.setsize ?? 1,
|
|
1081
|
+
aggregates: groupAggregateDisplay === "inline" ? aggregates : [],
|
|
1082
|
+
results: entry.aggregates,
|
|
1083
|
+
definitions,
|
|
1084
|
+
locale,
|
|
1085
|
+
cellMessages,
|
|
1086
|
+
focused: focusedColumnInRow(nav.focus, entry.rowIndex) !== null,
|
|
1087
|
+
contextMenu: groupMenu
|
|
1088
|
+
},
|
|
1089
|
+
entry.groupId
|
|
1090
|
+
);
|
|
1091
|
+
default:
|
|
1092
|
+
return entry;
|
|
1062
1093
|
}
|
|
1063
|
-
return /* @__PURE__ */ jsx7(
|
|
1064
|
-
GridGroupRow_default,
|
|
1065
|
-
{
|
|
1066
|
-
ref: virtualRange?.measureRow(entry.rowIndex),
|
|
1067
|
-
columnCount: columns.length,
|
|
1068
|
-
groupId: entry.groupId,
|
|
1069
|
-
level: entry.level,
|
|
1070
|
-
groupColumn: definitions.get(entry.columnId) ?? { field: entry.columnId },
|
|
1071
|
-
value: entry.value,
|
|
1072
|
-
expanded: entry.expanded,
|
|
1073
|
-
count: entry.count,
|
|
1074
|
-
rowIndex: entry.rowIndex,
|
|
1075
|
-
datasetIndex: entry.datasetIndex,
|
|
1076
|
-
posinset: ariaMeta.get(entry.groupId)?.posinset ?? 1,
|
|
1077
|
-
setsize: ariaMeta.get(entry.groupId)?.setsize ?? 1,
|
|
1078
|
-
aggregates: groupAggregateDisplay === "inline" ? aggregates : [],
|
|
1079
|
-
results: entry.aggregates,
|
|
1080
|
-
definitions,
|
|
1081
|
-
locale,
|
|
1082
|
-
cellMessages,
|
|
1083
|
-
focused: focusedColumnInRow(nav.focus, entry.rowIndex) !== null,
|
|
1084
|
-
contextMenu: groupMenu
|
|
1085
|
-
},
|
|
1086
|
-
entry.groupId
|
|
1087
|
-
);
|
|
1088
1094
|
}),
|
|
1089
1095
|
virtualRange !== null && virtualRange.offsetAfter > 0 && /* @__PURE__ */ jsx7("tr", { "aria-hidden": "true", children: /* @__PURE__ */ jsx7(
|
|
1090
1096
|
"td",
|
|
@@ -1716,7 +1722,7 @@ function useGridCopy({
|
|
|
1716
1722
|
const { pageRows, columns } = controller.getView();
|
|
1717
1723
|
const entry = pageRows[focus.rowIndex];
|
|
1718
1724
|
const column = columns[focus.columnIndex];
|
|
1719
|
-
return entry
|
|
1725
|
+
return entry?.kind !== "data" || column === void 0 ? null : { area: "cell", rowId: entry.rowId, columnId: column.id };
|
|
1720
1726
|
}
|
|
1721
1727
|
return (event) => {
|
|
1722
1728
|
if (!isCopyKey(event) || isNativeCopy(event.target)) {
|
|
@@ -2386,7 +2392,7 @@ function bodyPlaceAt(element, parts) {
|
|
|
2386
2392
|
if (group !== null) {
|
|
2387
2393
|
const entry = pageRows[group.rowIndex];
|
|
2388
2394
|
const cell = bodyCell(parts, group.rowIndex, 0);
|
|
2389
|
-
return entry !== void 0 &&
|
|
2395
|
+
return entry !== void 0 && entry.kind === "group" && cell?.element.contains(element) === true ? onCell(
|
|
2390
2396
|
{ area: "group", groupId: entry.groupId, columnId: entry.columnId },
|
|
2391
2397
|
cell,
|
|
2392
2398
|
parts
|
|
@@ -2396,7 +2402,7 @@ function bodyPlaceAt(element, parts) {
|
|
|
2396
2402
|
if (position !== null) {
|
|
2397
2403
|
const entry = pageRows[position.rowIndex];
|
|
2398
2404
|
const cell = bodyCell(parts, position.rowIndex, position.columnIndex);
|
|
2399
|
-
return entry !== void 0 &&
|
|
2405
|
+
return entry !== void 0 && entry.kind === "data" && cell?.element.contains(element) === true ? onCell(
|
|
2400
2406
|
{ area: "cell", rowId: entry.rowId, columnId: position.columnId },
|
|
2401
2407
|
cell,
|
|
2402
2408
|
parts
|
|
@@ -2418,7 +2424,7 @@ function placeOf(target, parts) {
|
|
|
2418
2424
|
);
|
|
2419
2425
|
case "cell": {
|
|
2420
2426
|
const rowIndex = parts.pageRows.findIndex(
|
|
2421
|
-
(entry) =>
|
|
2427
|
+
(entry) => entry.kind === "data" && entry.rowId === target.rowId
|
|
2422
2428
|
);
|
|
2423
2429
|
return onCell(
|
|
2424
2430
|
target,
|
|
@@ -2428,7 +2434,7 @@ function placeOf(target, parts) {
|
|
|
2428
2434
|
}
|
|
2429
2435
|
case "group": {
|
|
2430
2436
|
const rowIndex = parts.pageRows.findIndex(
|
|
2431
|
-
(entry) =>
|
|
2437
|
+
(entry) => entry.kind === "group" && entry.groupId === target.groupId
|
|
2432
2438
|
);
|
|
2433
2439
|
return onCell(target, bodyCell(parts, rowIndex, 0), parts);
|
|
2434
2440
|
}
|
|
@@ -4547,19 +4553,6 @@ function selectedRowsReader(controller) {
|
|
|
4547
4553
|
return last.selected;
|
|
4548
4554
|
};
|
|
4549
4555
|
}
|
|
4550
|
-
function focusAt(rowIndex, columnIndex) {
|
|
4551
|
-
return rowIndex < 0 ? headerFocus3(columnIndex) : bodyFocus3(rowIndex, columnIndex);
|
|
4552
|
-
}
|
|
4553
|
-
function focusedCellReader() {
|
|
4554
|
-
let last;
|
|
4555
|
-
return (focus) => {
|
|
4556
|
-
if (last?.focus !== focus) {
|
|
4557
|
-
const rowIndex = focus.area === "header" ? -1 : focus.rowIndex;
|
|
4558
|
-
last = { focus, cell: { rowIndex, columnIndex: focus.columnIndex } };
|
|
4559
|
-
}
|
|
4560
|
-
return last.cell;
|
|
4561
|
-
};
|
|
4562
|
-
}
|
|
4563
4556
|
function DataGrid(props) {
|
|
4564
4557
|
const {
|
|
4565
4558
|
borders,
|
|
@@ -4619,7 +4612,6 @@ function DataGrid(props) {
|
|
|
4619
4612
|
});
|
|
4620
4613
|
const [readPagination] = useState18(() => paginationReader(controller));
|
|
4621
4614
|
const [readSelectedRows] = useState18(() => selectedRowsReader(controller));
|
|
4622
|
-
const [readFocusedCell] = useState18(focusedCellReader);
|
|
4623
4615
|
const virtualizer = useRowVirtualizer({
|
|
4624
4616
|
enabled: virtualized,
|
|
4625
4617
|
rows: view.pageRows,
|
|
@@ -4685,7 +4677,7 @@ function DataGrid(props) {
|
|
|
4685
4677
|
// vertical movement steps over it rather than landing there.
|
|
4686
4678
|
isSkippableRow: (rowIndex) => {
|
|
4687
4679
|
const entry = view.pageRows[rowIndex];
|
|
4688
|
-
return entry
|
|
4680
|
+
return entry?.kind === "group-summary";
|
|
4689
4681
|
}
|
|
4690
4682
|
});
|
|
4691
4683
|
const overlay = useGridOverlay({
|
|
@@ -4812,12 +4804,10 @@ function DataGrid(props) {
|
|
|
4812
4804
|
getSelectedRows: readSelectedRows,
|
|
4813
4805
|
getColumnSelection: () => controller.getState().columnSelection,
|
|
4814
4806
|
getCellSelection: () => controller.getState().cellSelection,
|
|
4815
|
-
getFocusedCell: () =>
|
|
4807
|
+
getFocusedCell: () => nav.focus,
|
|
4816
4808
|
getState: controller.getState,
|
|
4817
4809
|
restoreState: controller.restoreState,
|
|
4818
|
-
focusCell:
|
|
4819
|
-
nav.focusCell(focusAt(rowIndex, columnIndex));
|
|
4820
|
-
},
|
|
4810
|
+
focusCell: nav.focusCell,
|
|
4821
4811
|
clearSelection: controller.clearSelection,
|
|
4822
4812
|
selectAllRows: controller.selectAllRows,
|
|
4823
4813
|
selectRows: controller.selectRows,
|
|
@@ -4856,7 +4846,7 @@ function DataGrid(props) {
|
|
|
4856
4846
|
runCommand: (commandId, target = { area: "grid" }) => commands.run(commandId, target, "api"),
|
|
4857
4847
|
scrollToRow: (rowId, options) => {
|
|
4858
4848
|
const index = controller.getView().pageRows.findIndex(
|
|
4859
|
-
(entry) =>
|
|
4849
|
+
(entry) => entry.kind === "data" && entry.rowId === rowId
|
|
4860
4850
|
);
|
|
4861
4851
|
if (index === -1) return;
|
|
4862
4852
|
if (virtualized) {
|