react-glide-table 2.0.1 → 2.1.0

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.
@@ -1,4 +1,4 @@
1
- import { Row, ColumnDef, RowSelectionState, Updater, ColumnSizingState, OnChangeFn, ColumnResizeMode } from '@tanstack/react-table';
1
+ import { Row, ColumnDef, RowSelectionState, Updater, ColumnSizingState, OnChangeFn, ColumnResizeMode, ColumnOrderState } from '@tanstack/react-table';
2
2
  import { ReactNode, CSSProperties, InputHTMLAttributes, ComponentType, Ref } from 'react';
3
3
 
4
4
  /**
@@ -161,6 +161,8 @@ type DataTableLabels = {
161
161
  collapseRow: string;
162
162
  /** Accessible label for the column resize handle */
163
163
  resizeColumn: string;
164
+ /** Accessible label for a draggable column header */
165
+ reorderColumn: string;
164
166
  /** Built-in find-in-page search overlay */
165
167
  searchPlaceholder: string;
166
168
  searchResultHint: string;
@@ -206,6 +208,20 @@ declare module "@tanstack/react-table" {
206
208
  * Middle columns are allowed; multiple frozen columns stack via cumulative offsets.
207
209
  */
208
210
  frozen?: ColumnFreezeMeta;
211
+ /**
212
+ * When false, this column cannot be dragged even if `enableColumnReorder` is on.
213
+ * Defaults to true.
214
+ */
215
+ reorderable?: boolean;
216
+ }
217
+ interface CellContext<TData, TValue> {
218
+ /**
219
+ * Commit a cell value through `onCellChange` / `onDataChange`.
220
+ * Present at runtime only when the context was wrapped by `DataTable`,
221
+ * `withCellUpdate`, or `useGlideTable().getCellContext` — not on bare
222
+ * `cell.getContext()`. Prefer those helpers for a guaranteed `update`.
223
+ */
224
+ update?: (next: TValue) => void;
209
225
  }
210
226
  interface Row<TData> {
211
227
  /**
@@ -374,6 +390,15 @@ type DataTableProps<T extends Record<string, unknown>> = {
374
390
  * Use `"onEnd"` to update only after the pointer is released.
375
391
  */
376
392
  columnResizeMode?: ColumnResizeMode;
393
+ /**
394
+ * Enable drag-to-reorder on column headers. Defaults to false.
395
+ * Opt out per column with `Column.reorderable={false}` / `meta.reorderable: false`.
396
+ * Leaf columns can move across groups; consecutive same-group leaves stay wrapped.
397
+ */
398
+ enableColumnReorder?: boolean;
399
+ /** Controlled leaf column id order */
400
+ columnOrder?: ColumnOrderState;
401
+ onColumnOrderChange?: OnChangeFn<ColumnOrderState>;
377
402
  /**
378
403
  * Enable sticky freeze columns. Defaults to false.
379
404
  * Mark columns with `Column.frozen` / `meta.frozen` (`true` | `"left"` | `"right"`).
@@ -426,6 +451,8 @@ type DataTableClassNames = {
426
451
  headCell?: string;
427
452
  /** Column resize drag handle inside a header cell */
428
453
  resizeHandle?: string;
454
+ /** Drop-edge indicator while reordering columns */
455
+ dropEdge?: string;
429
456
  body?: string;
430
457
  emptyCell?: string;
431
458
  virtualSpacer?: string;
@@ -520,6 +547,11 @@ type TableColumnProps<T extends Record<string, unknown>, K extends string = keyo
520
547
  * Defaults to true.
521
548
  */
522
549
  resizable?: boolean;
550
+ /**
551
+ * When false, this column cannot be dragged even if `enableColumnReorder` is on.
552
+ * Defaults to true. Still accepts drops next to it.
553
+ */
554
+ reorderable?: boolean;
523
555
  /**
524
556
  * Freeze (sticky) without changing column order.
525
557
  * `true` / `"left"` → left edge; `"right"` → right edge.
@@ -1,4 +1,4 @@
1
- import { Row, ColumnDef, RowSelectionState, Updater, ColumnSizingState, OnChangeFn, ColumnResizeMode } from '@tanstack/react-table';
1
+ import { Row, ColumnDef, RowSelectionState, Updater, ColumnSizingState, OnChangeFn, ColumnResizeMode, ColumnOrderState } from '@tanstack/react-table';
2
2
  import { ReactNode, CSSProperties, InputHTMLAttributes, ComponentType, Ref } from 'react';
3
3
 
4
4
  /**
@@ -161,6 +161,8 @@ type DataTableLabels = {
161
161
  collapseRow: string;
162
162
  /** Accessible label for the column resize handle */
163
163
  resizeColumn: string;
164
+ /** Accessible label for a draggable column header */
165
+ reorderColumn: string;
164
166
  /** Built-in find-in-page search overlay */
165
167
  searchPlaceholder: string;
166
168
  searchResultHint: string;
@@ -206,6 +208,20 @@ declare module "@tanstack/react-table" {
206
208
  * Middle columns are allowed; multiple frozen columns stack via cumulative offsets.
207
209
  */
208
210
  frozen?: ColumnFreezeMeta;
211
+ /**
212
+ * When false, this column cannot be dragged even if `enableColumnReorder` is on.
213
+ * Defaults to true.
214
+ */
215
+ reorderable?: boolean;
216
+ }
217
+ interface CellContext<TData, TValue> {
218
+ /**
219
+ * Commit a cell value through `onCellChange` / `onDataChange`.
220
+ * Present at runtime only when the context was wrapped by `DataTable`,
221
+ * `withCellUpdate`, or `useGlideTable().getCellContext` — not on bare
222
+ * `cell.getContext()`. Prefer those helpers for a guaranteed `update`.
223
+ */
224
+ update?: (next: TValue) => void;
209
225
  }
210
226
  interface Row<TData> {
211
227
  /**
@@ -374,6 +390,15 @@ type DataTableProps<T extends Record<string, unknown>> = {
374
390
  * Use `"onEnd"` to update only after the pointer is released.
375
391
  */
376
392
  columnResizeMode?: ColumnResizeMode;
393
+ /**
394
+ * Enable drag-to-reorder on column headers. Defaults to false.
395
+ * Opt out per column with `Column.reorderable={false}` / `meta.reorderable: false`.
396
+ * Leaf columns can move across groups; consecutive same-group leaves stay wrapped.
397
+ */
398
+ enableColumnReorder?: boolean;
399
+ /** Controlled leaf column id order */
400
+ columnOrder?: ColumnOrderState;
401
+ onColumnOrderChange?: OnChangeFn<ColumnOrderState>;
377
402
  /**
378
403
  * Enable sticky freeze columns. Defaults to false.
379
404
  * Mark columns with `Column.frozen` / `meta.frozen` (`true` | `"left"` | `"right"`).
@@ -426,6 +451,8 @@ type DataTableClassNames = {
426
451
  headCell?: string;
427
452
  /** Column resize drag handle inside a header cell */
428
453
  resizeHandle?: string;
454
+ /** Drop-edge indicator while reordering columns */
455
+ dropEdge?: string;
429
456
  body?: string;
430
457
  emptyCell?: string;
431
458
  virtualSpacer?: string;
@@ -520,6 +547,11 @@ type TableColumnProps<T extends Record<string, unknown>, K extends string = keyo
520
547
  * Defaults to true.
521
548
  */
522
549
  resizable?: boolean;
550
+ /**
551
+ * When false, this column cannot be dragged even if `enableColumnReorder` is on.
552
+ * Defaults to true. Still accepts drops next to it.
553
+ */
554
+ reorderable?: boolean;
523
555
  /**
524
556
  * Freeze (sticky) without changing column order.
525
557
  * `true` / `"left"` → left edge; `"right"` → right edge.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-glide-table",
3
- "version": "2.0.1",
3
+ "version": "2.1.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/zpxlffjrm/react-glide-table.git"