@gridkitjs/react 0.0.0-dev-20261118190822 → 0.0.0-dev-20261118223155

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
- 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, RowGroupPosition, RowPointerEvent, RowProps, RowSelectEvent, RowSelectionChangeEvent, RowsSelectEvent, SelectableConfig, SelectedCellRef, SelectionMode, SelectionState, SerializedGridState, SortDirection, 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, ColumnPinningState, ColumnSortState, FilterState, GroupByState, GroupExpansionState, AggregateResults, SelectionState, CellSelectionState, GridFocus, GridState, SerializedGridState, ColumnPin, 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, ColumnPin, ColumnPinningEvent, ColumnPinningState, 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 {
@@ -122,6 +122,8 @@ interface DataGridApi<Row> extends GridExportApi, GridPrintApi, GridPanelApi {
122
122
  getColumnOrder(): ColumnOrderState;
123
123
  /** Columns shown or hidden since the grid mounted. A column absent from it follows its definition's `hidden`. */
124
124
  getColumnVisibility(): ColumnVisibilityState;
125
+ /** Columns pinned or unpinned since the grid mounted. A column absent from it follows its definition's `pinned`. */
126
+ getColumnPinning(): ColumnPinningState;
125
127
  getColumnSort(): ColumnSortState;
126
128
  /** The filter the rows are shown through — every entry, ANDed together. */
127
129
  getFilter(): FilterState<Row>;
@@ -205,6 +207,13 @@ interface DataGridApi<Row> extends GridExportApi, GridPrintApi, GridPanelApi {
205
207
  * filters and groups, and keeps its place in the column order.
206
208
  */
207
209
  hideColumns(columnIds: readonly string[]): void;
210
+ /**
211
+ * Pins a column to the `"start"` or `"end"` edge, or unpins it with
212
+ * `"none"`, leaving the column order as it is: an unpinned column goes
213
+ * back to its place among the others. Reports one
214
+ * `onColumnPinningChange`, and none when the column is already there.
215
+ */
216
+ pinColumn(columnId: string, pin: ColumnPin): void;
208
217
  /**
209
218
  * Replaces the filter, the way a filter UI would, and sends an uncontrolled
210
219
  * grid back to its first page. Reports one `onFilterChange`, and none when
@@ -230,6 +239,8 @@ interface DataGridApi<Row> extends GridExportApi, GridPrintApi, GridPanelApi {
230
239
  setColumnOrder(order: ColumnOrderState): void;
231
240
  /** Replaces the column visibility state. Reports through `onColumnVisibilityChange`. */
232
241
  setColumnVisibility(visibility: ColumnVisibilityState): void;
242
+ /** Replaces the column pinning state. Reports through `onColumnPinningChange`. */
243
+ setColumnPinning(pinning: ColumnPinningState): void;
233
244
  /** Replaces the selected row ids as given, whatever `selectable` allows. Fires the row selection callbacks. */
234
245
  setRowSelection(selection: SelectionState): void;
235
246
  /** Replaces the selected column ids as given. Fires the column selection callbacks. */
@@ -490,6 +501,16 @@ declare function useColumnOrderState<Row>(gridRef: RefObject<DataGridApi<Row> |
490
501
  */
491
502
  declare function useColumnVisibilityState<Row>(gridRef: RefObject<DataGridApi<Row> | null>): ColumnVisibilityState;
492
503
 
504
+ /**
505
+ * Reactive column-pinning state read off a mounted `DataGrid`'s `ref` — the
506
+ * columns pinned or unpinned since it mounted, keyed by id. Read-only:
507
+ * change it through the ref's `pinColumn`/`setColumnPinning`. A column
508
+ * absent from it follows its definition's `pinned`.
509
+ *
510
+ * Before the grid mounts, reads as an empty object.
511
+ */
512
+ declare function useColumnPinningState<Row>(gridRef: RefObject<DataGridApi<Row> | null>): ColumnPinningState;
513
+
493
514
  interface FilterStateApi<Row> {
494
515
  filter: FilterState<Row>;
495
516
  setFilter: (filter: FilterState<Row>) => void;
@@ -505,4 +526,4 @@ interface FilterStateApi<Row> {
505
526
  */
506
527
  declare function useFilterState<Row>(gridRef: RefObject<DataGridApi<Row> | null>): FilterStateApi<Row>;
507
528
 
508
- export { type CellSelectEvent, type CellSelectionChangeEvent, type ColumnDefinition, type ColumnSelectEvent, type ColumnSelectionChangeEvent, type ColumnsSelectEvent, type DataColumn, DataGrid, type DataGridApi, type DataGridProps, type FilterStateApi, type GroupByStateApi, type InfiniteScrollConfig, type PagerConfig, type PagerTemplateContext, type PaginationStateApi, type ReactRenderSlots, type ResolvedColumn, type SelectedCell, type SelectedColumn, type SelectionStateApi, useAggregateState, useColumnOrderState, useColumnSizingState, useColumnSortState, useColumnVisibilityState, useFilterState, useGroupByState, usePaginationState, useSelectionState };
529
+ export { type CellSelectEvent, type CellSelectionChangeEvent, type ColumnDefinition, type ColumnSelectEvent, type ColumnSelectionChangeEvent, type ColumnsSelectEvent, type DataColumn, DataGrid, type DataGridApi, type DataGridProps, type FilterStateApi, type GroupByStateApi, type InfiniteScrollConfig, type PagerConfig, type PagerTemplateContext, type PaginationStateApi, type ReactRenderSlots, type ResolvedColumn, type SelectedCell, type SelectedColumn, type SelectionStateApi, useAggregateState, useColumnOrderState, useColumnPinningState, useColumnSizingState, useColumnSortState, useColumnVisibilityState, useFilterState, useGroupByState, usePaginationState, useSelectionState };
package/dist/index.js CHANGED
@@ -11,12 +11,16 @@ import {
11
11
  } from "react";
12
12
  import {
13
13
  headerFocus as headerFocus3,
14
- moveColumnBefore,
15
14
  resolveColumnHeaderText as resolveColumnHeaderText2,
15
+ resolveColumnPin as resolveColumnPin2,
16
16
  resolveMessages,
17
17
  resolveRows
18
18
  } from "@gridkitjs/core";
19
- import { totalColumnWidth } from "@gridkitjs/core/renderer";
19
+ import {
20
+ moveColumnInPinGroup,
21
+ pinnedWidths as pinnedWidths2,
22
+ totalColumnWidth
23
+ } from "@gridkitjs/core/renderer";
20
24
 
21
25
  // src/DataGrid/components/GridColgroup.tsx
22
26
  import { jsx } from "react/jsx-runtime";
@@ -111,6 +115,27 @@ function isOwnEvent(event) {
111
115
  return event.target instanceof Node && event.currentTarget.contains(event.target);
112
116
  }
113
117
 
118
+ // src/DataGrid/pinnedCell.ts
119
+ function pinnedCellClassNames({
120
+ pinned,
121
+ pinEdge
122
+ }) {
123
+ if (pinned === "none") return "";
124
+ return classNames(
125
+ pinned === "start" ? "is-pinned-start" : "is-pinned-end",
126
+ pinEdge && "is-pinned-edge"
127
+ );
128
+ }
129
+ function pinnedCellStyle({
130
+ pinned,
131
+ pinOffset
132
+ }) {
133
+ if (pinned === "none") return void 0;
134
+ return {
135
+ "--gridkit-pin-offset": `${String(pinOffset)}px`
136
+ };
137
+ }
138
+
114
139
  // src/DataGrid/useGridSelection.ts
115
140
  import { useMemo } from "react";
116
141
  function keyboardSelectIntent(event) {
@@ -182,8 +207,10 @@ function GridHeader({
182
207
  const { column } = entry;
183
208
  const resizing = resize.activeColumnId === entry.id;
184
209
  const dragging = drag.draggedColumnId === entry.id;
185
- const dropBefore = beforeId !== void 0 && beforeId === entry.id;
186
- const dropAfter = beforeId === null && index === columns.length - 1;
210
+ const dragBlocked = draggedEntry !== null && entry.pinned !== draggedEntry.pinned;
211
+ const next = columns[index + 1];
212
+ const dropBefore = beforeId === entry.id && !dragBlocked;
213
+ const dropAfter = !dragBlocked && (next === void 0 ? beforeId === null : beforeId === next.id && next.pinned !== entry.pinned);
187
214
  const selected = selection.selectedColumnIds.has(entry.id);
188
215
  const sortable = column.sortable ?? sortableColumns;
189
216
  const sortDirection = sortDirectionFor(columnSort, entry.id);
@@ -288,9 +315,12 @@ function GridHeader({
288
315
  dragging ? "is-dragging" : "",
289
316
  dropBefore ? "is-drop-before" : "",
290
317
  dropAfter ? "is-drop-after" : "",
318
+ dragBlocked ? "is-drag-blocked" : "",
291
319
  column.wrap?.header ? "is-wrapped" : "",
320
+ pinnedCellClassNames(entry),
292
321
  column.headerClassName ?? ""
293
322
  ),
323
+ style: pinnedCellStyle(entry),
294
324
  ...ariaAttr(shortcuts !== "", "aria-keyshortcuts", shortcuts),
295
325
  ...ariaAttr(
296
326
  filtered,
@@ -738,9 +768,13 @@ function GridGroupSummaryRowComponent({
738
768
  {
739
769
  role: "gridcell",
740
770
  "data-gridkit-column": entry.id,
741
- className: "gridkit-grid-group-summary-cell",
771
+ className: classNames(
772
+ "gridkit-grid-group-summary-cell",
773
+ pinnedCellClassNames(entry)
774
+ ),
742
775
  style: {
743
- textAlign: textAlignFor(specs[0]?.alignment ?? entry.alignment)
776
+ textAlign: textAlignFor(specs[0]?.alignment ?? entry.alignment),
777
+ ...pinnedCellStyle(entry)
744
778
  },
745
779
  children: [
746
780
  entry.id === columns[0]?.id && /* @__PURE__ */ jsx5(
@@ -827,7 +861,8 @@ function GridRowComponent({
827
861
  selected ? "is-selected" : "",
828
862
  rowClassName
829
863
  ),
830
- children: columns.map(({ id, column, alignment }, columnIndex) => {
864
+ children: columns.map((entry, columnIndex) => {
865
+ const { id, column, alignment } = entry;
831
866
  const value = accessDotted(row, column.field);
832
867
  const cellSelected = id === selectedColumnId;
833
868
  return /* @__PURE__ */ jsx6(
@@ -844,9 +879,13 @@ function GridRowComponent({
844
879
  id === activeColumnId ? "is-resizing" : "",
845
880
  cellSelected || selectedColumnIds.has(id) ? "is-selected" : "",
846
881
  column.wrap?.cells ? "is-wrapped" : "",
882
+ pinnedCellClassNames(entry),
847
883
  column.cellClassName ?? ""
848
884
  ),
849
- style: { textAlign: textAlignFor(alignment) },
885
+ style: {
886
+ textAlign: textAlignFor(alignment),
887
+ ...pinnedCellStyle(entry)
888
+ },
850
889
  children: column.cellTemplate ? column.cellTemplate({
851
890
  value,
852
891
  row,
@@ -1167,9 +1206,13 @@ function GridFooter({
1167
1206
  {
1168
1207
  role: "gridcell",
1169
1208
  "data-gridkit-column": entry.id,
1170
- className: "gridkit-grid-footer-cell",
1209
+ className: classNames(
1210
+ "gridkit-grid-footer-cell",
1211
+ pinnedCellClassNames(entry)
1212
+ ),
1171
1213
  style: {
1172
- textAlign: textAlignFor(specs[0]?.alignment ?? entry.alignment)
1214
+ textAlign: textAlignFor(specs[0]?.alignment ?? entry.alignment),
1215
+ ...pinnedCellStyle(entry)
1173
1216
  },
1174
1217
  children: specs.map(
1175
1218
  (spec) => renderAggregate(
@@ -1590,7 +1633,8 @@ function GroupByBar({
1590
1633
  // src/DataGrid/announcedCallbacks.ts
1591
1634
  import {
1592
1635
  isColumnVisible,
1593
- isGroupExpanded
1636
+ isGroupExpanded,
1637
+ resolveColumnPin
1594
1638
  } from "@gridkitjs/core";
1595
1639
  function announcedCallbacks({
1596
1640
  callbacks,
@@ -1644,6 +1688,26 @@ function announcedCallbacks({
1644
1688
  shown ? messages.columnShown(columnName(columnId)) : messages.columnHidden(columnName(columnId))
1645
1689
  );
1646
1690
  },
1691
+ /**
1692
+ * Naming the one column pinned or unpinned and the edge it went to. A
1693
+ * change touching several columns, as `setColumnPinning` or restoring a
1694
+ * layout can, may pin some and unpin others, and says nothing.
1695
+ */
1696
+ onColumnPinningChange: (event) => {
1697
+ callbacks.onColumnPinningChange?.(event);
1698
+ const [columnId, ...others] = event.columnIds;
1699
+ if (columnId === void 0 || others.length > 0) {
1700
+ return;
1701
+ }
1702
+ const column = columnOf(columnId);
1703
+ if (column === void 0) {
1704
+ return;
1705
+ }
1706
+ const pin = resolveColumnPin(column, event.pinning);
1707
+ announce(
1708
+ pin === "none" ? messages.columnUnpinned(columnName(columnId)) : messages.columnPinned(columnName(columnId), pin)
1709
+ );
1710
+ },
1647
1711
  /** A toggle, a stack, or a clear back to "none" each get their own. */
1648
1712
  onColumnSortChange: (event) => {
1649
1713
  callbacks.onColumnSortChange?.(event);
@@ -2360,7 +2424,7 @@ import {
2360
2424
  isSameCell,
2361
2425
  resolveMenu
2362
2426
  } from "@gridkitjs/core";
2363
- import { hasContextMenu } from "@gridkitjs/core/renderer";
2427
+ import { hasContextMenu, pinnedWidths } from "@gridkitjs/core/renderer";
2364
2428
  import {
2365
2429
  attachContextMenuTrigger
2366
2430
  } from "@gridkitjs/dom";
@@ -2385,12 +2449,16 @@ function bodyCell(parts, rowIndex, columnIndex) {
2385
2449
  const element = findBodyRow2(parts.bodyTable, rowIndex)?.cells[columnIndex];
2386
2450
  return element === void 0 ? null : { element, focus: bodyFocus2(rowIndex, columnIndex) };
2387
2451
  }
2452
+ function underPinnedColumns(element, parts) {
2453
+ return parts.pinnedWidths.start + parts.pinnedWidths.end > 0 && element instanceof HTMLTableCellElement && !element.matches(".is-pinned-start, .is-pinned-end");
2454
+ }
2388
2455
  function viewOf(element, parts) {
2389
- const view = parts.scroller?.getBoundingClientRect();
2390
- if (view === void 0) {
2456
+ const { scroller } = parts;
2457
+ if (scroller === null) {
2391
2458
  return null;
2392
2459
  }
2393
- let { top, bottom } = view;
2460
+ const view = scroller.getBoundingClientRect();
2461
+ let { top, bottom, left, right } = view;
2394
2462
  if (parts.body?.contains(element) === true) {
2395
2463
  top = Math.max(
2396
2464
  top,
@@ -2401,7 +2469,19 @@ function viewOf(element, parts) {
2401
2469
  parts.footerTable?.getBoundingClientRect().top ?? bottom
2402
2470
  );
2403
2471
  }
2404
- return new DOMRect(view.left, top, view.width, Math.max(0, bottom - top));
2472
+ if (underPinnedColumns(element, parts)) {
2473
+ const { start, end } = parts.pinnedWidths;
2474
+ const rtl = writingDirection5(element) === "rtl";
2475
+ const portLeft = view.left + scroller.clientLeft;
2476
+ left = portLeft + (rtl ? end : start);
2477
+ right = portLeft + scroller.clientWidth - (rtl ? start : end);
2478
+ }
2479
+ return new DOMRect(
2480
+ left,
2481
+ top,
2482
+ Math.max(0, right - left),
2483
+ Math.max(0, bottom - top)
2484
+ );
2405
2485
  }
2406
2486
  function clamp(value, min, max) {
2407
2487
  return Math.min(Math.max(value, min), max);
@@ -2540,6 +2620,7 @@ function useContextMenu({
2540
2620
  body: bodyRef.current,
2541
2621
  footerTable: footerTableRef.current,
2542
2622
  columns,
2623
+ pinnedWidths: pinnedWidths(columns),
2543
2624
  pageRows
2544
2625
  };
2545
2626
  }
@@ -4332,13 +4413,15 @@ function useColumnDrag({
4332
4413
  order,
4333
4414
  groupBy,
4334
4415
  groupByDraggableIds,
4416
+ pinOf,
4335
4417
  onDrop
4336
4418
  }) {
4337
4419
  const drag = useDragReorder({
4338
4420
  resolveTarget: (clientX, clientY, movedId) => resolveColumnDropTarget(clientX, clientY, movedId, {
4339
4421
  order,
4340
4422
  groupBy,
4341
- groupByDraggableIds
4423
+ groupByDraggableIds,
4424
+ pinOf
4342
4425
  }),
4343
4426
  onDrop
4344
4427
  });
@@ -4677,6 +4760,19 @@ function selectedRowsReader(controller) {
4677
4760
  return last.selected;
4678
4761
  };
4679
4762
  }
4763
+ function tablesStyle(height, headerHeight, footerHeight, pinned) {
4764
+ const heights = height === void 0 ? {} : {
4765
+ "--gridkit-body-height": typeof height === "number" ? `${String(height)}px` : height,
4766
+ ...headerHeight === null ? {} : { "--gridkit-header-height": `${String(headerHeight)}px` },
4767
+ ...footerHeight === null ? {} : { "--gridkit-footer-height": `${String(footerHeight)}px` }
4768
+ };
4769
+ const widths = pinned.start === 0 && pinned.end === 0 ? {} : {
4770
+ "--gridkit-pinned-start-width": `${String(pinned.start)}px`,
4771
+ "--gridkit-pinned-end-width": `${String(pinned.end)}px`
4772
+ };
4773
+ const style = { ...heights, ...widths };
4774
+ return Object.keys(style).length === 0 ? void 0 : style;
4775
+ }
4680
4776
  function DataGrid(props) {
4681
4777
  const {
4682
4778
  borders,
@@ -4842,20 +4938,36 @@ function DataGrid(props) {
4842
4938
  ),
4843
4939
  [view.columns]
4844
4940
  );
4941
+ function pinOf(columnId) {
4942
+ const column = definitions.get(columnId);
4943
+ return column === void 0 ? "none" : resolveColumnPin2(column, state.columnPinning);
4944
+ }
4845
4945
  function handleDrop(target, movedId) {
4846
4946
  if (target.kind === "group-by") {
4847
4947
  controller.moveGroupBy(movedId, target.beforeColumnId);
4848
4948
  return;
4849
4949
  }
4850
- const next = moveColumnBefore(orderedIds, movedId, target.beforeId);
4950
+ const next = moveColumnInPinGroup(
4951
+ orderedIds,
4952
+ pinOf,
4953
+ movedId,
4954
+ target.beforeId
4955
+ );
4851
4956
  if (next === orderedIds) {
4852
4957
  return;
4853
4958
  }
4854
4959
  controller.moveColumn(movedId, target.beforeId);
4855
- const shown = next.filter((id) => displayedIds.includes(id));
4856
- const position = shown.indexOf(movedId);
4960
+ const pin = pinOf(movedId);
4961
+ const group = next.filter(
4962
+ (id) => pinOf(id) === pin && displayedIds.includes(id)
4963
+ );
4964
+ const position = displayedIds.findIndex((id) => pinOf(id) === pin) + group.indexOf(movedId);
4857
4965
  announce(
4858
- messages.columnMoved(columnName(movedId), position + 1, shown.length)
4966
+ messages.columnMoved(
4967
+ columnName(movedId),
4968
+ position + 1,
4969
+ displayedIds.length
4970
+ )
4859
4971
  );
4860
4972
  nav.focusCell(headerFocus3(position));
4861
4973
  }
@@ -4863,6 +4975,7 @@ function DataGrid(props) {
4863
4975
  order: displayedIds,
4864
4976
  groupBy: state.groupBy,
4865
4977
  groupByDraggableIds,
4978
+ pinOf,
4866
4979
  onDrop: handleDrop
4867
4980
  });
4868
4981
  const draggedColumnAlreadyGrouped = drag.draggedColumnId !== null && state.groupBy.some((entry) => entry.columnId === drag.draggedColumnId);
@@ -4920,6 +5033,7 @@ function DataGrid(props) {
4920
5033
  getColumnSizing: () => controller.getState().columnSizing,
4921
5034
  getColumnOrder: () => controller.getState().columnOrder,
4922
5035
  getColumnVisibility: () => controller.getState().columnVisibility,
5036
+ getColumnPinning: () => controller.getState().columnPinning,
4923
5037
  getColumnSort: () => controller.getState().columnSort,
4924
5038
  getFilter: () => controller.getState().filter,
4925
5039
  getGroupBy: () => controller.getState().groupBy,
@@ -4946,6 +5060,7 @@ function DataGrid(props) {
4946
5060
  setPageSize: controller.setPageSize,
4947
5061
  showColumns: controller.showColumns,
4948
5062
  hideColumns: controller.hideColumns,
5063
+ pinColumn: controller.pinColumn,
4949
5064
  setFilter: controller.setFilter,
4950
5065
  setColumnSort: controller.setColumnSort,
4951
5066
  setGroupBy: controller.setGroupBy,
@@ -4954,6 +5069,7 @@ function DataGrid(props) {
4954
5069
  setColumnSizing: controller.setColumnSizing,
4955
5070
  setColumnOrder: controller.setColumnOrder,
4956
5071
  setColumnVisibility: controller.setColumnVisibility,
5072
+ setColumnPinning: controller.setColumnPinning,
4957
5073
  setRowSelection: controller.setRowSelection,
4958
5074
  setColumnSelection: controller.setColumnSelection,
4959
5075
  setCellSelection: controller.setCellSelection,
@@ -5060,11 +5176,12 @@ function DataGrid(props) {
5060
5176
  "aria-rowcount": view.displayRows.length + (hasFooter ? 2 : 1),
5061
5177
  "aria-colcount": view.columns.length,
5062
5178
  tabIndex: -1,
5063
- style: height === void 0 ? void 0 : {
5064
- "--gridkit-body-height": typeof height === "number" ? `${String(height)}px` : height,
5065
- ...headerHeight === null ? {} : { "--gridkit-header-height": `${String(headerHeight)}px` },
5066
- ...footerHeight === null ? {} : { "--gridkit-footer-height": `${String(footerHeight)}px` }
5067
- },
5179
+ style: tablesStyle(
5180
+ height,
5181
+ headerHeight,
5182
+ footerHeight,
5183
+ pinnedWidths2(view.columns)
5184
+ ),
5068
5185
  ...ariaAttr(multiselectable, "aria-multiselectable", true),
5069
5186
  ...ariaAttr(labelledBy !== void 0, "aria-labelledby", labelledBy),
5070
5187
  ...ariaAttr(
@@ -5419,13 +5536,24 @@ function useColumnVisibilityState(gridRef) {
5419
5536
  );
5420
5537
  }
5421
5538
 
5539
+ // src/DataGrid/hooks/useColumnPinningState.ts
5540
+ import { useCallback as useCallback13 } from "react";
5541
+ var FALLBACK_PINNING = {};
5542
+ function useColumnPinningState(gridRef) {
5543
+ return useGridSnapshot(
5544
+ gridRef,
5545
+ useCallback13((api) => api.getColumnPinning(), []),
5546
+ FALLBACK_PINNING
5547
+ );
5548
+ }
5549
+
5422
5550
  // src/DataGrid/hooks/useFilterState.ts
5423
- import { useCallback as useCallback13, useState as useState20 } from "react";
5551
+ import { useCallback as useCallback14, useState as useState20 } from "react";
5424
5552
  function useFilterState(gridRef) {
5425
5553
  const [fallback] = useState20(() => []);
5426
5554
  const filter = useGridSnapshot(
5427
5555
  gridRef,
5428
- useCallback13((api) => api.getFilter(), []),
5556
+ useCallback14((api) => api.getFilter(), []),
5429
5557
  fallback
5430
5558
  );
5431
5559
  return {
@@ -5444,6 +5572,7 @@ export {
5444
5572
  serializeGridState,
5445
5573
  useAggregateState,
5446
5574
  useColumnOrderState,
5575
+ useColumnPinningState,
5447
5576
  useColumnSizingState,
5448
5577
  useColumnSortState,
5449
5578
  useColumnVisibilityState,