react-glide-table 1.4.0 → 1.6.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.
@@ -48,6 +48,67 @@ declare function getColumnFreezeStyle(offset: ColumnFreezeOffset | undefined, op
48
48
  isHeader?: boolean;
49
49
  }): CSSProperties | undefined;
50
50
 
51
+ /** Cell match as `[colIndex, rowIndex]` — same order as Glide Data Grid `Item`.
52
+ * For tree tables, `rowIndex` is the search-corpus index (includes collapsed rows).
53
+ */
54
+ type SearchResultItem = readonly [colIndex: number, rowIndex: number];
55
+ type SearchStatus = {
56
+ rowsSearched: number;
57
+ results: number;
58
+ selectedIndex: number;
59
+ };
60
+ /** One searchable row, including collapsed tree descendants. */
61
+ type SearchCorpusRow<T extends Record<string, unknown> = Record<string, unknown>> = {
62
+ /** Stable row id used to resolve the visible index after expand */
63
+ id: string;
64
+ data: T;
65
+ /**
66
+ * Toggle-field keys of ancestors that must be in `expandedRows`
67
+ * for this row to become visible.
68
+ */
69
+ ancestorToggleKeys: string[];
70
+ };
71
+ declare const INLINE_SEARCH_MAX_RESULTS = 1000;
72
+ declare function escapeSearchRegex(value: string): string;
73
+ declare function createSearchRegex(query: string): RegExp | null;
74
+ declare function cellValueToSearchText(value: unknown): string | undefined;
75
+ declare function formatSearchResultLabel(status: SearchStatus): string;
76
+ declare function nextSearchIndex(selectedIndex: number, results: number): number;
77
+ declare function previousSearchIndex(selectedIndex: number, results: number): number;
78
+ declare function buildSearchMatchKey(colIndex: number, rowIndex: number): string;
79
+ declare function buildSearchMatchKeys(results: readonly SearchResultItem[]): Set<string>;
80
+ /**
81
+ * Scan a contiguous row window for matches.
82
+ * Returns newly found items (appended in row-major, col-major order).
83
+ */
84
+ declare function collectSearchMatchesInRange(options: {
85
+ query: string;
86
+ startRow: number;
87
+ rowCount: number;
88
+ columnCount: number;
89
+ getCellValue: (rowIndex: number, colIndex: number) => unknown;
90
+ maxResults?: number;
91
+ }): SearchResultItem[];
92
+ declare function nextSearchStride(currentStride: number, elapsedMs: number, targetMs?: number): number;
93
+ /**
94
+ * Flat (non-tree) search corpus — one entry per visible row.
95
+ */
96
+ declare function buildFlatSearchCorpus<T extends Record<string, unknown>>(rows: T[], getRowId: (row: T, index: number) => string): SearchCorpusRow<T>[];
97
+ /**
98
+ * Build a search corpus that includes collapsed tree descendants.
99
+ * Starts from root rows (`level === 0`) and walks each node's `children`.
100
+ */
101
+ declare function buildTreeSearchCorpus<T extends Record<string, unknown>>(visibleRows: T[], options: {
102
+ toggleField: string;
103
+ getRowId: (row: T, index: number) => string;
104
+ }): SearchCorpusRow<T>[];
105
+ /**
106
+ * Map corpus-indexed search results onto currently visible row indices for highlighting.
107
+ */
108
+ declare function mapSearchResultsToVisibleKeys(results: readonly SearchResultItem[], corpus: readonly SearchCorpusRow[], visibleRowIndexById: Map<string, number>): Set<string>;
109
+ declare function mapSearchResultToVisibleItem(item: SearchResultItem, corpus: readonly SearchCorpusRow[], visibleRowIndexById: Map<string, number>): SearchResultItem | null;
110
+ declare function collectAncestorKeysToExpand(corpusRow: SearchCorpusRow, expandedRows: Set<string>): string[];
111
+
51
112
  type DataTableLabels = {
52
113
  empty: string;
53
114
  loading: string;
@@ -56,6 +117,12 @@ type DataTableLabels = {
56
117
  collapseRow: string;
57
118
  /** Accessible label for the column resize handle */
58
119
  resizeColumn: string;
120
+ /** Built-in find-in-page search overlay */
121
+ searchPlaceholder: string;
122
+ searchResultHint: string;
123
+ searchPrevious: string;
124
+ searchNext: string;
125
+ searchClose: string;
59
126
  };
60
127
  /** Default copy. Override via the `labels` option. */
61
128
  declare const DEFAULT_DATA_TABLE_LABELS: DataTableLabels;
@@ -254,6 +321,25 @@ type DataTableProps<T extends Record<string, unknown>> = {
254
321
  * Does not reorder columns; offsets stack so frozen cells do not overlap.
255
322
  */
256
323
  enableColumnFreeze?: boolean;
324
+ /**
325
+ * Enable Glide-style built-in find-in-page search (Ctrl/Cmd+F).
326
+ * Highlights matching cells; Enter / buttons navigate without filtering rows.
327
+ * Defaults to false.
328
+ */
329
+ enableInlineSearch?: boolean;
330
+ /** Controlled search overlay visibility. When omitted, Ctrl/Cmd+F toggles internally. */
331
+ showSearch?: boolean;
332
+ /** Controlled search query string. */
333
+ searchValue?: string;
334
+ onSearchValueChange?: (value: string) => void;
335
+ /**
336
+ * Emitted when the overlay close control is used (X / Escape / Ctrl+F in the box).
337
+ * Providing this shows the close button. For controlled `showSearch`, set it false here.
338
+ */
339
+ onSearchClose?: () => void;
340
+ /** Override the internal match list (`[colIndex, rowIndex]`). */
341
+ searchResults?: readonly SearchResultItem[];
342
+ onSearchResultsChanged?: (results: readonly SearchResultItem[], navIndex: number) => void;
257
343
  /**
258
344
  * Optional UI part replacements for the unstyled DataTable renderer.
259
345
  * Use with `createTable` / `Table.Column`, or pass columns directly to `DataTable`.
@@ -295,6 +381,12 @@ type DataTableClassNames = {
295
381
  expandToggle?: string;
296
382
  expandToggleIcon?: string;
297
383
  fillHandle?: string;
384
+ /** Built-in search overlay root */
385
+ search?: string;
386
+ searchInput?: string;
387
+ searchButton?: string;
388
+ searchStatus?: string;
389
+ searchProgress?: string;
298
390
  };
299
391
  type DataTableToolbarSlotProps = {
300
392
  filteredCount?: number;
@@ -390,4 +482,4 @@ type TableProps<T extends Record<string, unknown>> = Omit<DataTableProps<T>, "co
390
482
  children: ReactNode;
391
483
  };
392
484
 
393
- export { type ColumnFreezeColumnInput as C, DEFAULT_DATA_TABLE_LABELS as D, type PasteMode as P, type RowSelectionMode as R, 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 TableProps as l, buildColumnFreezeOffsets as m, getColumnFreezeEdgeAttr as n, getColumnFreezeStyle as o, resolveDataTableLabels as p, type CellEditType as q, resolveColumnFreezeSide as r };
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 };
@@ -48,6 +48,67 @@ declare function getColumnFreezeStyle(offset: ColumnFreezeOffset | undefined, op
48
48
  isHeader?: boolean;
49
49
  }): CSSProperties | undefined;
50
50
 
51
+ /** Cell match as `[colIndex, rowIndex]` — same order as Glide Data Grid `Item`.
52
+ * For tree tables, `rowIndex` is the search-corpus index (includes collapsed rows).
53
+ */
54
+ type SearchResultItem = readonly [colIndex: number, rowIndex: number];
55
+ type SearchStatus = {
56
+ rowsSearched: number;
57
+ results: number;
58
+ selectedIndex: number;
59
+ };
60
+ /** One searchable row, including collapsed tree descendants. */
61
+ type SearchCorpusRow<T extends Record<string, unknown> = Record<string, unknown>> = {
62
+ /** Stable row id used to resolve the visible index after expand */
63
+ id: string;
64
+ data: T;
65
+ /**
66
+ * Toggle-field keys of ancestors that must be in `expandedRows`
67
+ * for this row to become visible.
68
+ */
69
+ ancestorToggleKeys: string[];
70
+ };
71
+ declare const INLINE_SEARCH_MAX_RESULTS = 1000;
72
+ declare function escapeSearchRegex(value: string): string;
73
+ declare function createSearchRegex(query: string): RegExp | null;
74
+ declare function cellValueToSearchText(value: unknown): string | undefined;
75
+ declare function formatSearchResultLabel(status: SearchStatus): string;
76
+ declare function nextSearchIndex(selectedIndex: number, results: number): number;
77
+ declare function previousSearchIndex(selectedIndex: number, results: number): number;
78
+ declare function buildSearchMatchKey(colIndex: number, rowIndex: number): string;
79
+ declare function buildSearchMatchKeys(results: readonly SearchResultItem[]): Set<string>;
80
+ /**
81
+ * Scan a contiguous row window for matches.
82
+ * Returns newly found items (appended in row-major, col-major order).
83
+ */
84
+ declare function collectSearchMatchesInRange(options: {
85
+ query: string;
86
+ startRow: number;
87
+ rowCount: number;
88
+ columnCount: number;
89
+ getCellValue: (rowIndex: number, colIndex: number) => unknown;
90
+ maxResults?: number;
91
+ }): SearchResultItem[];
92
+ declare function nextSearchStride(currentStride: number, elapsedMs: number, targetMs?: number): number;
93
+ /**
94
+ * Flat (non-tree) search corpus — one entry per visible row.
95
+ */
96
+ declare function buildFlatSearchCorpus<T extends Record<string, unknown>>(rows: T[], getRowId: (row: T, index: number) => string): SearchCorpusRow<T>[];
97
+ /**
98
+ * Build a search corpus that includes collapsed tree descendants.
99
+ * Starts from root rows (`level === 0`) and walks each node's `children`.
100
+ */
101
+ declare function buildTreeSearchCorpus<T extends Record<string, unknown>>(visibleRows: T[], options: {
102
+ toggleField: string;
103
+ getRowId: (row: T, index: number) => string;
104
+ }): SearchCorpusRow<T>[];
105
+ /**
106
+ * Map corpus-indexed search results onto currently visible row indices for highlighting.
107
+ */
108
+ declare function mapSearchResultsToVisibleKeys(results: readonly SearchResultItem[], corpus: readonly SearchCorpusRow[], visibleRowIndexById: Map<string, number>): Set<string>;
109
+ declare function mapSearchResultToVisibleItem(item: SearchResultItem, corpus: readonly SearchCorpusRow[], visibleRowIndexById: Map<string, number>): SearchResultItem | null;
110
+ declare function collectAncestorKeysToExpand(corpusRow: SearchCorpusRow, expandedRows: Set<string>): string[];
111
+
51
112
  type DataTableLabels = {
52
113
  empty: string;
53
114
  loading: string;
@@ -56,6 +117,12 @@ type DataTableLabels = {
56
117
  collapseRow: string;
57
118
  /** Accessible label for the column resize handle */
58
119
  resizeColumn: string;
120
+ /** Built-in find-in-page search overlay */
121
+ searchPlaceholder: string;
122
+ searchResultHint: string;
123
+ searchPrevious: string;
124
+ searchNext: string;
125
+ searchClose: string;
59
126
  };
60
127
  /** Default copy. Override via the `labels` option. */
61
128
  declare const DEFAULT_DATA_TABLE_LABELS: DataTableLabels;
@@ -254,6 +321,25 @@ type DataTableProps<T extends Record<string, unknown>> = {
254
321
  * Does not reorder columns; offsets stack so frozen cells do not overlap.
255
322
  */
256
323
  enableColumnFreeze?: boolean;
324
+ /**
325
+ * Enable Glide-style built-in find-in-page search (Ctrl/Cmd+F).
326
+ * Highlights matching cells; Enter / buttons navigate without filtering rows.
327
+ * Defaults to false.
328
+ */
329
+ enableInlineSearch?: boolean;
330
+ /** Controlled search overlay visibility. When omitted, Ctrl/Cmd+F toggles internally. */
331
+ showSearch?: boolean;
332
+ /** Controlled search query string. */
333
+ searchValue?: string;
334
+ onSearchValueChange?: (value: string) => void;
335
+ /**
336
+ * Emitted when the overlay close control is used (X / Escape / Ctrl+F in the box).
337
+ * Providing this shows the close button. For controlled `showSearch`, set it false here.
338
+ */
339
+ onSearchClose?: () => void;
340
+ /** Override the internal match list (`[colIndex, rowIndex]`). */
341
+ searchResults?: readonly SearchResultItem[];
342
+ onSearchResultsChanged?: (results: readonly SearchResultItem[], navIndex: number) => void;
257
343
  /**
258
344
  * Optional UI part replacements for the unstyled DataTable renderer.
259
345
  * Use with `createTable` / `Table.Column`, or pass columns directly to `DataTable`.
@@ -295,6 +381,12 @@ type DataTableClassNames = {
295
381
  expandToggle?: string;
296
382
  expandToggleIcon?: string;
297
383
  fillHandle?: string;
384
+ /** Built-in search overlay root */
385
+ search?: string;
386
+ searchInput?: string;
387
+ searchButton?: string;
388
+ searchStatus?: string;
389
+ searchProgress?: string;
298
390
  };
299
391
  type DataTableToolbarSlotProps = {
300
392
  filteredCount?: number;
@@ -390,4 +482,4 @@ type TableProps<T extends Record<string, unknown>> = Omit<DataTableProps<T>, "co
390
482
  children: ReactNode;
391
483
  };
392
484
 
393
- export { type ColumnFreezeColumnInput as C, DEFAULT_DATA_TABLE_LABELS as D, type PasteMode as P, type RowSelectionMode as R, 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 TableProps as l, buildColumnFreezeOffsets as m, getColumnFreezeEdgeAttr as n, getColumnFreezeStyle as o, resolveDataTableLabels as p, type CellEditType as q, resolveColumnFreezeSide as r };
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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-glide-table",
3
- "version": "1.4.0",
3
+ "version": "1.6.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/zpxlffjrm/react-glide-table.git"