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

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
@@ -34,10 +34,12 @@ import {
34
34
  } from "@gridkitjs/core";
35
35
  import {
36
36
  buildKeyShortcuts,
37
+ inlineStep,
37
38
  intentOf,
38
39
  KEYBOARD_STEP,
39
40
  resolveColumnFilterMenu
40
41
  } from "@gridkitjs/core/renderer";
42
+ import { writingDirection } from "@gridkitjs/dom";
41
43
 
42
44
  // src/DataGrid/ariaAttr.ts
43
45
  function ariaAttr(condition, key, value) {
@@ -228,16 +230,18 @@ function GridHeader({
228
230
  },
229
231
  onKeyDown: (event) => {
230
232
  if (!isOwnEvent(event)) return;
231
- const horizontal = event.key === "ArrowLeft" || event.key === "ArrowRight";
232
- const direction = event.key === "ArrowLeft" ? -1 : 1;
233
- if (horizontal && event.ctrlKey && entry.reorderable) {
233
+ const step = inlineStep(
234
+ event.key,
235
+ writingDirection(event.currentTarget)
236
+ );
237
+ if (step !== null && event.ctrlKey && entry.reorderable) {
234
238
  event.preventDefault();
235
- drag.moveByKeyboard(entry, direction);
239
+ drag.moveByKeyboard(entry, step);
236
240
  return;
237
241
  }
238
- if (horizontal && event.altKey && entry.resizable) {
242
+ if (step !== null && event.altKey && entry.resizable) {
239
243
  event.preventDefault();
240
- resize.nudge(entry, direction * KEYBOARD_STEP);
244
+ resize.nudge(entry, step * KEYBOARD_STEP);
241
245
  return;
242
246
  }
243
247
  if (event.key === "Enter" && event.altKey && entry.resizable) {
@@ -435,8 +439,7 @@ import {
435
439
  useState as useState2
436
440
  } from "react";
437
441
  import {
438
- bodyFocus,
439
- groupRowId
442
+ bodyFocus
440
443
  } from "@gridkitjs/core";
441
444
  import { intentOf as intentOf2 } from "@gridkitjs/core/renderer";
442
445
  import {
@@ -455,7 +458,8 @@ import {
455
458
  import {
456
459
  createGridFocus,
457
460
  findBodyRow,
458
- measurePageSize
461
+ measurePageSize,
462
+ writingDirection as writingDirection2
459
463
  } from "@gridkitjs/dom";
460
464
  function tabIndexFor(columnIndex, focusedColumnIndex) {
461
465
  return columnIndex === focusedColumnIndex ? 0 : -1;
@@ -519,7 +523,8 @@ function useGridNavigation({
519
523
  if (gridFocus.handleKey(
520
524
  event.key,
521
525
  event,
522
- measurePageSize(bodyTableRef.current)
526
+ measurePageSize(bodyTableRef.current),
527
+ writingDirection2(event.currentTarget)
523
528
  )) {
524
529
  event.preventDefault();
525
530
  }
@@ -686,6 +691,20 @@ var GridGroupRow_default = GridGroupRow;
686
691
 
687
692
  // src/DataGrid/components/GridGroupSummaryRow.tsx
688
693
  import { memo as memo2 } from "react";
694
+
695
+ // src/DataGrid/textAlign.ts
696
+ function textAlignFor(alignment) {
697
+ switch (alignment) {
698
+ case "left":
699
+ return "start";
700
+ case "right":
701
+ return "end";
702
+ case "center":
703
+ return "center";
704
+ }
705
+ }
706
+
707
+ // src/DataGrid/components/GridGroupSummaryRow.tsx
689
708
  import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
690
709
  function GridGroupSummaryRowComponent({
691
710
  groupId,
@@ -720,7 +739,9 @@ function GridGroupSummaryRowComponent({
720
739
  role: "gridcell",
721
740
  "data-gridkit-column": entry.id,
722
741
  className: "gridkit-grid-group-summary-cell",
723
- style: { textAlign: specs[0]?.alignment ?? entry.alignment },
742
+ style: {
743
+ textAlign: textAlignFor(specs[0]?.alignment ?? entry.alignment)
744
+ },
724
745
  children: [
725
746
  entry.id === columns[0]?.id && /* @__PURE__ */ jsx5(
726
747
  "span",
@@ -767,6 +788,9 @@ function GridRowComponent({
767
788
  row,
768
789
  rowIndex,
769
790
  datasetIndex,
791
+ groupLevel,
792
+ groupPosition,
793
+ groupSetSize,
770
794
  activeColumnId,
771
795
  selectedColumnIds,
772
796
  selected,
@@ -794,6 +818,9 @@ function GridRowComponent({
794
818
  "aria-rowindex": datasetIndex + 2,
795
819
  "data-gridkit-row-index": rowIndex,
796
820
  "data-gridkit-row-id": rowId,
821
+ "aria-level": groupLevel === void 0 ? void 0 : groupLevel + 1,
822
+ "aria-posinset": groupPosition,
823
+ "aria-setsize": groupSetSize,
797
824
  ...ariaAttr(rowsSelectable, "aria-selected", selected),
798
825
  className: classNames(
799
826
  "gridkit-grid-row",
@@ -819,7 +846,7 @@ function GridRowComponent({
819
846
  column.wrap?.cells ? "is-wrapped" : "",
820
847
  column.cellClassName ?? ""
821
848
  ),
822
- style: { textAlign: alignment },
849
+ style: { textAlign: textAlignFor(alignment) },
823
850
  children: column.cellTemplate ? column.cellTemplate({
824
851
  value,
825
852
  row,
@@ -840,27 +867,6 @@ var GridRow_default = GridRow;
840
867
 
841
868
  // src/DataGrid/components/GridBody.tsx
842
869
  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
870
  function GridBody({
865
871
  columns,
866
872
  definitions,
@@ -883,7 +889,6 @@ function GridBody({
883
889
  groupMenu
884
890
  }) {
885
891
  const { selectedCell, rowMode, cellMode, toggleOnClick } = selection;
886
- const ariaMeta = useMemo2(() => groupAriaMeta(rows), [rows]);
887
892
  const visibleRows = virtualRange === null ? rows : rows.slice(virtualRange.startIndex, virtualRange.endIndex + 1);
888
893
  const { booleanTrue, booleanFalse, blankGroupValue } = messages;
889
894
  const cellMessages = useMemo2(
@@ -941,7 +946,7 @@ function GridBody({
941
946
  return /* @__PURE__ */ jsxs5(
942
947
  "tbody",
943
948
  {
944
- role: "rowgroup",
949
+ role: "presentation",
945
950
  className: "gridkit-grid-body",
946
951
  onFocus: (event) => {
947
952
  const group = groupRowFrom(event.target);
@@ -1029,6 +1034,9 @@ function GridBody({
1029
1034
  row: entry.row,
1030
1035
  rowIndex: entry.rowIndex,
1031
1036
  datasetIndex: entry.datasetIndex,
1037
+ groupLevel: entry.groupPosition?.level,
1038
+ groupPosition: entry.groupPosition?.position,
1039
+ groupSetSize: entry.groupPosition?.setSize,
1032
1040
  activeColumnId,
1033
1041
  selectedColumnIds: selection.selectedColumnIds,
1034
1042
  selected: selection.selectedRowIds.has(entry.rowId),
@@ -1078,8 +1086,8 @@ function GridBody({
1078
1086
  count: entry.count,
1079
1087
  rowIndex: entry.rowIndex,
1080
1088
  datasetIndex: entry.datasetIndex,
1081
- posinset: ariaMeta.get(entry.groupId)?.posinset ?? 1,
1082
- setsize: ariaMeta.get(entry.groupId)?.setsize ?? 1,
1089
+ posinset: entry.position,
1090
+ setsize: entry.setSize,
1083
1091
  aggregates: groupAggregateDisplay === "inline" ? aggregates : [],
1084
1092
  results: entry.aggregates,
1085
1093
  definitions,
@@ -1160,7 +1168,9 @@ function GridFooter({
1160
1168
  role: "gridcell",
1161
1169
  "data-gridkit-column": entry.id,
1162
1170
  className: "gridkit-grid-footer-cell",
1163
- style: { textAlign: specs[0]?.alignment ?? entry.alignment },
1171
+ style: {
1172
+ textAlign: textAlignFor(specs[0]?.alignment ?? entry.alignment)
1173
+ },
1164
1174
  children: specs.map(
1165
1175
  (spec) => renderAggregate(
1166
1176
  results.get(spec.id ?? spec.columnId),
@@ -1334,7 +1344,11 @@ import { createPortal as createPortal2 } from "react-dom";
1334
1344
  import {
1335
1345
  resolveColumnLabel as resolveColumnLabel2
1336
1346
  } from "@gridkitjs/core";
1337
- import { resolveKeyboardDropTarget } from "@gridkitjs/core/renderer";
1347
+ import {
1348
+ inlineStep as inlineStep2,
1349
+ resolveKeyboardDropTarget
1350
+ } from "@gridkitjs/core/renderer";
1351
+ import { writingDirection as writingDirection3 } from "@gridkitjs/dom";
1338
1352
 
1339
1353
  // src/DataGrid/useGroupByDrag.ts
1340
1354
  import {
@@ -1525,13 +1539,13 @@ function GroupByBar({
1525
1539
  chipDrag.startDrag(entry.columnId, event);
1526
1540
  },
1527
1541
  onKeyDown: (event) => {
1528
- const horizontal = event.key === "ArrowLeft" || event.key === "ArrowRight";
1529
- if (horizontal && event.ctrlKey) {
1542
+ const step = inlineStep2(
1543
+ event.key,
1544
+ writingDirection3(event.currentTarget)
1545
+ );
1546
+ if (step !== null && event.ctrlKey) {
1530
1547
  event.preventDefault();
1531
- moveByKeyboard(
1532
- entry.columnId,
1533
- event.key === "ArrowLeft" ? -1 : 1
1534
- );
1548
+ moveByKeyboard(entry.columnId, step);
1535
1549
  }
1536
1550
  },
1537
1551
  children: [
@@ -1977,20 +1991,27 @@ import {
1977
1991
  import { useLayoutEffect as useLayoutEffect3, useRef as useRef5 } from "react";
1978
1992
  import { createPortal as createPortal3 } from "react-dom";
1979
1993
  import {
1980
- attachOverlay
1994
+ attachOverlay,
1995
+ writingDirection as writingDirection4
1981
1996
  } from "@gridkitjs/dom";
1982
1997
  import { jsx as jsx11 } from "react/jsx-runtime";
1983
1998
  var ANCHOR_GAP = 4;
1984
1999
  function attachedFocus(focus) {
1985
2000
  return typeof focus === "object" && !(focus instanceof HTMLElement) ? focus.current ?? "first" : focus;
1986
2001
  }
1987
- function overlayThemeClassName(element) {
2002
+ function themeClassNameOf(element) {
1988
2003
  const scope = element?.closest(".gridkit-light, .gridkit-dark");
1989
2004
  if (scope === null || scope === void 0) {
1990
2005
  return "";
1991
2006
  }
1992
2007
  return scope.classList.contains("gridkit-dark") ? "gridkit-dark" : "gridkit-light";
1993
2008
  }
2009
+ function overlayScope(element) {
2010
+ return {
2011
+ themeClassName: themeClassNameOf(element),
2012
+ direction: writingDirection4(element ?? document.documentElement)
2013
+ };
2014
+ }
1994
2015
  function Overlay({
1995
2016
  anchor,
1996
2017
  placement,
@@ -2001,7 +2022,7 @@ function Overlay({
2001
2022
  returnFocusFallback,
2002
2023
  ignoreScrollAfterInput,
2003
2024
  trapFocus,
2004
- themeClassName,
2025
+ scope,
2005
2026
  onDismiss,
2006
2027
  children
2007
2028
  }) {
@@ -2045,7 +2066,8 @@ function Overlay({
2045
2066
  "div",
2046
2067
  {
2047
2068
  ref: panelRef,
2048
- className: classNames("gridkit-overlay", themeClassName),
2069
+ className: classNames("gridkit-overlay", scope.themeClassName),
2070
+ dir: scope.direction,
2049
2071
  children
2050
2072
  }
2051
2073
  ),
@@ -2153,7 +2175,7 @@ function MenuItem({
2153
2175
  function GridMenu({
2154
2176
  entries,
2155
2177
  label,
2156
- themeClassName,
2178
+ scope,
2157
2179
  onRun,
2158
2180
  onClose,
2159
2181
  onCloseSubmenu,
@@ -2273,14 +2295,14 @@ function GridMenu({
2273
2295
  placement: "right-start",
2274
2296
  offset: submenu.offset,
2275
2297
  initialFocus: submenu.focus,
2276
- themeClassName,
2298
+ scope,
2277
2299
  onDismiss: closeSubmenu,
2278
2300
  children: /* @__PURE__ */ jsx13(
2279
2301
  GridMenu,
2280
2302
  {
2281
2303
  entries: openEntry.items,
2282
2304
  label: openEntry.label,
2283
- themeClassName,
2305
+ scope,
2284
2306
  onRun,
2285
2307
  onClose,
2286
2308
  onCloseSubmenu: closeSubmenu,
@@ -2309,14 +2331,14 @@ function GridContextMenu({
2309
2331
  gap: menu.anchor instanceof Element ? ANCHOR_GAP : 0,
2310
2332
  returnFocusTo: menu.cell ?? void 0,
2311
2333
  returnFocusFallback,
2312
- themeClassName: menu.themeClassName,
2334
+ scope: menu.scope,
2313
2335
  onDismiss: close,
2314
2336
  children: /* @__PURE__ */ jsx14(
2315
2337
  GridMenu,
2316
2338
  {
2317
2339
  entries: menu.entries,
2318
2340
  label: menu.label,
2319
- themeClassName: menu.themeClassName,
2341
+ scope: menu.scope,
2320
2342
  onRun: run,
2321
2343
  onClose: close
2322
2344
  }
@@ -2352,7 +2374,8 @@ import {
2352
2374
  bodyCellFrom as bodyCellFrom2,
2353
2375
  bodyRowFrom as bodyRowFrom2,
2354
2376
  findBodyRow as findBodyRow2,
2355
- groupRowFrom as groupRowFrom2
2377
+ groupRowFrom as groupRowFrom2,
2378
+ writingDirection as writingDirection5
2356
2379
  } from "@gridkitjs/dom";
2357
2380
  function headerCell(parts, columnIndex) {
2358
2381
  const element = parts.headerTable?.tHead?.rows[0]?.cells[columnIndex];
@@ -2380,6 +2403,9 @@ function viewOf(element, parts) {
2380
2403
  function clamp(value, min, max) {
2381
2404
  return Math.min(Math.max(value, min), max);
2382
2405
  }
2406
+ function inlineStartOf(element, box) {
2407
+ return writingDirection5(element) === "rtl" ? box.right : box.left;
2408
+ }
2383
2409
  function onCell(target, cell, parts) {
2384
2410
  if (cell === null) {
2385
2411
  return null;
@@ -2393,14 +2419,18 @@ function onCell(target, cell, parts) {
2393
2419
  target,
2394
2420
  cell,
2395
2421
  anchor: {
2396
- x: clamp(box.left, view.left, view.right),
2422
+ x: clamp(inlineStartOf(cell.element, box), view.left, view.right),
2397
2423
  y: clamp(box.bottom, view.top, view.bottom)
2398
2424
  }
2399
2425
  };
2400
2426
  }
2401
2427
  function onBody(body) {
2402
- const { left, top } = body.getBoundingClientRect();
2403
- return { target: { area: "body" }, cell: null, anchor: { x: left, y: top } };
2428
+ const box = body.getBoundingClientRect();
2429
+ return {
2430
+ target: { area: "body" },
2431
+ cell: null,
2432
+ anchor: { x: inlineStartOf(body, box), y: box.top }
2433
+ };
2404
2434
  }
2405
2435
  function headerPlaceAt(element, parts) {
2406
2436
  const cell = element.closest("th[data-gridkit-column]");
@@ -2571,7 +2601,7 @@ function useContextMenu({
2571
2601
  label: labelOf(target),
2572
2602
  anchor: point ?? anchor,
2573
2603
  cell: cell?.element ?? null,
2574
- themeClassName: overlayThemeClassName(rootRef.current)
2604
+ scope: overlayScope(rootRef.current)
2575
2605
  }
2576
2606
  });
2577
2607
  return true;
@@ -2823,7 +2853,7 @@ function useMenuButton({
2823
2853
  setState({
2824
2854
  kind: "open",
2825
2855
  anchor: button,
2826
- themeClassName: overlayThemeClassName(button),
2856
+ scope: overlayScope(button),
2827
2857
  gap: gap(button),
2828
2858
  focusItem: onLast ? itemCount - 1 : 0
2829
2859
  });
@@ -2914,14 +2944,14 @@ function OperatorMenuButton({
2914
2944
  placement: "right-start",
2915
2945
  gap: state.gap,
2916
2946
  returnFocusTo: state.anchor,
2917
- themeClassName: state.themeClassName,
2947
+ scope: state.scope,
2918
2948
  onDismiss: close,
2919
2949
  children: /* @__PURE__ */ jsx16(
2920
2950
  GridMenu,
2921
2951
  {
2922
2952
  entries,
2923
2953
  label,
2924
- themeClassName: state.themeClassName,
2954
+ scope: state.scope,
2925
2955
  behaviourRef,
2926
2956
  onRun: (item) => {
2927
2957
  item.run();
@@ -3777,7 +3807,7 @@ function GridPanels({
3777
3807
  returnFocusFallback,
3778
3808
  ignoreScrollAfterInput: true,
3779
3809
  trapFocus,
3780
- themeClassName: panel.themeClassName,
3810
+ scope: panel.scope,
3781
3811
  onDismiss: close,
3782
3812
  children: /* @__PURE__ */ jsx22(
3783
3813
  Panel,
@@ -3824,6 +3854,9 @@ function panelApi(panels, controller) {
3824
3854
 
3825
3855
  // src/DataGrid/panels/useGridPanels.ts
3826
3856
  import { useRef as useRef16 } from "react";
3857
+ import {
3858
+ writingDirection as writingDirection6
3859
+ } from "@gridkitjs/dom";
3827
3860
  function toolbarItem(root, itemId) {
3828
3861
  const items = root.querySelectorAll(
3829
3862
  ":scope > .gridkit-toolbar > [data-gridkit-toolbar-item]"
@@ -3860,9 +3893,9 @@ function useGridPanels({
3860
3893
  returnFocusTo: element
3861
3894
  };
3862
3895
  }
3863
- const { right, top } = root.getBoundingClientRect();
3896
+ const { left, right, top } = root.getBoundingClientRect();
3864
3897
  return {
3865
- anchor: { x: right, y: top },
3898
+ anchor: { x: writingDirection6(root) === "rtl" ? left : right, y: top },
3866
3899
  placement: "bottom-end",
3867
3900
  returnFocusTo: void 0
3868
3901
  };
@@ -3883,7 +3916,7 @@ function useGridPanels({
3883
3916
  kind,
3884
3917
  target,
3885
3918
  ...placeFor(root, target),
3886
- themeClassName: overlayThemeClassName(root)
3919
+ scope: overlayScope(root)
3887
3920
  }
3888
3921
  });
3889
3922
  },
@@ -3945,14 +3978,14 @@ function ToolbarMenuButton({
3945
3978
  gap: state.gap,
3946
3979
  returnFocusTo: state.anchor,
3947
3980
  returnFocusFallback,
3948
- themeClassName: state.themeClassName,
3981
+ scope: state.scope,
3949
3982
  onDismiss: close,
3950
3983
  children: /* @__PURE__ */ jsx23(
3951
3984
  GridMenu,
3952
3985
  {
3953
3986
  entries,
3954
3987
  label,
3955
- themeClassName: state.themeClassName,
3988
+ scope: state.scope,
3956
3989
  behaviourRef,
3957
3990
  onRun: (item) => {
3958
3991
  item.run();
@@ -4947,181 +4980,191 @@ function DataGrid(props) {
4947
4980
  selection.cellMode === false ? "" : "gridkit-selectable-cells"
4948
4981
  );
4949
4982
  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;
4983
+ return /* @__PURE__ */ jsxs19(
4984
+ "div",
4985
+ {
4986
+ className: "gridkit-data-grid-viewport",
4987
+ ref: viewportRef,
4988
+ tabIndex: -1,
4989
+ children: [
4990
+ /* @__PURE__ */ jsx26(
4991
+ GridToolbar,
4992
+ {
4993
+ toolbar: props.toolbar,
4994
+ renderItem: props.renderToolbarItem,
4995
+ gridId,
4996
+ controller,
4997
+ commands,
4998
+ messages,
4999
+ announce
5001
5000
  }
5002
- if ((event.ctrlKey || event.metaKey) && (event.key === "a" || event.key === "A")) {
5003
- if (selection.rowMode !== "multiple") return;
5004
- event.preventDefault();
5005
- selection.selectAllRows();
5001
+ ),
5002
+ showGroupByBar && /* @__PURE__ */ jsx26(
5003
+ GroupByBar,
5004
+ {
5005
+ columns: view.columns,
5006
+ definitions,
5007
+ groupBy: state.groupBy,
5008
+ controller,
5009
+ columnName,
5010
+ headerDragEligible: dragEligibleForGroupBy,
5011
+ headerDragBlocked: draggedColumnAlreadyGrouped,
5012
+ headerDropTarget: headerGroupByDropTarget,
5013
+ messages
5006
5014
  }
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(
5015
+ ),
5016
+ /* @__PURE__ */ jsxs19(
5017
+ "div",
5018
+ {
5019
+ ref: gridRef,
5020
+ id: gridId,
5021
+ className: "gridkit-data-grid-tables",
5022
+ role: state.groupBy.length > 0 ? "treegrid" : "grid",
5023
+ "aria-rowcount": view.displayRows.length + (hasFooter ? 2 : 1),
5024
+ "aria-colcount": view.columns.length,
5025
+ ...ariaAttr(multiselectable, "aria-multiselectable", true),
5026
+ ...ariaAttr(labelledBy !== void 0, "aria-labelledby", labelledBy),
5027
+ ...ariaAttr(
5028
+ labelledBy === void 0 && label !== void 0,
5029
+ "aria-label",
5030
+ label
5031
+ ),
5032
+ onKeyDown: (event) => {
5033
+ if (!isOwnEvent(event)) return;
5034
+ handleCopyKey(event);
5035
+ if (event.key === "Escape") {
5036
+ if (drag.draggedColumnId !== null || resize.activeColumnId !== null)
5037
+ return;
5038
+ selection.clear();
5039
+ return;
5040
+ }
5041
+ if ((event.ctrlKey || event.metaKey) && (event.key === "a" || event.key === "A")) {
5042
+ if (selection.rowMode !== "multiple") return;
5043
+ event.preventDefault();
5044
+ selection.selectAllRows();
5045
+ }
5046
+ },
5047
+ children: [
5048
+ /* @__PURE__ */ jsxs19(
5048
5049
  "table",
5049
5050
  {
5050
- ref: bodyTableRef,
5051
+ ref: headerTableRef,
5051
5052
  role: "presentation",
5052
5053
  style: { width: totalColumnWidth(view.columns) },
5053
- className: gridTableClassName,
5054
+ className: classNames(gridTableClassName, "gridkit-data-grid-header"),
5054
5055
  children: [
5055
5056
  /* @__PURE__ */ jsx26(GridColgroup, { columns: view.columns }),
5056
5057
  /* @__PURE__ */ jsx26(
5057
- GridBody,
5058
+ GridHeader,
5058
5059
  {
5059
5060
  columns: view.columns,
5060
- definitions,
5061
- rows: view.pageRows,
5062
- activeColumnId: resize.activeColumnId,
5063
- nav,
5064
- selection,
5061
+ resize,
5062
+ drag,
5065
5063
  controller,
5064
+ state,
5065
+ sortableColumns,
5066
+ groupableColumns,
5067
+ groupToggleIconColumns,
5068
+ headerMenu: contextMenu.opens("header"),
5069
+ panels,
5070
+ messages,
5071
+ nav,
5072
+ selection
5073
+ }
5074
+ )
5075
+ ]
5076
+ }
5077
+ ),
5078
+ /* @__PURE__ */ jsx26(
5079
+ "div",
5080
+ {
5081
+ className: "gridkit-data-grid-body",
5082
+ ref: bodyScrollRef,
5083
+ role: "rowgroup",
5084
+ tabIndex: -1,
5085
+ style: height === void 0 ? void 0 : {
5086
+ "--gridkit-body-height": typeof height === "number" ? `${String(height)}px` : height
5087
+ },
5088
+ children: /* @__PURE__ */ jsxs19(
5089
+ "table",
5090
+ {
5091
+ ref: bodyTableRef,
5092
+ role: "presentation",
5093
+ style: { width: totalColumnWidth(view.columns) },
5094
+ className: gridTableClassName,
5095
+ children: [
5096
+ /* @__PURE__ */ jsx26(GridColgroup, { columns: view.columns }),
5097
+ /* @__PURE__ */ jsx26(
5098
+ GridBody,
5099
+ {
5100
+ columns: view.columns,
5101
+ definitions,
5102
+ rows: view.pageRows,
5103
+ activeColumnId: resize.activeColumnId,
5104
+ nav,
5105
+ selection,
5106
+ controller,
5107
+ aggregates,
5108
+ groupAggregateDisplay,
5109
+ virtualRange: virtualized ? virtualizer : null,
5110
+ infiniteScroll,
5111
+ sentinelRef,
5112
+ locale,
5113
+ getRowProps,
5114
+ onRowClick,
5115
+ onRowDoubleClick,
5116
+ messages,
5117
+ cellMenu: contextMenu.opens("cell"),
5118
+ groupMenu: contextMenu.opens("group")
5119
+ }
5120
+ )
5121
+ ]
5122
+ }
5123
+ )
5124
+ }
5125
+ ),
5126
+ hasFooter && /* @__PURE__ */ jsxs19(
5127
+ "table",
5128
+ {
5129
+ role: "presentation",
5130
+ style: { width: totalColumnWidth(view.columns) },
5131
+ className: classNames(
5132
+ gridTableClassName,
5133
+ "gridkit-data-grid-footer"
5134
+ ),
5135
+ children: [
5136
+ /* @__PURE__ */ jsx26(GridColgroup, { columns: view.columns }),
5137
+ /* @__PURE__ */ jsx26(
5138
+ GridFooter,
5139
+ {
5140
+ columns: view.columns,
5066
5141
  aggregates,
5067
- groupAggregateDisplay,
5068
- virtualRange: virtualized ? virtualizer : null,
5069
- infiniteScroll,
5070
- sentinelRef,
5142
+ results: view.grandTotal,
5143
+ rows: view.rows.map((entry) => entry.row),
5071
5144
  locale,
5072
- getRowProps,
5073
- onRowClick,
5074
- onRowDoubleClick,
5075
- messages,
5076
- cellMenu: contextMenu.opens("cell"),
5077
- groupMenu: contextMenu.opens("group")
5145
+ ariaRowIndex: view.displayRows.length + 2
5078
5146
  }
5079
5147
  )
5080
5148
  ]
5081
5149
  }
5082
5150
  )
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
- ] });
5151
+ ]
5152
+ }
5153
+ ),
5154
+ /* @__PURE__ */ jsx26(GridContextMenu, { contextMenu }),
5155
+ /* @__PURE__ */ jsx26(
5156
+ GridPanels,
5157
+ {
5158
+ panels,
5159
+ controller,
5160
+ commands,
5161
+ messages
5162
+ }
5163
+ ),
5164
+ paginated && (pager?.template ? pager.template(pagerContext) : /* @__PURE__ */ jsx26(GridPager, { pager: pagerContext, config: pager, messages }))
5165
+ ]
5166
+ }
5167
+ );
5125
5168
  }
5126
5169
 
5127
5170
  // src/index.ts