react-glide-table 1.1.8 → 1.2.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,5 +1,42 @@
1
- import { ColumnDef, RowSelectionState, Updater, Row } from '@tanstack/react-table';
2
- import { ReactNode, InputHTMLAttributes, ComponentType } from 'react';
1
+ import { ColumnDef, RowSelectionState, Updater, ColumnSizingState, OnChangeFn, ColumnResizeMode, Row } from '@tanstack/react-table';
2
+ import { CSSProperties, ReactNode, InputHTMLAttributes, ComponentType } from 'react';
3
+
4
+ /** Sticky edge for a frozen column. Does not reorder columns. */
5
+ type ColumnFreezeSide = "left" | "right";
6
+ /**
7
+ * Per-column freeze flag.
8
+ * `true` is sugar for `"left"`.
9
+ */
10
+ type ColumnFreezeMeta = boolean | ColumnFreezeSide;
11
+ type ColumnFreezeColumnInput = {
12
+ id: string;
13
+ size: number;
14
+ side?: ColumnFreezeSide;
15
+ };
16
+ type ColumnFreezeOffset = {
17
+ side: ColumnFreezeSide;
18
+ /** Cumulative sticky inset (`left` or `right` in px). */
19
+ offset: number;
20
+ /** Inner edge of the sticky group (shadow / divider). */
21
+ isEdge: boolean;
22
+ /** Relative stack order within the freeze side (higher = closer to the viewport edge). */
23
+ stack: number;
24
+ };
25
+ /** Normalize column `frozen` meta into a sticky side. */
26
+ declare function resolveColumnFreezeSide(frozen?: ColumnFreezeMeta): ColumnFreezeSide | undefined;
27
+ /**
28
+ * Build sticky insets for frozen columns without changing DOM/column order.
29
+ *
30
+ * - `left`: `left = Σ(widths of left-frozen columns before this one)`
31
+ * - `right`: `right = Σ(widths of right-frozen columns after this one)`
32
+ *
33
+ * Middle columns may be frozen; non-frozen neighbors scroll underneath.
34
+ */
35
+ declare function buildColumnFreezeOffsets(columns: ColumnFreezeColumnInput[]): Map<string, ColumnFreezeOffset>;
36
+ /** Sticky position styles for a frozen header or body cell. */
37
+ declare function getColumnFreezeStyle(offset: ColumnFreezeOffset | undefined, options?: {
38
+ isHeader?: boolean;
39
+ }): CSSProperties | undefined;
3
40
 
4
41
  type DataTableLabels = {
5
42
  empty: string;
@@ -7,6 +44,8 @@ type DataTableLabels = {
7
44
  selection: (selectedCount: number) => ReactNode;
8
45
  expandRow: string;
9
46
  collapseRow: string;
47
+ /** Accessible label for the column resize handle */
48
+ resizeColumn: string;
10
49
  };
11
50
  /** Default copy. Override via the `labels` option. */
12
51
  declare const DEFAULT_DATA_TABLE_LABELS: DataTableLabels;
@@ -31,6 +70,21 @@ declare module "@tanstack/react-table" {
31
70
  editType?: CellEditType;
32
71
  /** Inline editor input attribute overrides */
33
72
  editInputProps?: DataTableEditInputProps;
73
+ /**
74
+ * Freeze (sticky) this column without reordering.
75
+ * `true` / `"left"` stick to the scrollport left; `"right"` to the right.
76
+ * Middle columns are allowed; multiple frozen columns stack via cumulative offsets.
77
+ */
78
+ frozen?: ColumnFreezeMeta;
79
+ }
80
+ interface Row<TData> {
81
+ /**
82
+ * Returns whether this row's cell is inside the active drag selection.
83
+ * Attached at render time by DataTableRow (optional outside that renderer).
84
+ * - `columnId` omitted: true when any visible cell in the row is selected.
85
+ * - `columnId` provided: checks only that column (row-span aware via merge origin).
86
+ */
87
+ getIsCellDragSelected?: (columnId?: string) => boolean;
34
88
  }
35
89
  }
36
90
  type DataTableCopyActions = {
@@ -171,6 +225,25 @@ type DataTableProps<T extends Record<string, unknown>> = {
171
225
  estimateRowHeight?: number;
172
226
  /** Virtualization overscan row count. Default 8 */
173
227
  virtualOverscan?: number;
228
+ /**
229
+ * Enable drag-to-resize on column headers. Defaults to false.
230
+ * Opt out per column with `Column.resizable={false}` / `enableResizing: false`.
231
+ */
232
+ enableColumnResize?: boolean;
233
+ /** Controlled column sizing map (`{ [columnId]: widthPx }`) */
234
+ columnSizing?: ColumnSizingState;
235
+ onColumnSizingChange?: OnChangeFn<ColumnSizingState>;
236
+ /**
237
+ * When to commit resize updates. Defaults to `"onChange"` (live while dragging).
238
+ * Use `"onEnd"` to update only after the pointer is released.
239
+ */
240
+ columnResizeMode?: ColumnResizeMode;
241
+ /**
242
+ * Enable sticky freeze columns. Defaults to false.
243
+ * Mark columns with `Column.frozen` / `meta.frozen` (`true` | `"left"` | `"right"`).
244
+ * Does not reorder columns; offsets stack so frozen cells do not overlap.
245
+ */
246
+ enableColumnFreeze?: boolean;
174
247
  /**
175
248
  * Optional UI part replacements for the unstyled DataTable renderer.
176
249
  * Use with `createTable` / `Table.Column`, or pass columns directly to `DataTable`.
@@ -196,6 +269,8 @@ type DataTableClassNames = {
196
269
  head?: string;
197
270
  headRow?: string;
198
271
  headCell?: string;
272
+ /** Column resize drag handle inside a header cell */
273
+ resizeHandle?: string;
199
274
  body?: string;
200
275
  emptyCell?: string;
201
276
  virtualSpacer?: string;
@@ -257,7 +332,23 @@ type TableColumnProps<T extends Record<string, unknown>, K extends string = keyo
257
332
  virtual?: boolean;
258
333
  children?: ReactNode;
259
334
  sortable?: boolean;
335
+ /** Initial / default column width in px (TanStack `size`) */
260
336
  width?: number;
337
+ /** Minimum resize width in px. Defaults to the table min when omitted */
338
+ minWidth?: number;
339
+ /** Maximum resize width in px. Defaults to the table max when omitted */
340
+ maxWidth?: number;
341
+ /**
342
+ * When false, this column cannot be resized even if `enableColumnResize` is on.
343
+ * Defaults to true.
344
+ */
345
+ resizable?: boolean;
346
+ /**
347
+ * Freeze (sticky) without changing column order.
348
+ * `true` / `"left"` → left edge; `"right"` → right edge.
349
+ * Requires `enableColumnFreeze`. Middle columns are allowed.
350
+ */
351
+ frozen?: ColumnFreezeMeta;
261
352
  align?: "left" | "center" | "right";
262
353
  rowSpan?: boolean;
263
354
  rowSpanKey?: string;
@@ -273,4 +364,4 @@ type TableProps<T extends Record<string, unknown>> = Omit<DataTableProps<T>, "co
273
364
  children: ReactNode;
274
365
  };
275
366
 
276
- export { type CellEditType as C, DEFAULT_DATA_TABLE_LABELS as D, type PasteMode as P, type RowSelectionMode as R, type TableColumnProps as T, type DataTableClassNames as a, type DataTableCopyActions as b, type DataTableLabels as c, type DataTableProps as d, type DataTableSlots as e, type RowsPastePayload as f, type TableProps as g, resolveDataTableLabels as r };
367
+ export { type ColumnFreezeColumnInput as C, DEFAULT_DATA_TABLE_LABELS as D, type PasteMode as P, type RowSelectionMode as R, type TableColumnProps as T, type ColumnFreezeMeta as a, type ColumnFreezeOffset as b, type ColumnFreezeSide as c, type DataTableClassNames as d, type DataTableCopyActions as e, type DataTableLabels as f, type DataTableProps as g, type DataTableSlots as h, type RowsPastePayload as i, type TableProps as j, buildColumnFreezeOffsets as k, getColumnFreezeStyle as l, resolveDataTableLabels as m, type CellEditType as n, resolveColumnFreezeSide as r };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-glide-table",
3
- "version": "1.1.8",
3
+ "version": "1.2.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/zpxlffjrm/react-glide-table.git"
@@ -11,6 +11,28 @@
11
11
  "homepage": "https://github.com/zpxlffjrm/react-glide-table#readme",
12
12
  "type": "module",
13
13
  "license": "MIT",
14
+ "keywords": [
15
+ "react",
16
+ "table",
17
+ "datagrid",
18
+ "data-grid",
19
+ "headless",
20
+ "unstyled",
21
+ "tanstack",
22
+ "tanstack-table",
23
+ "virtualization",
24
+ "virtualized",
25
+ "typescript",
26
+ "compound-components",
27
+ "column-resize",
28
+ "column-freeze",
29
+ "sticky-columns",
30
+ "row-span",
31
+ "cell-selection",
32
+ "editable",
33
+ "tree-table",
34
+ "clipboard"
35
+ ],
14
36
  "sideEffects": false,
15
37
  "engines": {
16
38
  "node": "^20.19.0 || >=22.12.0"