react-glide-table 1.6.0 → 2.0.1

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,32 @@
1
- import { ColumnDef, RowSelectionState, Updater, ColumnSizingState, OnChangeFn, ColumnResizeMode, Row } from '@tanstack/react-table';
2
- import { CSSProperties, ReactNode, InputHTMLAttributes, ComponentType, Ref } from 'react';
1
+ import { Row, ColumnDef, RowSelectionState, Updater, ColumnSizingState, OnChangeFn, ColumnResizeMode } from '@tanstack/react-table';
2
+ import { ReactNode, CSSProperties, InputHTMLAttributes, ComponentType, Ref } from 'react';
3
+
4
+ /**
5
+ * Built-in cell kinds inspired by Glide Data Grid All Cell Kinds.
6
+ * Custom kinds are plain strings registered via `cellRenderers`.
7
+ */
8
+ type BuiltinCellKind = "text" | "number" | "boolean" | "uri" | "image" | "bubble" | "markdown" | "drilldown" | "loading" | "protected" | "row-id";
9
+ type CellKind = BuiltinCellKind | (string & {});
10
+ type CellRenderContext<T extends Record<string, unknown> = Record<string, unknown>, V = unknown> = {
11
+ value: V;
12
+ row: Row<T>;
13
+ index: number;
14
+ columnId: string;
15
+ /** Kind-specific props from `Column.cellProps` / `meta.cellProps` */
16
+ cellProps?: Record<string, unknown>;
17
+ /**
18
+ * Commit a cell value through the table's `onCellChange` / `onDataChange` pipeline.
19
+ * Prefer this over calling `setData` directly from custom renders.
20
+ */
21
+ update: (next: V) => void;
22
+ };
23
+ type CellRenderer<T extends Record<string, unknown> = Record<string, unknown>, V = unknown> = {
24
+ kind: CellKind;
25
+ render: (ctx: CellRenderContext<T, V>) => ReactNode;
26
+ /** Optional extra match when resolving custom renderers */
27
+ isMatch?: (ctx: CellRenderContext<T, V>) => boolean;
28
+ };
29
+ type CellRenderFn<T extends Record<string, unknown> = Record<string, unknown>, V = unknown> = (ctx: CellRenderContext<T, V>) => ReactNode;
3
30
 
4
31
  /** Sticky edge for a frozen column. Does not reorder columns. */
5
32
  type ColumnFreezeSide = "left" | "right";
@@ -46,7 +73,24 @@ declare function buildColumnFreezeOffsets(columns: ColumnFreezeColumnInput[]): M
46
73
  /** Sticky position styles for a frozen header or body cell. */
47
74
  declare function getColumnFreezeStyle(offset: ColumnFreezeOffset | undefined, options?: {
48
75
  isHeader?: boolean;
76
+ /**
77
+ * @deprecated Unused. Vertical sticky belongs on `thead` (`classNames.head`),
78
+ * not on frozen header cells — dual `top` sticky detaches freeze bands.
79
+ */
80
+ headerTop?: number;
49
81
  }): CSSProperties | undefined;
82
+ type HeaderFreezeColumnLike = {
83
+ id: string;
84
+ columns?: HeaderFreezeColumnLike[];
85
+ getLeafColumns?: () => HeaderFreezeColumnLike[];
86
+ };
87
+ /**
88
+ * Resolve freeze offset for a header cell.
89
+ * Leaf columns use the leaf map directly. Group headers inherit sticky
90
+ * positioning only when every leaf is frozen on the same side — otherwise a
91
+ * scrolled-away group label leaves frozen leaves looking like a detached band.
92
+ */
93
+ declare function resolveHeaderFreezeOffset(column: HeaderFreezeColumnLike, freezeOffsets: Map<string, ColumnFreezeOffset>): ColumnFreezeOffset | undefined;
50
94
 
51
95
  /** Cell match as `[colIndex, rowIndex]` — same order as Glide Data Grid `Item`.
52
96
  * For tree tables, `rowIndex` is the search-corpus index (includes collapsed rows).
@@ -147,6 +191,15 @@ declare module "@tanstack/react-table" {
147
191
  editType?: CellEditType;
148
192
  /** Inline editor input attribute overrides */
149
193
  editInputProps?: DataTableEditInputProps;
194
+ /**
195
+ * Built-in or custom cell kind. Resolved via table `cellRenderers` registry.
196
+ * Column `render` takes precedence over `kind`.
197
+ */
198
+ kind?: CellKind;
199
+ /** Extra props forwarded to the kind / custom renderer as `ctx.cellProps` */
200
+ cellProps?: Record<string, unknown>;
201
+ /** Compound `Column.render` stored for `ResolvedTableCell` */
202
+ cellRender?: CellRenderFn<Record<string, unknown>>;
150
203
  /**
151
204
  * Freeze (sticky) this column without reordering.
152
205
  * `true` / `"left"` stick to the scrollport left; `"right"` to the right.
@@ -251,6 +304,12 @@ type DataTableProps<T extends Record<string, unknown>> = {
251
304
  columnId: string;
252
305
  value: unknown;
253
306
  }>) => void;
307
+ /**
308
+ * Extra / overriding cell kind renderers (same `kind` replaces builtins).
309
+ * Built-ins: text, number, boolean, uri, image, bubble, markdown, drilldown,
310
+ * loading, protected, row-id.
311
+ */
312
+ cellRenderers?: readonly CellRenderer[];
254
313
  /**
255
314
  * Root className hook (combined with `DataTableJSX`).
256
315
  * The package ships no CSS — style these hooks yourself or leave unstyled.
@@ -474,12 +533,33 @@ type TableColumnProps<T extends Record<string, unknown>, K extends string = keyo
474
533
  editType?: CellEditType;
475
534
  /** Inline editor input attribute overrides */
476
535
  editInputProps?: DataTableEditInputProps;
536
+ /**
537
+ * Cell kind for the built-in / custom renderer registry.
538
+ * Ignored when `render` is set (render wins).
539
+ */
540
+ kind?: CellKind;
541
+ /** Extra props for the kind renderer (`ctx.cellProps`) */
542
+ cellProps?: Record<string, unknown>;
477
543
  className?: string;
478
544
  headerClassName?: string;
479
- render?: (value: K extends keyof T ? T[K] : unknown, row: Row<T>, index: number) => ReactNode;
545
+ /**
546
+ * Custom cell content. Receives a single context object — destructure what you need.
547
+ * Use `update` to commit via `onCellChange` / `onDataChange`.
548
+ */
549
+ render?: CellRenderFn<T, K extends keyof T ? T[K] : unknown>;
550
+ };
551
+ /** Declares a multi-row header group wrapping leaf `Table.Column`s. */
552
+ type TableColumnGroupProps = {
553
+ /** Group header label shown in the top header row */
554
+ header: ReactNode;
555
+ children: ReactNode;
556
+ /** Stable group id. Auto-generated when omitted */
557
+ id?: string;
558
+ align?: "left" | "center" | "right";
559
+ headerClassName?: string;
480
560
  };
481
561
  type TableProps<T extends Record<string, unknown>> = Omit<DataTableProps<T>, "columns"> & {
482
562
  children: ReactNode;
483
563
  };
484
564
 
485
- export { getColumnFreezeStyle as A, mapSearchResultToVisibleItem as B, type ColumnFreezeColumnInput as C, DEFAULT_DATA_TABLE_LABELS as D, mapSearchResultsToVisibleKeys as E, nextSearchIndex as F, nextSearchStride as G, previousSearchIndex as H, INLINE_SEARCH_MAX_RESULTS as I, resolveColumnFreezeSide as J, resolveDataTableLabels as K, type CellEditType as L, type PasteMode as P, type RowSelectionMode as R, type SearchCorpusRow as S, type TableColumnProps as T, type ColumnFreezeEdgeSide as a, type ColumnFreezeMeta as b, type ColumnFreezeOffset as c, type ColumnFreezeSide as d, type DataTableClassNames as e, type DataTableCopyActions as f, type DataTableLabels as g, type DataTableProps as h, type DataTableScrollSlotProps as i, type DataTableSlots as j, type RowsPastePayload as k, type SearchResultItem as l, type SearchStatus as m, type TableProps as n, buildColumnFreezeOffsets as o, buildFlatSearchCorpus as p, buildSearchMatchKey as q, buildSearchMatchKeys as r, buildTreeSearchCorpus as s, cellValueToSearchText as t, collectAncestorKeysToExpand as u, collectSearchMatchesInRange as v, createSearchRegex as w, escapeSearchRegex as x, formatSearchResultLabel as y, getColumnFreezeEdgeAttr as z };
565
+ export { collectSearchMatchesInRange as A, type BuiltinCellKind as B, type CellKind as C, DEFAULT_DATA_TABLE_LABELS as D, createSearchRegex as E, escapeSearchRegex as F, formatSearchResultLabel as G, getColumnFreezeEdgeAttr as H, INLINE_SEARCH_MAX_RESULTS as I, getColumnFreezeStyle as J, mapSearchResultToVisibleItem as K, mapSearchResultsToVisibleKeys as L, nextSearchIndex as M, nextSearchStride as N, previousSearchIndex as O, type PasteMode as P, resolveColumnFreezeSide as Q, type RowSelectionMode as R, type SearchCorpusRow as S, type TableColumnGroupProps as T, resolveDataTableLabels as U, resolveHeaderFreezeOffset as V, type CellEditType as W, type CellRenderContext as a, type CellRenderFn as b, type CellRenderer as c, type ColumnFreezeColumnInput as d, type ColumnFreezeEdgeSide as e, type ColumnFreezeMeta as f, type ColumnFreezeOffset as g, type ColumnFreezeSide as h, type DataTableClassNames as i, type DataTableCopyActions as j, type DataTableLabels as k, type DataTableProps as l, type DataTableScrollSlotProps as m, type DataTableSlots as n, type RowsPastePayload as o, type SearchResultItem as p, type SearchStatus as q, type TableColumnProps as r, type TableProps as s, buildColumnFreezeOffsets as t, buildFlatSearchCorpus as u, buildSearchMatchKey as v, buildSearchMatchKeys as w, buildTreeSearchCorpus as x, cellValueToSearchText as y, collectAncestorKeysToExpand as z };
@@ -1,5 +1,32 @@
1
- import { ColumnDef, RowSelectionState, Updater, ColumnSizingState, OnChangeFn, ColumnResizeMode, Row } from '@tanstack/react-table';
2
- import { CSSProperties, ReactNode, InputHTMLAttributes, ComponentType, Ref } from 'react';
1
+ import { Row, ColumnDef, RowSelectionState, Updater, ColumnSizingState, OnChangeFn, ColumnResizeMode } from '@tanstack/react-table';
2
+ import { ReactNode, CSSProperties, InputHTMLAttributes, ComponentType, Ref } from 'react';
3
+
4
+ /**
5
+ * Built-in cell kinds inspired by Glide Data Grid All Cell Kinds.
6
+ * Custom kinds are plain strings registered via `cellRenderers`.
7
+ */
8
+ type BuiltinCellKind = "text" | "number" | "boolean" | "uri" | "image" | "bubble" | "markdown" | "drilldown" | "loading" | "protected" | "row-id";
9
+ type CellKind = BuiltinCellKind | (string & {});
10
+ type CellRenderContext<T extends Record<string, unknown> = Record<string, unknown>, V = unknown> = {
11
+ value: V;
12
+ row: Row<T>;
13
+ index: number;
14
+ columnId: string;
15
+ /** Kind-specific props from `Column.cellProps` / `meta.cellProps` */
16
+ cellProps?: Record<string, unknown>;
17
+ /**
18
+ * Commit a cell value through the table's `onCellChange` / `onDataChange` pipeline.
19
+ * Prefer this over calling `setData` directly from custom renders.
20
+ */
21
+ update: (next: V) => void;
22
+ };
23
+ type CellRenderer<T extends Record<string, unknown> = Record<string, unknown>, V = unknown> = {
24
+ kind: CellKind;
25
+ render: (ctx: CellRenderContext<T, V>) => ReactNode;
26
+ /** Optional extra match when resolving custom renderers */
27
+ isMatch?: (ctx: CellRenderContext<T, V>) => boolean;
28
+ };
29
+ type CellRenderFn<T extends Record<string, unknown> = Record<string, unknown>, V = unknown> = (ctx: CellRenderContext<T, V>) => ReactNode;
3
30
 
4
31
  /** Sticky edge for a frozen column. Does not reorder columns. */
5
32
  type ColumnFreezeSide = "left" | "right";
@@ -46,7 +73,24 @@ declare function buildColumnFreezeOffsets(columns: ColumnFreezeColumnInput[]): M
46
73
  /** Sticky position styles for a frozen header or body cell. */
47
74
  declare function getColumnFreezeStyle(offset: ColumnFreezeOffset | undefined, options?: {
48
75
  isHeader?: boolean;
76
+ /**
77
+ * @deprecated Unused. Vertical sticky belongs on `thead` (`classNames.head`),
78
+ * not on frozen header cells — dual `top` sticky detaches freeze bands.
79
+ */
80
+ headerTop?: number;
49
81
  }): CSSProperties | undefined;
82
+ type HeaderFreezeColumnLike = {
83
+ id: string;
84
+ columns?: HeaderFreezeColumnLike[];
85
+ getLeafColumns?: () => HeaderFreezeColumnLike[];
86
+ };
87
+ /**
88
+ * Resolve freeze offset for a header cell.
89
+ * Leaf columns use the leaf map directly. Group headers inherit sticky
90
+ * positioning only when every leaf is frozen on the same side — otherwise a
91
+ * scrolled-away group label leaves frozen leaves looking like a detached band.
92
+ */
93
+ declare function resolveHeaderFreezeOffset(column: HeaderFreezeColumnLike, freezeOffsets: Map<string, ColumnFreezeOffset>): ColumnFreezeOffset | undefined;
50
94
 
51
95
  /** Cell match as `[colIndex, rowIndex]` — same order as Glide Data Grid `Item`.
52
96
  * For tree tables, `rowIndex` is the search-corpus index (includes collapsed rows).
@@ -147,6 +191,15 @@ declare module "@tanstack/react-table" {
147
191
  editType?: CellEditType;
148
192
  /** Inline editor input attribute overrides */
149
193
  editInputProps?: DataTableEditInputProps;
194
+ /**
195
+ * Built-in or custom cell kind. Resolved via table `cellRenderers` registry.
196
+ * Column `render` takes precedence over `kind`.
197
+ */
198
+ kind?: CellKind;
199
+ /** Extra props forwarded to the kind / custom renderer as `ctx.cellProps` */
200
+ cellProps?: Record<string, unknown>;
201
+ /** Compound `Column.render` stored for `ResolvedTableCell` */
202
+ cellRender?: CellRenderFn<Record<string, unknown>>;
150
203
  /**
151
204
  * Freeze (sticky) this column without reordering.
152
205
  * `true` / `"left"` stick to the scrollport left; `"right"` to the right.
@@ -251,6 +304,12 @@ type DataTableProps<T extends Record<string, unknown>> = {
251
304
  columnId: string;
252
305
  value: unknown;
253
306
  }>) => void;
307
+ /**
308
+ * Extra / overriding cell kind renderers (same `kind` replaces builtins).
309
+ * Built-ins: text, number, boolean, uri, image, bubble, markdown, drilldown,
310
+ * loading, protected, row-id.
311
+ */
312
+ cellRenderers?: readonly CellRenderer[];
254
313
  /**
255
314
  * Root className hook (combined with `DataTableJSX`).
256
315
  * The package ships no CSS — style these hooks yourself or leave unstyled.
@@ -474,12 +533,33 @@ type TableColumnProps<T extends Record<string, unknown>, K extends string = keyo
474
533
  editType?: CellEditType;
475
534
  /** Inline editor input attribute overrides */
476
535
  editInputProps?: DataTableEditInputProps;
536
+ /**
537
+ * Cell kind for the built-in / custom renderer registry.
538
+ * Ignored when `render` is set (render wins).
539
+ */
540
+ kind?: CellKind;
541
+ /** Extra props for the kind renderer (`ctx.cellProps`) */
542
+ cellProps?: Record<string, unknown>;
477
543
  className?: string;
478
544
  headerClassName?: string;
479
- render?: (value: K extends keyof T ? T[K] : unknown, row: Row<T>, index: number) => ReactNode;
545
+ /**
546
+ * Custom cell content. Receives a single context object — destructure what you need.
547
+ * Use `update` to commit via `onCellChange` / `onDataChange`.
548
+ */
549
+ render?: CellRenderFn<T, K extends keyof T ? T[K] : unknown>;
550
+ };
551
+ /** Declares a multi-row header group wrapping leaf `Table.Column`s. */
552
+ type TableColumnGroupProps = {
553
+ /** Group header label shown in the top header row */
554
+ header: ReactNode;
555
+ children: ReactNode;
556
+ /** Stable group id. Auto-generated when omitted */
557
+ id?: string;
558
+ align?: "left" | "center" | "right";
559
+ headerClassName?: string;
480
560
  };
481
561
  type TableProps<T extends Record<string, unknown>> = Omit<DataTableProps<T>, "columns"> & {
482
562
  children: ReactNode;
483
563
  };
484
564
 
485
- export { getColumnFreezeStyle as A, mapSearchResultToVisibleItem as B, type ColumnFreezeColumnInput as C, DEFAULT_DATA_TABLE_LABELS as D, mapSearchResultsToVisibleKeys as E, nextSearchIndex as F, nextSearchStride as G, previousSearchIndex as H, INLINE_SEARCH_MAX_RESULTS as I, resolveColumnFreezeSide as J, resolveDataTableLabels as K, type CellEditType as L, type PasteMode as P, type RowSelectionMode as R, type SearchCorpusRow as S, type TableColumnProps as T, type ColumnFreezeEdgeSide as a, type ColumnFreezeMeta as b, type ColumnFreezeOffset as c, type ColumnFreezeSide as d, type DataTableClassNames as e, type DataTableCopyActions as f, type DataTableLabels as g, type DataTableProps as h, type DataTableScrollSlotProps as i, type DataTableSlots as j, type RowsPastePayload as k, type SearchResultItem as l, type SearchStatus as m, type TableProps as n, buildColumnFreezeOffsets as o, buildFlatSearchCorpus as p, buildSearchMatchKey as q, buildSearchMatchKeys as r, buildTreeSearchCorpus as s, cellValueToSearchText as t, collectAncestorKeysToExpand as u, collectSearchMatchesInRange as v, createSearchRegex as w, escapeSearchRegex as x, formatSearchResultLabel as y, getColumnFreezeEdgeAttr as z };
565
+ export { collectSearchMatchesInRange as A, type BuiltinCellKind as B, type CellKind as C, DEFAULT_DATA_TABLE_LABELS as D, createSearchRegex as E, escapeSearchRegex as F, formatSearchResultLabel as G, getColumnFreezeEdgeAttr as H, INLINE_SEARCH_MAX_RESULTS as I, getColumnFreezeStyle as J, mapSearchResultToVisibleItem as K, mapSearchResultsToVisibleKeys as L, nextSearchIndex as M, nextSearchStride as N, previousSearchIndex as O, type PasteMode as P, resolveColumnFreezeSide as Q, type RowSelectionMode as R, type SearchCorpusRow as S, type TableColumnGroupProps as T, resolveDataTableLabels as U, resolveHeaderFreezeOffset as V, type CellEditType as W, type CellRenderContext as a, type CellRenderFn as b, type CellRenderer as c, type ColumnFreezeColumnInput as d, type ColumnFreezeEdgeSide as e, type ColumnFreezeMeta as f, type ColumnFreezeOffset as g, type ColumnFreezeSide as h, type DataTableClassNames as i, type DataTableCopyActions as j, type DataTableLabels as k, type DataTableProps as l, type DataTableScrollSlotProps as m, type DataTableSlots as n, type RowsPastePayload as o, type SearchResultItem as p, type SearchStatus as q, type TableColumnProps as r, type TableProps as s, buildColumnFreezeOffsets as t, buildFlatSearchCorpus as u, buildSearchMatchKey as v, buildSearchMatchKeys as w, buildTreeSearchCorpus as x, cellValueToSearchText as y, collectAncestorKeysToExpand as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-glide-table",
3
- "version": "1.6.0",
3
+ "version": "2.0.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/zpxlffjrm/react-glide-table.git"