react-glide-table 1.7.0 → 2.0.2
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/README.md +87 -6
- package/dist/compound.cjs +474 -98
- package/dist/compound.d.cts +2 -2
- package/dist/compound.d.ts +2 -2
- package/dist/compound.js +459 -83
- package/dist/core.cjs +416 -12
- package/dist/core.d.cts +58 -4
- package/dist/core.d.ts +58 -4
- package/dist/core.js +407 -12
- package/dist/index.cjs +574 -166
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +545 -146
- package/dist/{types-Cs9MiZs1.d.cts → types-bgEceyRV.d.cts} +82 -4
- package/dist/{types-Cs9MiZs1.d.ts → types-bgEceyRV.d.ts} +82 -4
- package/package.json +1 -1
|
@@ -1,5 +1,32 @@
|
|
|
1
|
-
import { ColumnDef, RowSelectionState, Updater, ColumnSizingState, OnChangeFn, ColumnResizeMode
|
|
2
|
-
import {
|
|
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,8 +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
|
+
*/
|
|
49
80
|
headerTop?: number;
|
|
50
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;
|
|
51
94
|
|
|
52
95
|
/** Cell match as `[colIndex, rowIndex]` — same order as Glide Data Grid `Item`.
|
|
53
96
|
* For tree tables, `rowIndex` is the search-corpus index (includes collapsed rows).
|
|
@@ -148,6 +191,15 @@ declare module "@tanstack/react-table" {
|
|
|
148
191
|
editType?: CellEditType;
|
|
149
192
|
/** Inline editor input attribute overrides */
|
|
150
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>>;
|
|
151
203
|
/**
|
|
152
204
|
* Freeze (sticky) this column without reordering.
|
|
153
205
|
* `true` / `"left"` stick to the scrollport left; `"right"` to the right.
|
|
@@ -155,6 +207,15 @@ declare module "@tanstack/react-table" {
|
|
|
155
207
|
*/
|
|
156
208
|
frozen?: ColumnFreezeMeta;
|
|
157
209
|
}
|
|
210
|
+
interface CellContext<TData, TValue> {
|
|
211
|
+
/**
|
|
212
|
+
* Commit a cell value through `onCellChange` / `onDataChange`.
|
|
213
|
+
* Present at runtime only when the context was wrapped by `DataTable`,
|
|
214
|
+
* `withCellUpdate`, or `useGlideTable().getCellContext` — not on bare
|
|
215
|
+
* `cell.getContext()`. Prefer those helpers for a guaranteed `update`.
|
|
216
|
+
*/
|
|
217
|
+
update?: (next: TValue) => void;
|
|
218
|
+
}
|
|
158
219
|
interface Row<TData> {
|
|
159
220
|
/**
|
|
160
221
|
* Returns whether this row's cell is inside the active drag selection.
|
|
@@ -252,6 +313,12 @@ type DataTableProps<T extends Record<string, unknown>> = {
|
|
|
252
313
|
columnId: string;
|
|
253
314
|
value: unknown;
|
|
254
315
|
}>) => void;
|
|
316
|
+
/**
|
|
317
|
+
* Extra / overriding cell kind renderers (same `kind` replaces builtins).
|
|
318
|
+
* Built-ins: text, number, boolean, uri, image, bubble, markdown, drilldown,
|
|
319
|
+
* loading, protected, row-id.
|
|
320
|
+
*/
|
|
321
|
+
cellRenderers?: readonly CellRenderer[];
|
|
255
322
|
/**
|
|
256
323
|
* Root className hook (combined with `DataTableJSX`).
|
|
257
324
|
* The package ships no CSS — style these hooks yourself or leave unstyled.
|
|
@@ -475,9 +542,20 @@ type TableColumnProps<T extends Record<string, unknown>, K extends string = keyo
|
|
|
475
542
|
editType?: CellEditType;
|
|
476
543
|
/** Inline editor input attribute overrides */
|
|
477
544
|
editInputProps?: DataTableEditInputProps;
|
|
545
|
+
/**
|
|
546
|
+
* Cell kind for the built-in / custom renderer registry.
|
|
547
|
+
* Ignored when `render` is set (render wins).
|
|
548
|
+
*/
|
|
549
|
+
kind?: CellKind;
|
|
550
|
+
/** Extra props for the kind renderer (`ctx.cellProps`) */
|
|
551
|
+
cellProps?: Record<string, unknown>;
|
|
478
552
|
className?: string;
|
|
479
553
|
headerClassName?: string;
|
|
480
|
-
|
|
554
|
+
/**
|
|
555
|
+
* Custom cell content. Receives a single context object — destructure what you need.
|
|
556
|
+
* Use `update` to commit via `onCellChange` / `onDataChange`.
|
|
557
|
+
*/
|
|
558
|
+
render?: CellRenderFn<T, K extends keyof T ? T[K] : unknown>;
|
|
481
559
|
};
|
|
482
560
|
/** Declares a multi-row header group wrapping leaf `Table.Column`s. */
|
|
483
561
|
type TableColumnGroupProps = {
|
|
@@ -493,4 +571,4 @@ type TableProps<T extends Record<string, unknown>> = Omit<DataTableProps<T>, "co
|
|
|
493
571
|
children: ReactNode;
|
|
494
572
|
};
|
|
495
573
|
|
|
496
|
-
export {
|
|
574
|
+
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
|
|
2
|
-
import {
|
|
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,8 +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
|
+
*/
|
|
49
80
|
headerTop?: number;
|
|
50
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;
|
|
51
94
|
|
|
52
95
|
/** Cell match as `[colIndex, rowIndex]` — same order as Glide Data Grid `Item`.
|
|
53
96
|
* For tree tables, `rowIndex` is the search-corpus index (includes collapsed rows).
|
|
@@ -148,6 +191,15 @@ declare module "@tanstack/react-table" {
|
|
|
148
191
|
editType?: CellEditType;
|
|
149
192
|
/** Inline editor input attribute overrides */
|
|
150
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>>;
|
|
151
203
|
/**
|
|
152
204
|
* Freeze (sticky) this column without reordering.
|
|
153
205
|
* `true` / `"left"` stick to the scrollport left; `"right"` to the right.
|
|
@@ -155,6 +207,15 @@ declare module "@tanstack/react-table" {
|
|
|
155
207
|
*/
|
|
156
208
|
frozen?: ColumnFreezeMeta;
|
|
157
209
|
}
|
|
210
|
+
interface CellContext<TData, TValue> {
|
|
211
|
+
/**
|
|
212
|
+
* Commit a cell value through `onCellChange` / `onDataChange`.
|
|
213
|
+
* Present at runtime only when the context was wrapped by `DataTable`,
|
|
214
|
+
* `withCellUpdate`, or `useGlideTable().getCellContext` — not on bare
|
|
215
|
+
* `cell.getContext()`. Prefer those helpers for a guaranteed `update`.
|
|
216
|
+
*/
|
|
217
|
+
update?: (next: TValue) => void;
|
|
218
|
+
}
|
|
158
219
|
interface Row<TData> {
|
|
159
220
|
/**
|
|
160
221
|
* Returns whether this row's cell is inside the active drag selection.
|
|
@@ -252,6 +313,12 @@ type DataTableProps<T extends Record<string, unknown>> = {
|
|
|
252
313
|
columnId: string;
|
|
253
314
|
value: unknown;
|
|
254
315
|
}>) => void;
|
|
316
|
+
/**
|
|
317
|
+
* Extra / overriding cell kind renderers (same `kind` replaces builtins).
|
|
318
|
+
* Built-ins: text, number, boolean, uri, image, bubble, markdown, drilldown,
|
|
319
|
+
* loading, protected, row-id.
|
|
320
|
+
*/
|
|
321
|
+
cellRenderers?: readonly CellRenderer[];
|
|
255
322
|
/**
|
|
256
323
|
* Root className hook (combined with `DataTableJSX`).
|
|
257
324
|
* The package ships no CSS — style these hooks yourself or leave unstyled.
|
|
@@ -475,9 +542,20 @@ type TableColumnProps<T extends Record<string, unknown>, K extends string = keyo
|
|
|
475
542
|
editType?: CellEditType;
|
|
476
543
|
/** Inline editor input attribute overrides */
|
|
477
544
|
editInputProps?: DataTableEditInputProps;
|
|
545
|
+
/**
|
|
546
|
+
* Cell kind for the built-in / custom renderer registry.
|
|
547
|
+
* Ignored when `render` is set (render wins).
|
|
548
|
+
*/
|
|
549
|
+
kind?: CellKind;
|
|
550
|
+
/** Extra props for the kind renderer (`ctx.cellProps`) */
|
|
551
|
+
cellProps?: Record<string, unknown>;
|
|
478
552
|
className?: string;
|
|
479
553
|
headerClassName?: string;
|
|
480
|
-
|
|
554
|
+
/**
|
|
555
|
+
* Custom cell content. Receives a single context object — destructure what you need.
|
|
556
|
+
* Use `update` to commit via `onCellChange` / `onDataChange`.
|
|
557
|
+
*/
|
|
558
|
+
render?: CellRenderFn<T, K extends keyof T ? T[K] : unknown>;
|
|
481
559
|
};
|
|
482
560
|
/** Declares a multi-row header group wrapping leaf `Table.Column`s. */
|
|
483
561
|
type TableColumnGroupProps = {
|
|
@@ -493,4 +571,4 @@ type TableProps<T extends Record<string, unknown>> = Omit<DataTableProps<T>, "co
|
|
|
493
571
|
children: ReactNode;
|
|
494
572
|
};
|
|
495
573
|
|
|
496
|
-
export {
|
|
574
|
+
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 };
|