@gridkitjs/react 0.0.0-dev-20261111180407 → 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.js CHANGED
@@ -842,14 +842,14 @@ import { Fragment, jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
842
842
  function groupAriaMeta(rows) {
843
843
  const totals = /* @__PURE__ */ new Map();
844
844
  for (const entry of rows) {
845
- if (!("kind" in entry) || entry.kind !== "group") continue;
845
+ if (entry.kind !== "group") continue;
846
846
  const parentKey = groupRowId(entry.path.slice(0, -1));
847
847
  totals.set(parentKey, (totals.get(parentKey) ?? 0) + 1);
848
848
  }
849
849
  const seen = /* @__PURE__ */ new Map();
850
850
  const meta = /* @__PURE__ */ new Map();
851
851
  for (const entry of rows) {
852
- if (!("kind" in entry) || entry.kind !== "group") continue;
852
+ if (entry.kind !== "group") continue;
853
853
  const parentKey = groupRowId(entry.path.slice(0, -1));
854
854
  const posinset = (seen.get(parentKey) ?? 0) + 1;
855
855
  seen.set(parentKey, posinset);
@@ -892,14 +892,14 @@ function GridBody({
892
892
  const [resolveRowProps] = useState2(() => createRowPropsResolver());
893
893
  const rowPropsOf = resolveRowProps(
894
894
  visibleRows.filter(
895
- (entry) => !("kind" in entry)
895
+ (entry) => entry.kind === "data"
896
896
  ),
897
897
  getRowProps
898
898
  );
899
899
  function targetOf(target) {
900
900
  const position = bodyCellFrom(target);
901
901
  const entry = position === null ? void 0 : rows[position.rowIndex];
902
- if (position === null || entry === void 0 || "kind" in entry) {
902
+ if (position === null || entry?.kind !== "data") {
903
903
  return null;
904
904
  }
905
905
  return { position, rowId: entry.rowId };
@@ -915,7 +915,7 @@ function GridBody({
915
915
  function rowPointerEventOf(event) {
916
916
  const target = bodyRowFrom(event.target);
917
917
  const entry = target === null ? void 0 : rows[target.rowIndex];
918
- if (target === null || entry === void 0 || "kind" in entry) {
918
+ if (target === null || entry?.kind !== "data") {
919
919
  return null;
920
920
  }
921
921
  return {
@@ -1016,75 +1016,82 @@ function GridBody({
1016
1016
  }
1017
1017
  ) }),
1018
1018
  visibleRows.map((entry) => {
1019
- if (!("kind" in entry)) {
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(nav.focus, entry.rowIndex),
1035
- rowsSelectable: rowMode !== false,
1036
- cellsSelectable: cellMode !== false,
1037
- contextMenu: cellMenu,
1038
- locale,
1039
- cellMessages,
1040
- rowClassName: rowProps.className,
1041
- rowAttributes: rowProps.attributes
1042
- },
1043
- entry.rowId
1044
- );
1045
- }
1046
- if (entry.kind === "group-summary") {
1047
- return /* @__PURE__ */ jsx7(
1048
- GridGroupSummaryRow_default,
1049
- {
1050
- ref: virtualRange?.measureRow(entry.rowIndex),
1051
- groupId: entry.groupId,
1052
- level: entry.level,
1053
- rowIndex: entry.rowIndex,
1054
- datasetIndex: entry.datasetIndex,
1055
- results: entry.aggregates,
1056
- aggregates,
1057
- columns,
1058
- locale
1059
- },
1060
- `${entry.groupId}-summary`
1061
- );
1019
+ switch (entry.kind) {
1020
+ case "data": {
1021
+ const rowProps = rowPropsOf(entry.rowId);
1022
+ return /* @__PURE__ */ jsx7(
1023
+ GridRow_default,
1024
+ {
1025
+ ref: virtualRange?.measureRow(entry.rowIndex),
1026
+ columns,
1027
+ rowId: entry.rowId,
1028
+ row: entry.row,
1029
+ rowIndex: entry.rowIndex,
1030
+ datasetIndex: entry.datasetIndex,
1031
+ activeColumnId,
1032
+ selectedColumnIds: selection.selectedColumnIds,
1033
+ selected: selection.selectedRowIds.has(entry.rowId),
1034
+ selectedColumnId: selectedCell?.rowId === entry.rowId ? selectedCell.columnId : null,
1035
+ focusedColumnIndex: focusedColumnInRow(
1036
+ nav.focus,
1037
+ entry.rowIndex
1038
+ ),
1039
+ rowsSelectable: rowMode !== false,
1040
+ cellsSelectable: cellMode !== false,
1041
+ contextMenu: cellMenu,
1042
+ locale,
1043
+ cellMessages,
1044
+ rowClassName: rowProps.className,
1045
+ rowAttributes: rowProps.attributes
1046
+ },
1047
+ entry.rowId
1048
+ );
1049
+ }
1050
+ case "group-summary":
1051
+ return /* @__PURE__ */ jsx7(
1052
+ GridGroupSummaryRow_default,
1053
+ {
1054
+ ref: virtualRange?.measureRow(entry.rowIndex),
1055
+ groupId: entry.groupId,
1056
+ level: entry.level,
1057
+ rowIndex: entry.rowIndex,
1058
+ datasetIndex: entry.datasetIndex,
1059
+ results: entry.aggregates,
1060
+ aggregates,
1061
+ columns,
1062
+ locale
1063
+ },
1064
+ `${entry.groupId}-summary`
1065
+ );
1066
+ case "group":
1067
+ return /* @__PURE__ */ jsx7(
1068
+ GridGroupRow_default,
1069
+ {
1070
+ ref: virtualRange?.measureRow(entry.rowIndex),
1071
+ columnCount: columns.length,
1072
+ groupId: entry.groupId,
1073
+ level: entry.level,
1074
+ groupColumn: definitions.get(entry.columnId) ?? { field: entry.columnId },
1075
+ value: entry.value,
1076
+ expanded: entry.expanded,
1077
+ count: entry.count,
1078
+ rowIndex: entry.rowIndex,
1079
+ datasetIndex: entry.datasetIndex,
1080
+ posinset: ariaMeta.get(entry.groupId)?.posinset ?? 1,
1081
+ setsize: ariaMeta.get(entry.groupId)?.setsize ?? 1,
1082
+ aggregates: groupAggregateDisplay === "inline" ? aggregates : [],
1083
+ results: entry.aggregates,
1084
+ definitions,
1085
+ locale,
1086
+ cellMessages,
1087
+ focused: focusedColumnInRow(nav.focus, entry.rowIndex) !== null,
1088
+ contextMenu: groupMenu
1089
+ },
1090
+ entry.groupId
1091
+ );
1092
+ default:
1093
+ return entry;
1062
1094
  }
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
1095
  }),
1089
1096
  virtualRange !== null && virtualRange.offsetAfter > 0 && /* @__PURE__ */ jsx7("tr", { "aria-hidden": "true", children: /* @__PURE__ */ jsx7(
1090
1097
  "td",
@@ -1716,7 +1723,7 @@ function useGridCopy({
1716
1723
  const { pageRows, columns } = controller.getView();
1717
1724
  const entry = pageRows[focus.rowIndex];
1718
1725
  const column = columns[focus.columnIndex];
1719
- return entry === void 0 || "kind" in entry || column === void 0 ? null : { area: "cell", rowId: entry.rowId, columnId: column.id };
1726
+ return entry?.kind !== "data" || column === void 0 ? null : { area: "cell", rowId: entry.rowId, columnId: column.id };
1720
1727
  }
1721
1728
  return (event) => {
1722
1729
  if (!isCopyKey(event) || isNativeCopy(event.target)) {
@@ -2386,7 +2393,7 @@ function bodyPlaceAt(element, parts) {
2386
2393
  if (group !== null) {
2387
2394
  const entry = pageRows[group.rowIndex];
2388
2395
  const cell = bodyCell(parts, group.rowIndex, 0);
2389
- return entry !== void 0 && "kind" in entry && entry.kind === "group" && cell?.element.contains(element) === true ? onCell(
2396
+ return entry !== void 0 && entry.kind === "group" && cell?.element.contains(element) === true ? onCell(
2390
2397
  { area: "group", groupId: entry.groupId, columnId: entry.columnId },
2391
2398
  cell,
2392
2399
  parts
@@ -2396,7 +2403,7 @@ function bodyPlaceAt(element, parts) {
2396
2403
  if (position !== null) {
2397
2404
  const entry = pageRows[position.rowIndex];
2398
2405
  const cell = bodyCell(parts, position.rowIndex, position.columnIndex);
2399
- return entry !== void 0 && !("kind" in entry) && cell?.element.contains(element) === true ? onCell(
2406
+ return entry !== void 0 && entry.kind === "data" && cell?.element.contains(element) === true ? onCell(
2400
2407
  { area: "cell", rowId: entry.rowId, columnId: position.columnId },
2401
2408
  cell,
2402
2409
  parts
@@ -2418,7 +2425,7 @@ function placeOf(target, parts) {
2418
2425
  );
2419
2426
  case "cell": {
2420
2427
  const rowIndex = parts.pageRows.findIndex(
2421
- (entry) => !("kind" in entry) && entry.rowId === target.rowId
2428
+ (entry) => entry.kind === "data" && entry.rowId === target.rowId
2422
2429
  );
2423
2430
  return onCell(
2424
2431
  target,
@@ -2428,7 +2435,7 @@ function placeOf(target, parts) {
2428
2435
  }
2429
2436
  case "group": {
2430
2437
  const rowIndex = parts.pageRows.findIndex(
2431
- (entry) => "kind" in entry && entry.kind === "group" && entry.groupId === target.groupId
2438
+ (entry) => entry.kind === "group" && entry.groupId === target.groupId
2432
2439
  );
2433
2440
  return onCell(target, bodyCell(parts, rowIndex, 0), parts);
2434
2441
  }
@@ -4685,7 +4692,7 @@ function DataGrid(props) {
4685
4692
  // vertical movement steps over it rather than landing there.
4686
4693
  isSkippableRow: (rowIndex) => {
4687
4694
  const entry = view.pageRows[rowIndex];
4688
- return entry !== void 0 && "kind" in entry && entry.kind === "group-summary";
4695
+ return entry?.kind === "group-summary";
4689
4696
  }
4690
4697
  });
4691
4698
  const overlay = useGridOverlay({
@@ -4856,7 +4863,7 @@ function DataGrid(props) {
4856
4863
  runCommand: (commandId, target = { area: "grid" }) => commands.run(commandId, target, "api"),
4857
4864
  scrollToRow: (rowId, options) => {
4858
4865
  const index = controller.getView().pageRows.findIndex(
4859
- (entry) => !("kind" in entry) && entry.rowId === rowId
4866
+ (entry) => entry.kind === "data" && entry.rowId === rowId
4860
4867
  );
4861
4868
  if (index === -1) return;
4862
4869
  if (virtualized) {