react-glide-table 1.4.1 → 1.7.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.
- package/README.md +32 -2
- package/dist/compound.cjs +1222 -119
- package/dist/compound.d.cts +11 -3
- package/dist/compound.d.ts +11 -3
- package/dist/compound.js +1224 -114
- package/dist/core.cjs +874 -48
- package/dist/core.d.cts +73 -6
- package/dist/core.d.ts +73 -6
- package/dist/core.js +868 -52
- package/dist/index.cjs +1270 -133
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1252 -125
- package/dist/{types-CHQnBz91.d.cts → types-Cs9MiZs1.d.cts} +104 -1
- package/dist/{types-CHQnBz91.d.ts → types-Cs9MiZs1.d.ts} +104 -1
- package/package.json +1 -1
|
@@ -46,8 +46,70 @@ declare function buildColumnFreezeOffsets(columns: ColumnFreezeColumnInput[]): M
|
|
|
46
46
|
/** Sticky position styles for a frozen header or body cell. */
|
|
47
47
|
declare function getColumnFreezeStyle(offset: ColumnFreezeOffset | undefined, options?: {
|
|
48
48
|
isHeader?: boolean;
|
|
49
|
+
headerTop?: number;
|
|
49
50
|
}): CSSProperties | undefined;
|
|
50
51
|
|
|
52
|
+
/** Cell match as `[colIndex, rowIndex]` — same order as Glide Data Grid `Item`.
|
|
53
|
+
* For tree tables, `rowIndex` is the search-corpus index (includes collapsed rows).
|
|
54
|
+
*/
|
|
55
|
+
type SearchResultItem = readonly [colIndex: number, rowIndex: number];
|
|
56
|
+
type SearchStatus = {
|
|
57
|
+
rowsSearched: number;
|
|
58
|
+
results: number;
|
|
59
|
+
selectedIndex: number;
|
|
60
|
+
};
|
|
61
|
+
/** One searchable row, including collapsed tree descendants. */
|
|
62
|
+
type SearchCorpusRow<T extends Record<string, unknown> = Record<string, unknown>> = {
|
|
63
|
+
/** Stable row id used to resolve the visible index after expand */
|
|
64
|
+
id: string;
|
|
65
|
+
data: T;
|
|
66
|
+
/**
|
|
67
|
+
* Toggle-field keys of ancestors that must be in `expandedRows`
|
|
68
|
+
* for this row to become visible.
|
|
69
|
+
*/
|
|
70
|
+
ancestorToggleKeys: string[];
|
|
71
|
+
};
|
|
72
|
+
declare const INLINE_SEARCH_MAX_RESULTS = 1000;
|
|
73
|
+
declare function escapeSearchRegex(value: string): string;
|
|
74
|
+
declare function createSearchRegex(query: string): RegExp | null;
|
|
75
|
+
declare function cellValueToSearchText(value: unknown): string | undefined;
|
|
76
|
+
declare function formatSearchResultLabel(status: SearchStatus): string;
|
|
77
|
+
declare function nextSearchIndex(selectedIndex: number, results: number): number;
|
|
78
|
+
declare function previousSearchIndex(selectedIndex: number, results: number): number;
|
|
79
|
+
declare function buildSearchMatchKey(colIndex: number, rowIndex: number): string;
|
|
80
|
+
declare function buildSearchMatchKeys(results: readonly SearchResultItem[]): Set<string>;
|
|
81
|
+
/**
|
|
82
|
+
* Scan a contiguous row window for matches.
|
|
83
|
+
* Returns newly found items (appended in row-major, col-major order).
|
|
84
|
+
*/
|
|
85
|
+
declare function collectSearchMatchesInRange(options: {
|
|
86
|
+
query: string;
|
|
87
|
+
startRow: number;
|
|
88
|
+
rowCount: number;
|
|
89
|
+
columnCount: number;
|
|
90
|
+
getCellValue: (rowIndex: number, colIndex: number) => unknown;
|
|
91
|
+
maxResults?: number;
|
|
92
|
+
}): SearchResultItem[];
|
|
93
|
+
declare function nextSearchStride(currentStride: number, elapsedMs: number, targetMs?: number): number;
|
|
94
|
+
/**
|
|
95
|
+
* Flat (non-tree) search corpus — one entry per visible row.
|
|
96
|
+
*/
|
|
97
|
+
declare function buildFlatSearchCorpus<T extends Record<string, unknown>>(rows: T[], getRowId: (row: T, index: number) => string): SearchCorpusRow<T>[];
|
|
98
|
+
/**
|
|
99
|
+
* Build a search corpus that includes collapsed tree descendants.
|
|
100
|
+
* Starts from root rows (`level === 0`) and walks each node's `children`.
|
|
101
|
+
*/
|
|
102
|
+
declare function buildTreeSearchCorpus<T extends Record<string, unknown>>(visibleRows: T[], options: {
|
|
103
|
+
toggleField: string;
|
|
104
|
+
getRowId: (row: T, index: number) => string;
|
|
105
|
+
}): SearchCorpusRow<T>[];
|
|
106
|
+
/**
|
|
107
|
+
* Map corpus-indexed search results onto currently visible row indices for highlighting.
|
|
108
|
+
*/
|
|
109
|
+
declare function mapSearchResultsToVisibleKeys(results: readonly SearchResultItem[], corpus: readonly SearchCorpusRow[], visibleRowIndexById: Map<string, number>): Set<string>;
|
|
110
|
+
declare function mapSearchResultToVisibleItem(item: SearchResultItem, corpus: readonly SearchCorpusRow[], visibleRowIndexById: Map<string, number>): SearchResultItem | null;
|
|
111
|
+
declare function collectAncestorKeysToExpand(corpusRow: SearchCorpusRow, expandedRows: Set<string>): string[];
|
|
112
|
+
|
|
51
113
|
type DataTableLabels = {
|
|
52
114
|
empty: string;
|
|
53
115
|
loading: string;
|
|
@@ -56,6 +118,12 @@ type DataTableLabels = {
|
|
|
56
118
|
collapseRow: string;
|
|
57
119
|
/** Accessible label for the column resize handle */
|
|
58
120
|
resizeColumn: string;
|
|
121
|
+
/** Built-in find-in-page search overlay */
|
|
122
|
+
searchPlaceholder: string;
|
|
123
|
+
searchResultHint: string;
|
|
124
|
+
searchPrevious: string;
|
|
125
|
+
searchNext: string;
|
|
126
|
+
searchClose: string;
|
|
59
127
|
};
|
|
60
128
|
/** Default copy. Override via the `labels` option. */
|
|
61
129
|
declare const DEFAULT_DATA_TABLE_LABELS: DataTableLabels;
|
|
@@ -254,6 +322,25 @@ type DataTableProps<T extends Record<string, unknown>> = {
|
|
|
254
322
|
* Does not reorder columns; offsets stack so frozen cells do not overlap.
|
|
255
323
|
*/
|
|
256
324
|
enableColumnFreeze?: boolean;
|
|
325
|
+
/**
|
|
326
|
+
* Enable Glide-style built-in find-in-page search (Ctrl/Cmd+F).
|
|
327
|
+
* Highlights matching cells; Enter / buttons navigate without filtering rows.
|
|
328
|
+
* Defaults to false.
|
|
329
|
+
*/
|
|
330
|
+
enableInlineSearch?: boolean;
|
|
331
|
+
/** Controlled search overlay visibility. When omitted, Ctrl/Cmd+F toggles internally. */
|
|
332
|
+
showSearch?: boolean;
|
|
333
|
+
/** Controlled search query string. */
|
|
334
|
+
searchValue?: string;
|
|
335
|
+
onSearchValueChange?: (value: string) => void;
|
|
336
|
+
/**
|
|
337
|
+
* Emitted when the overlay close control is used (X / Escape / Ctrl+F in the box).
|
|
338
|
+
* Providing this shows the close button. For controlled `showSearch`, set it false here.
|
|
339
|
+
*/
|
|
340
|
+
onSearchClose?: () => void;
|
|
341
|
+
/** Override the internal match list (`[colIndex, rowIndex]`). */
|
|
342
|
+
searchResults?: readonly SearchResultItem[];
|
|
343
|
+
onSearchResultsChanged?: (results: readonly SearchResultItem[], navIndex: number) => void;
|
|
257
344
|
/**
|
|
258
345
|
* Optional UI part replacements for the unstyled DataTable renderer.
|
|
259
346
|
* Use with `createTable` / `Table.Column`, or pass columns directly to `DataTable`.
|
|
@@ -295,6 +382,12 @@ type DataTableClassNames = {
|
|
|
295
382
|
expandToggle?: string;
|
|
296
383
|
expandToggleIcon?: string;
|
|
297
384
|
fillHandle?: string;
|
|
385
|
+
/** Built-in search overlay root */
|
|
386
|
+
search?: string;
|
|
387
|
+
searchInput?: string;
|
|
388
|
+
searchButton?: string;
|
|
389
|
+
searchStatus?: string;
|
|
390
|
+
searchProgress?: string;
|
|
298
391
|
};
|
|
299
392
|
type DataTableToolbarSlotProps = {
|
|
300
393
|
filteredCount?: number;
|
|
@@ -386,8 +479,18 @@ type TableColumnProps<T extends Record<string, unknown>, K extends string = keyo
|
|
|
386
479
|
headerClassName?: string;
|
|
387
480
|
render?: (value: K extends keyof T ? T[K] : unknown, row: Row<T>, index: number) => ReactNode;
|
|
388
481
|
};
|
|
482
|
+
/** Declares a multi-row header group wrapping leaf `Table.Column`s. */
|
|
483
|
+
type TableColumnGroupProps = {
|
|
484
|
+
/** Group header label shown in the top header row */
|
|
485
|
+
header: ReactNode;
|
|
486
|
+
children: ReactNode;
|
|
487
|
+
/** Stable group id. Auto-generated when omitted */
|
|
488
|
+
id?: string;
|
|
489
|
+
align?: "left" | "center" | "right";
|
|
490
|
+
headerClassName?: string;
|
|
491
|
+
};
|
|
389
492
|
type TableProps<T extends Record<string, unknown>> = Omit<DataTableProps<T>, "columns"> & {
|
|
390
493
|
children: ReactNode;
|
|
391
494
|
};
|
|
392
495
|
|
|
393
|
-
export { type ColumnFreezeColumnInput as C, DEFAULT_DATA_TABLE_LABELS as D, type PasteMode as P, type RowSelectionMode as R, type
|
|
496
|
+
export { getColumnFreezeEdgeAttr as A, getColumnFreezeStyle as B, type ColumnFreezeColumnInput as C, DEFAULT_DATA_TABLE_LABELS as D, mapSearchResultToVisibleItem as E, mapSearchResultsToVisibleKeys as F, nextSearchIndex as G, nextSearchStride as H, INLINE_SEARCH_MAX_RESULTS as I, previousSearchIndex as J, resolveColumnFreezeSide as K, resolveDataTableLabels as L, type CellEditType as M, type PasteMode as P, type RowSelectionMode as R, type SearchCorpusRow as S, type TableColumnGroupProps 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 TableColumnProps as n, type TableProps as o, buildColumnFreezeOffsets as p, buildFlatSearchCorpus as q, buildSearchMatchKey as r, buildSearchMatchKeys as s, buildTreeSearchCorpus as t, cellValueToSearchText as u, collectAncestorKeysToExpand as v, collectSearchMatchesInRange as w, createSearchRegex as x, escapeSearchRegex as y, formatSearchResultLabel as z };
|
|
@@ -46,8 +46,70 @@ declare function buildColumnFreezeOffsets(columns: ColumnFreezeColumnInput[]): M
|
|
|
46
46
|
/** Sticky position styles for a frozen header or body cell. */
|
|
47
47
|
declare function getColumnFreezeStyle(offset: ColumnFreezeOffset | undefined, options?: {
|
|
48
48
|
isHeader?: boolean;
|
|
49
|
+
headerTop?: number;
|
|
49
50
|
}): CSSProperties | undefined;
|
|
50
51
|
|
|
52
|
+
/** Cell match as `[colIndex, rowIndex]` — same order as Glide Data Grid `Item`.
|
|
53
|
+
* For tree tables, `rowIndex` is the search-corpus index (includes collapsed rows).
|
|
54
|
+
*/
|
|
55
|
+
type SearchResultItem = readonly [colIndex: number, rowIndex: number];
|
|
56
|
+
type SearchStatus = {
|
|
57
|
+
rowsSearched: number;
|
|
58
|
+
results: number;
|
|
59
|
+
selectedIndex: number;
|
|
60
|
+
};
|
|
61
|
+
/** One searchable row, including collapsed tree descendants. */
|
|
62
|
+
type SearchCorpusRow<T extends Record<string, unknown> = Record<string, unknown>> = {
|
|
63
|
+
/** Stable row id used to resolve the visible index after expand */
|
|
64
|
+
id: string;
|
|
65
|
+
data: T;
|
|
66
|
+
/**
|
|
67
|
+
* Toggle-field keys of ancestors that must be in `expandedRows`
|
|
68
|
+
* for this row to become visible.
|
|
69
|
+
*/
|
|
70
|
+
ancestorToggleKeys: string[];
|
|
71
|
+
};
|
|
72
|
+
declare const INLINE_SEARCH_MAX_RESULTS = 1000;
|
|
73
|
+
declare function escapeSearchRegex(value: string): string;
|
|
74
|
+
declare function createSearchRegex(query: string): RegExp | null;
|
|
75
|
+
declare function cellValueToSearchText(value: unknown): string | undefined;
|
|
76
|
+
declare function formatSearchResultLabel(status: SearchStatus): string;
|
|
77
|
+
declare function nextSearchIndex(selectedIndex: number, results: number): number;
|
|
78
|
+
declare function previousSearchIndex(selectedIndex: number, results: number): number;
|
|
79
|
+
declare function buildSearchMatchKey(colIndex: number, rowIndex: number): string;
|
|
80
|
+
declare function buildSearchMatchKeys(results: readonly SearchResultItem[]): Set<string>;
|
|
81
|
+
/**
|
|
82
|
+
* Scan a contiguous row window for matches.
|
|
83
|
+
* Returns newly found items (appended in row-major, col-major order).
|
|
84
|
+
*/
|
|
85
|
+
declare function collectSearchMatchesInRange(options: {
|
|
86
|
+
query: string;
|
|
87
|
+
startRow: number;
|
|
88
|
+
rowCount: number;
|
|
89
|
+
columnCount: number;
|
|
90
|
+
getCellValue: (rowIndex: number, colIndex: number) => unknown;
|
|
91
|
+
maxResults?: number;
|
|
92
|
+
}): SearchResultItem[];
|
|
93
|
+
declare function nextSearchStride(currentStride: number, elapsedMs: number, targetMs?: number): number;
|
|
94
|
+
/**
|
|
95
|
+
* Flat (non-tree) search corpus — one entry per visible row.
|
|
96
|
+
*/
|
|
97
|
+
declare function buildFlatSearchCorpus<T extends Record<string, unknown>>(rows: T[], getRowId: (row: T, index: number) => string): SearchCorpusRow<T>[];
|
|
98
|
+
/**
|
|
99
|
+
* Build a search corpus that includes collapsed tree descendants.
|
|
100
|
+
* Starts from root rows (`level === 0`) and walks each node's `children`.
|
|
101
|
+
*/
|
|
102
|
+
declare function buildTreeSearchCorpus<T extends Record<string, unknown>>(visibleRows: T[], options: {
|
|
103
|
+
toggleField: string;
|
|
104
|
+
getRowId: (row: T, index: number) => string;
|
|
105
|
+
}): SearchCorpusRow<T>[];
|
|
106
|
+
/**
|
|
107
|
+
* Map corpus-indexed search results onto currently visible row indices for highlighting.
|
|
108
|
+
*/
|
|
109
|
+
declare function mapSearchResultsToVisibleKeys(results: readonly SearchResultItem[], corpus: readonly SearchCorpusRow[], visibleRowIndexById: Map<string, number>): Set<string>;
|
|
110
|
+
declare function mapSearchResultToVisibleItem(item: SearchResultItem, corpus: readonly SearchCorpusRow[], visibleRowIndexById: Map<string, number>): SearchResultItem | null;
|
|
111
|
+
declare function collectAncestorKeysToExpand(corpusRow: SearchCorpusRow, expandedRows: Set<string>): string[];
|
|
112
|
+
|
|
51
113
|
type DataTableLabels = {
|
|
52
114
|
empty: string;
|
|
53
115
|
loading: string;
|
|
@@ -56,6 +118,12 @@ type DataTableLabels = {
|
|
|
56
118
|
collapseRow: string;
|
|
57
119
|
/** Accessible label for the column resize handle */
|
|
58
120
|
resizeColumn: string;
|
|
121
|
+
/** Built-in find-in-page search overlay */
|
|
122
|
+
searchPlaceholder: string;
|
|
123
|
+
searchResultHint: string;
|
|
124
|
+
searchPrevious: string;
|
|
125
|
+
searchNext: string;
|
|
126
|
+
searchClose: string;
|
|
59
127
|
};
|
|
60
128
|
/** Default copy. Override via the `labels` option. */
|
|
61
129
|
declare const DEFAULT_DATA_TABLE_LABELS: DataTableLabels;
|
|
@@ -254,6 +322,25 @@ type DataTableProps<T extends Record<string, unknown>> = {
|
|
|
254
322
|
* Does not reorder columns; offsets stack so frozen cells do not overlap.
|
|
255
323
|
*/
|
|
256
324
|
enableColumnFreeze?: boolean;
|
|
325
|
+
/**
|
|
326
|
+
* Enable Glide-style built-in find-in-page search (Ctrl/Cmd+F).
|
|
327
|
+
* Highlights matching cells; Enter / buttons navigate without filtering rows.
|
|
328
|
+
* Defaults to false.
|
|
329
|
+
*/
|
|
330
|
+
enableInlineSearch?: boolean;
|
|
331
|
+
/** Controlled search overlay visibility. When omitted, Ctrl/Cmd+F toggles internally. */
|
|
332
|
+
showSearch?: boolean;
|
|
333
|
+
/** Controlled search query string. */
|
|
334
|
+
searchValue?: string;
|
|
335
|
+
onSearchValueChange?: (value: string) => void;
|
|
336
|
+
/**
|
|
337
|
+
* Emitted when the overlay close control is used (X / Escape / Ctrl+F in the box).
|
|
338
|
+
* Providing this shows the close button. For controlled `showSearch`, set it false here.
|
|
339
|
+
*/
|
|
340
|
+
onSearchClose?: () => void;
|
|
341
|
+
/** Override the internal match list (`[colIndex, rowIndex]`). */
|
|
342
|
+
searchResults?: readonly SearchResultItem[];
|
|
343
|
+
onSearchResultsChanged?: (results: readonly SearchResultItem[], navIndex: number) => void;
|
|
257
344
|
/**
|
|
258
345
|
* Optional UI part replacements for the unstyled DataTable renderer.
|
|
259
346
|
* Use with `createTable` / `Table.Column`, or pass columns directly to `DataTable`.
|
|
@@ -295,6 +382,12 @@ type DataTableClassNames = {
|
|
|
295
382
|
expandToggle?: string;
|
|
296
383
|
expandToggleIcon?: string;
|
|
297
384
|
fillHandle?: string;
|
|
385
|
+
/** Built-in search overlay root */
|
|
386
|
+
search?: string;
|
|
387
|
+
searchInput?: string;
|
|
388
|
+
searchButton?: string;
|
|
389
|
+
searchStatus?: string;
|
|
390
|
+
searchProgress?: string;
|
|
298
391
|
};
|
|
299
392
|
type DataTableToolbarSlotProps = {
|
|
300
393
|
filteredCount?: number;
|
|
@@ -386,8 +479,18 @@ type TableColumnProps<T extends Record<string, unknown>, K extends string = keyo
|
|
|
386
479
|
headerClassName?: string;
|
|
387
480
|
render?: (value: K extends keyof T ? T[K] : unknown, row: Row<T>, index: number) => ReactNode;
|
|
388
481
|
};
|
|
482
|
+
/** Declares a multi-row header group wrapping leaf `Table.Column`s. */
|
|
483
|
+
type TableColumnGroupProps = {
|
|
484
|
+
/** Group header label shown in the top header row */
|
|
485
|
+
header: ReactNode;
|
|
486
|
+
children: ReactNode;
|
|
487
|
+
/** Stable group id. Auto-generated when omitted */
|
|
488
|
+
id?: string;
|
|
489
|
+
align?: "left" | "center" | "right";
|
|
490
|
+
headerClassName?: string;
|
|
491
|
+
};
|
|
389
492
|
type TableProps<T extends Record<string, unknown>> = Omit<DataTableProps<T>, "columns"> & {
|
|
390
493
|
children: ReactNode;
|
|
391
494
|
};
|
|
392
495
|
|
|
393
|
-
export { type ColumnFreezeColumnInput as C, DEFAULT_DATA_TABLE_LABELS as D, type PasteMode as P, type RowSelectionMode as R, type
|
|
496
|
+
export { getColumnFreezeEdgeAttr as A, getColumnFreezeStyle as B, type ColumnFreezeColumnInput as C, DEFAULT_DATA_TABLE_LABELS as D, mapSearchResultToVisibleItem as E, mapSearchResultsToVisibleKeys as F, nextSearchIndex as G, nextSearchStride as H, INLINE_SEARCH_MAX_RESULTS as I, previousSearchIndex as J, resolveColumnFreezeSide as K, resolveDataTableLabels as L, type CellEditType as M, type PasteMode as P, type RowSelectionMode as R, type SearchCorpusRow as S, type TableColumnGroupProps 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 TableColumnProps as n, type TableProps as o, buildColumnFreezeOffsets as p, buildFlatSearchCorpus as q, buildSearchMatchKey as r, buildSearchMatchKeys as s, buildTreeSearchCorpus as t, cellValueToSearchText as u, collectAncestorKeysToExpand as v, collectSearchMatchesInRange as w, createSearchRegex as x, escapeSearchRegex as y, formatSearchResultLabel as z };
|