@gridkitjs/react 0.0.0-dev-20261117141506 → 0.0.0-dev-20261118081957

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode, Ref, RefObject } from 'react';
3
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 { AggregateFn, AggregateResults, AggregateSpec, AggregateState, Borders, BuiltInAggregate, CellSelectionMode, CellSelectionState, CellTemplateContext, ColumnAlignment, ColumnFilterMenuOptions, ColumnOrderEvent, ColumnOrderState, ColumnResizeEvent, ColumnSizeDefaults, ColumnSizingState, ColumnSortEntry, ColumnSortEvent, ColumnSortState, ColumnType, ColumnVisibilityEvent, ColumnVisibilityState, ColumnWrapConfig, ContextMenuOpenChangeEvent, DisplayRow, ExportFile, ExportOptions, ExportScalar, ExportWriter, FieldPath, FilterChangeEvent, FilterEntry, FilterState, FooterTemplateContext, FormatLocale, GridCommand, GridCommandEvent, GridCommandTarget, GridContextMenuOptions, GridContextMenuRequest, GridContextMenuTarget, GridExportOptions, GridFilterMenuOptions, GridFocus, GridMessages, GridOptions, GridState, GridToolbarOptions, GroupAggregateDisplay, GroupByBarVisibility, GroupByEntry, GroupByEvent, GroupByState, GroupExpansionEvent, GroupExpansionState, HoverableConfig, MenuEntry, PaginationChangeEvent, PaginationState, PaginationUnit, PrintOptions, ResizeMode, ResolvedGroupRow, ResolvedGroupSummaryRow, ResolvedRow, RowPointerEvent, RowProps, RowSelectEvent, RowSelectionChangeEvent, RowsSelectEvent, SelectableConfig, SelectedCellRef, SelectionMode, SelectionState, SerializedGridState, SortDirection, ToolbarEntry, ToolbarItemAttributes, excelFilter, serializeGridState } from '@gridkitjs/core';
4
+ export { AggregateFn, AggregateResults, AggregateSpec, AggregateState, Borders, BuiltInAggregate, CellSelectionMode, CellSelectionState, CellTemplateContext, ColumnAlignment, ColumnFilterMenuOptions, ColumnOrderEvent, ColumnOrderState, ColumnResizeEvent, ColumnSizeDefaults, ColumnSizingState, ColumnSortEntry, ColumnSortEvent, ColumnSortState, ColumnType, ColumnVisibilityEvent, ColumnVisibilityState, ColumnWrapConfig, ContextMenuOpenChangeEvent, DisplayRow, ExportFile, ExportOptions, ExportScalar, ExportWriter, FieldPath, FilterChangeEvent, FilterEntry, FilterState, FooterTemplateContext, FormatLocale, GridCommand, GridCommandEvent, GridCommandTarget, GridContextMenuOptions, GridContextMenuRequest, GridContextMenuTarget, GridExportOptions, GridFilterMenuOptions, GridFocus, GridMessages, GridOptions, GridState, GridToolbarOptions, GroupAggregateDisplay, GroupByBarVisibility, GroupByEntry, GroupByEvent, GroupByState, GroupExpansionEvent, GroupExpansionState, HoverableConfig, MenuEntry, PaginationChangeEvent, PaginationState, PaginationUnit, PrintOptions, ResizeMode, ResolvedGroupRow, ResolvedGroupSummaryRow, ResolvedRow, RowGroupPosition, RowPointerEvent, RowProps, RowSelectEvent, RowSelectionChangeEvent, RowsSelectEvent, SelectableConfig, SelectedCellRef, SelectionMode, SelectionState, SerializedGridState, SortDirection, ToolbarEntry, ToolbarItemAttributes, excelFilter, serializeGridState } from '@gridkitjs/core';
5
5
 
6
6
  /** What `DataGridApi` carries for exporting. */
7
7
  interface GridExportApi {
package/dist/index.js CHANGED
@@ -435,8 +435,7 @@ import {
435
435
  useState as useState2
436
436
  } from "react";
437
437
  import {
438
- bodyFocus,
439
- groupRowId
438
+ bodyFocus
440
439
  } from "@gridkitjs/core";
441
440
  import { intentOf as intentOf2 } from "@gridkitjs/core/renderer";
442
441
  import {
@@ -767,6 +766,9 @@ function GridRowComponent({
767
766
  row,
768
767
  rowIndex,
769
768
  datasetIndex,
769
+ groupLevel,
770
+ groupPosition,
771
+ groupSetSize,
770
772
  activeColumnId,
771
773
  selectedColumnIds,
772
774
  selected,
@@ -794,6 +796,9 @@ function GridRowComponent({
794
796
  "aria-rowindex": datasetIndex + 2,
795
797
  "data-gridkit-row-index": rowIndex,
796
798
  "data-gridkit-row-id": rowId,
799
+ "aria-level": groupLevel === void 0 ? void 0 : groupLevel + 1,
800
+ "aria-posinset": groupPosition,
801
+ "aria-setsize": groupSetSize,
797
802
  ...ariaAttr(rowsSelectable, "aria-selected", selected),
798
803
  className: classNames(
799
804
  "gridkit-grid-row",
@@ -840,27 +845,6 @@ var GridRow_default = GridRow;
840
845
 
841
846
  // src/DataGrid/components/GridBody.tsx
842
847
  import { Fragment, jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
843
- function groupAriaMeta(rows) {
844
- const totals = /* @__PURE__ */ new Map();
845
- for (const entry of rows) {
846
- if (entry.kind !== "group") continue;
847
- const parentKey = groupRowId(entry.path.slice(0, -1));
848
- totals.set(parentKey, (totals.get(parentKey) ?? 0) + 1);
849
- }
850
- const seen = /* @__PURE__ */ new Map();
851
- const meta = /* @__PURE__ */ new Map();
852
- for (const entry of rows) {
853
- if (entry.kind !== "group") continue;
854
- const parentKey = groupRowId(entry.path.slice(0, -1));
855
- const posinset = (seen.get(parentKey) ?? 0) + 1;
856
- seen.set(parentKey, posinset);
857
- meta.set(entry.groupId, {
858
- posinset,
859
- setsize: totals.get(parentKey) ?? posinset
860
- });
861
- }
862
- return meta;
863
- }
864
848
  function GridBody({
865
849
  columns,
866
850
  definitions,
@@ -883,7 +867,6 @@ function GridBody({
883
867
  groupMenu
884
868
  }) {
885
869
  const { selectedCell, rowMode, cellMode, toggleOnClick } = selection;
886
- const ariaMeta = useMemo2(() => groupAriaMeta(rows), [rows]);
887
870
  const visibleRows = virtualRange === null ? rows : rows.slice(virtualRange.startIndex, virtualRange.endIndex + 1);
888
871
  const { booleanTrue, booleanFalse, blankGroupValue } = messages;
889
872
  const cellMessages = useMemo2(
@@ -941,7 +924,7 @@ function GridBody({
941
924
  return /* @__PURE__ */ jsxs5(
942
925
  "tbody",
943
926
  {
944
- role: "rowgroup",
927
+ role: "presentation",
945
928
  className: "gridkit-grid-body",
946
929
  onFocus: (event) => {
947
930
  const group = groupRowFrom(event.target);
@@ -1029,6 +1012,9 @@ function GridBody({
1029
1012
  row: entry.row,
1030
1013
  rowIndex: entry.rowIndex,
1031
1014
  datasetIndex: entry.datasetIndex,
1015
+ groupLevel: entry.groupPosition?.level,
1016
+ groupPosition: entry.groupPosition?.position,
1017
+ groupSetSize: entry.groupPosition?.setSize,
1032
1018
  activeColumnId,
1033
1019
  selectedColumnIds: selection.selectedColumnIds,
1034
1020
  selected: selection.selectedRowIds.has(entry.rowId),
@@ -1078,8 +1064,8 @@ function GridBody({
1078
1064
  count: entry.count,
1079
1065
  rowIndex: entry.rowIndex,
1080
1066
  datasetIndex: entry.datasetIndex,
1081
- posinset: ariaMeta.get(entry.groupId)?.posinset ?? 1,
1082
- setsize: ariaMeta.get(entry.groupId)?.setsize ?? 1,
1067
+ posinset: entry.position,
1068
+ setsize: entry.setSize,
1083
1069
  aggregates: groupAggregateDisplay === "inline" ? aggregates : [],
1084
1070
  results: entry.aggregates,
1085
1071
  definitions,
@@ -4947,181 +4933,191 @@ function DataGrid(props) {
4947
4933
  selection.cellMode === false ? "" : "gridkit-selectable-cells"
4948
4934
  );
4949
4935
  const hasFooter = aggregates.length > 0;
4950
- return /* @__PURE__ */ jsxs19("div", { className: "gridkit-data-grid-viewport", ref: viewportRef, children: [
4951
- /* @__PURE__ */ jsx26(
4952
- GridToolbar,
4953
- {
4954
- toolbar: props.toolbar,
4955
- renderItem: props.renderToolbarItem,
4956
- gridId,
4957
- controller,
4958
- commands,
4959
- messages,
4960
- announce
4961
- }
4962
- ),
4963
- showGroupByBar && /* @__PURE__ */ jsx26(
4964
- GroupByBar,
4965
- {
4966
- columns: view.columns,
4967
- definitions,
4968
- groupBy: state.groupBy,
4969
- controller,
4970
- columnName,
4971
- headerDragEligible: dragEligibleForGroupBy,
4972
- headerDragBlocked: draggedColumnAlreadyGrouped,
4973
- headerDropTarget: headerGroupByDropTarget,
4974
- messages
4975
- }
4976
- ),
4977
- /* @__PURE__ */ jsxs19(
4978
- "div",
4979
- {
4980
- ref: gridRef,
4981
- id: gridId,
4982
- className: "gridkit-data-grid-tables",
4983
- role: state.groupBy.length > 0 ? "treegrid" : "grid",
4984
- "aria-rowcount": view.displayRows.length + (hasFooter ? 2 : 1),
4985
- "aria-colcount": view.columns.length,
4986
- ...ariaAttr(multiselectable, "aria-multiselectable", true),
4987
- ...ariaAttr(labelledBy !== void 0, "aria-labelledby", labelledBy),
4988
- ...ariaAttr(
4989
- labelledBy === void 0 && label !== void 0,
4990
- "aria-label",
4991
- label
4992
- ),
4993
- onKeyDown: (event) => {
4994
- if (!isOwnEvent(event)) return;
4995
- handleCopyKey(event);
4996
- if (event.key === "Escape") {
4997
- if (drag.draggedColumnId !== null || resize.activeColumnId !== null)
4998
- return;
4999
- selection.clear();
5000
- return;
4936
+ return /* @__PURE__ */ jsxs19(
4937
+ "div",
4938
+ {
4939
+ className: "gridkit-data-grid-viewport",
4940
+ ref: viewportRef,
4941
+ tabIndex: -1,
4942
+ children: [
4943
+ /* @__PURE__ */ jsx26(
4944
+ GridToolbar,
4945
+ {
4946
+ toolbar: props.toolbar,
4947
+ renderItem: props.renderToolbarItem,
4948
+ gridId,
4949
+ controller,
4950
+ commands,
4951
+ messages,
4952
+ announce
5001
4953
  }
5002
- if ((event.ctrlKey || event.metaKey) && (event.key === "a" || event.key === "A")) {
5003
- if (selection.rowMode !== "multiple") return;
5004
- event.preventDefault();
5005
- selection.selectAllRows();
4954
+ ),
4955
+ showGroupByBar && /* @__PURE__ */ jsx26(
4956
+ GroupByBar,
4957
+ {
4958
+ columns: view.columns,
4959
+ definitions,
4960
+ groupBy: state.groupBy,
4961
+ controller,
4962
+ columnName,
4963
+ headerDragEligible: dragEligibleForGroupBy,
4964
+ headerDragBlocked: draggedColumnAlreadyGrouped,
4965
+ headerDropTarget: headerGroupByDropTarget,
4966
+ messages
5006
4967
  }
5007
- },
5008
- children: [
5009
- /* @__PURE__ */ jsxs19(
5010
- "table",
5011
- {
5012
- ref: headerTableRef,
5013
- role: "presentation",
5014
- style: { width: totalColumnWidth(view.columns) },
5015
- className: classNames(gridTableClassName, "gridkit-data-grid-header"),
5016
- children: [
5017
- /* @__PURE__ */ jsx26(GridColgroup, { columns: view.columns }),
5018
- /* @__PURE__ */ jsx26(
5019
- GridHeader,
5020
- {
5021
- columns: view.columns,
5022
- resize,
5023
- drag,
5024
- controller,
5025
- state,
5026
- sortableColumns,
5027
- groupableColumns,
5028
- groupToggleIconColumns,
5029
- headerMenu: contextMenu.opens("header"),
5030
- panels,
5031
- messages,
5032
- nav,
5033
- selection
5034
- }
5035
- )
5036
- ]
5037
- }
5038
- ),
5039
- /* @__PURE__ */ jsx26(
5040
- "div",
5041
- {
5042
- className: "gridkit-data-grid-body",
5043
- ref: bodyScrollRef,
5044
- style: height === void 0 ? void 0 : {
5045
- "--gridkit-body-height": typeof height === "number" ? `${String(height)}px` : height
5046
- },
5047
- children: /* @__PURE__ */ jsxs19(
4968
+ ),
4969
+ /* @__PURE__ */ jsxs19(
4970
+ "div",
4971
+ {
4972
+ ref: gridRef,
4973
+ id: gridId,
4974
+ className: "gridkit-data-grid-tables",
4975
+ role: state.groupBy.length > 0 ? "treegrid" : "grid",
4976
+ "aria-rowcount": view.displayRows.length + (hasFooter ? 2 : 1),
4977
+ "aria-colcount": view.columns.length,
4978
+ ...ariaAttr(multiselectable, "aria-multiselectable", true),
4979
+ ...ariaAttr(labelledBy !== void 0, "aria-labelledby", labelledBy),
4980
+ ...ariaAttr(
4981
+ labelledBy === void 0 && label !== void 0,
4982
+ "aria-label",
4983
+ label
4984
+ ),
4985
+ onKeyDown: (event) => {
4986
+ if (!isOwnEvent(event)) return;
4987
+ handleCopyKey(event);
4988
+ if (event.key === "Escape") {
4989
+ if (drag.draggedColumnId !== null || resize.activeColumnId !== null)
4990
+ return;
4991
+ selection.clear();
4992
+ return;
4993
+ }
4994
+ if ((event.ctrlKey || event.metaKey) && (event.key === "a" || event.key === "A")) {
4995
+ if (selection.rowMode !== "multiple") return;
4996
+ event.preventDefault();
4997
+ selection.selectAllRows();
4998
+ }
4999
+ },
5000
+ children: [
5001
+ /* @__PURE__ */ jsxs19(
5048
5002
  "table",
5049
5003
  {
5050
- ref: bodyTableRef,
5004
+ ref: headerTableRef,
5051
5005
  role: "presentation",
5052
5006
  style: { width: totalColumnWidth(view.columns) },
5053
- className: gridTableClassName,
5007
+ className: classNames(gridTableClassName, "gridkit-data-grid-header"),
5054
5008
  children: [
5055
5009
  /* @__PURE__ */ jsx26(GridColgroup, { columns: view.columns }),
5056
5010
  /* @__PURE__ */ jsx26(
5057
- GridBody,
5011
+ GridHeader,
5058
5012
  {
5059
5013
  columns: view.columns,
5060
- definitions,
5061
- rows: view.pageRows,
5062
- activeColumnId: resize.activeColumnId,
5063
- nav,
5064
- selection,
5014
+ resize,
5015
+ drag,
5065
5016
  controller,
5017
+ state,
5018
+ sortableColumns,
5019
+ groupableColumns,
5020
+ groupToggleIconColumns,
5021
+ headerMenu: contextMenu.opens("header"),
5022
+ panels,
5023
+ messages,
5024
+ nav,
5025
+ selection
5026
+ }
5027
+ )
5028
+ ]
5029
+ }
5030
+ ),
5031
+ /* @__PURE__ */ jsx26(
5032
+ "div",
5033
+ {
5034
+ className: "gridkit-data-grid-body",
5035
+ ref: bodyScrollRef,
5036
+ role: "rowgroup",
5037
+ tabIndex: -1,
5038
+ style: height === void 0 ? void 0 : {
5039
+ "--gridkit-body-height": typeof height === "number" ? `${String(height)}px` : height
5040
+ },
5041
+ children: /* @__PURE__ */ jsxs19(
5042
+ "table",
5043
+ {
5044
+ ref: bodyTableRef,
5045
+ role: "presentation",
5046
+ style: { width: totalColumnWidth(view.columns) },
5047
+ className: gridTableClassName,
5048
+ children: [
5049
+ /* @__PURE__ */ jsx26(GridColgroup, { columns: view.columns }),
5050
+ /* @__PURE__ */ jsx26(
5051
+ GridBody,
5052
+ {
5053
+ columns: view.columns,
5054
+ definitions,
5055
+ rows: view.pageRows,
5056
+ activeColumnId: resize.activeColumnId,
5057
+ nav,
5058
+ selection,
5059
+ controller,
5060
+ aggregates,
5061
+ groupAggregateDisplay,
5062
+ virtualRange: virtualized ? virtualizer : null,
5063
+ infiniteScroll,
5064
+ sentinelRef,
5065
+ locale,
5066
+ getRowProps,
5067
+ onRowClick,
5068
+ onRowDoubleClick,
5069
+ messages,
5070
+ cellMenu: contextMenu.opens("cell"),
5071
+ groupMenu: contextMenu.opens("group")
5072
+ }
5073
+ )
5074
+ ]
5075
+ }
5076
+ )
5077
+ }
5078
+ ),
5079
+ hasFooter && /* @__PURE__ */ jsxs19(
5080
+ "table",
5081
+ {
5082
+ role: "presentation",
5083
+ style: { width: totalColumnWidth(view.columns) },
5084
+ className: classNames(
5085
+ gridTableClassName,
5086
+ "gridkit-data-grid-footer"
5087
+ ),
5088
+ children: [
5089
+ /* @__PURE__ */ jsx26(GridColgroup, { columns: view.columns }),
5090
+ /* @__PURE__ */ jsx26(
5091
+ GridFooter,
5092
+ {
5093
+ columns: view.columns,
5066
5094
  aggregates,
5067
- groupAggregateDisplay,
5068
- virtualRange: virtualized ? virtualizer : null,
5069
- infiniteScroll,
5070
- sentinelRef,
5095
+ results: view.grandTotal,
5096
+ rows: view.rows.map((entry) => entry.row),
5071
5097
  locale,
5072
- getRowProps,
5073
- onRowClick,
5074
- onRowDoubleClick,
5075
- messages,
5076
- cellMenu: contextMenu.opens("cell"),
5077
- groupMenu: contextMenu.opens("group")
5098
+ ariaRowIndex: view.displayRows.length + 2
5078
5099
  }
5079
5100
  )
5080
5101
  ]
5081
5102
  }
5082
5103
  )
5083
- }
5084
- ),
5085
- hasFooter && /* @__PURE__ */ jsxs19(
5086
- "table",
5087
- {
5088
- role: "presentation",
5089
- style: { width: totalColumnWidth(view.columns) },
5090
- className: classNames(
5091
- gridTableClassName,
5092
- "gridkit-data-grid-footer"
5093
- ),
5094
- children: [
5095
- /* @__PURE__ */ jsx26(GridColgroup, { columns: view.columns }),
5096
- /* @__PURE__ */ jsx26(
5097
- GridFooter,
5098
- {
5099
- columns: view.columns,
5100
- aggregates,
5101
- results: view.grandTotal,
5102
- rows: view.rows.map((entry) => entry.row),
5103
- locale,
5104
- ariaRowIndex: view.displayRows.length + 2
5105
- }
5106
- )
5107
- ]
5108
- }
5109
- )
5110
- ]
5111
- }
5112
- ),
5113
- /* @__PURE__ */ jsx26(GridContextMenu, { contextMenu }),
5114
- /* @__PURE__ */ jsx26(
5115
- GridPanels,
5116
- {
5117
- panels,
5118
- controller,
5119
- commands,
5120
- messages
5121
- }
5122
- ),
5123
- paginated && (pager?.template ? pager.template(pagerContext) : /* @__PURE__ */ jsx26(GridPager, { pager: pagerContext, config: pager, messages }))
5124
- ] });
5104
+ ]
5105
+ }
5106
+ ),
5107
+ /* @__PURE__ */ jsx26(GridContextMenu, { contextMenu }),
5108
+ /* @__PURE__ */ jsx26(
5109
+ GridPanels,
5110
+ {
5111
+ panels,
5112
+ controller,
5113
+ commands,
5114
+ messages
5115
+ }
5116
+ ),
5117
+ paginated && (pager?.template ? pager.template(pagerContext) : /* @__PURE__ */ jsx26(GridPager, { pager: pagerContext, config: pager, messages }))
5118
+ ]
5119
+ }
5120
+ );
5125
5121
  }
5126
5122
 
5127
5123
  // src/index.ts