react-glide-table 1.1.4 → 1.1.6
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/LICENSE +21 -0
- package/README.md +38 -3
- package/dist/compound.cjs +515 -128
- package/dist/compound.d.cts +2 -2
- package/dist/compound.d.ts +2 -2
- package/dist/compound.js +519 -132
- package/dist/core.cjs +523 -119
- package/dist/core.d.cts +82 -8
- package/dist/core.d.ts +82 -8
- package/dist/core.js +515 -124
- package/dist/index.cjs +565 -130
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +560 -138
- package/dist/{types-BfthylVR.d.cts → types-DOLnknDe.d.cts} +52 -1
- package/dist/{types-BfthylVR.d.ts → types-DOLnknDe.d.ts} +52 -1
- package/package.json +1 -1
package/dist/core.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as CellEditType, a as DataTableClassNames, R as RowSelectionMode,
|
|
2
|
-
export { D as DEFAULT_DATA_TABLE_LABELS, r as resolveDataTableLabels } from './types-
|
|
1
|
+
import { C as CellEditType, a as DataTableClassNames, R as RowSelectionMode, d as DataTableProps, c as DataTableLabels, b as DataTableCopyActions, P as PasteMode, f as RowsPastePayload } from './types-DOLnknDe.cjs';
|
|
2
|
+
export { D as DEFAULT_DATA_TABLE_LABELS, r as resolveDataTableLabels } from './types-DOLnknDe.cjs';
|
|
3
3
|
import { Row, ColumnDef, Table, Updater, RowSelectionState } from '@tanstack/react-table';
|
|
4
4
|
export { ColumnDef, RowSelectionState } from '@tanstack/react-table';
|
|
5
5
|
import { Virtualizer, VirtualItem } from '@tanstack/react-virtual';
|
|
@@ -55,29 +55,50 @@ type DragState = {
|
|
|
55
55
|
fillAnchor: CellPosition | null;
|
|
56
56
|
fillEnd: CellPosition | null;
|
|
57
57
|
};
|
|
58
|
+
/**
|
|
59
|
+
* Reads per-row heights for a merged cell span from the table body.
|
|
60
|
+
* Expand + merge yields unequal row heights (e.g. parent 25px / child 22px);
|
|
61
|
+
* step borders must use these instead of equal-ratio splits.
|
|
62
|
+
*/
|
|
63
|
+
declare function measureMergedSpanRowHeights(rowIndex: number, rowSpan: number, cellElement?: HTMLElement | null): number[] | undefined;
|
|
58
64
|
declare function getRowIndexInMergedCell(clientY: number, cellElement: HTMLElement, rowIndex: number, rowSpan: number): number;
|
|
59
65
|
declare function isCellInSelection(rowIndex: number, colIndex: number, bounds: CellSelectionBounds | null, rowSpan?: number): boolean;
|
|
60
66
|
declare const CELL_SELECTION_EDGES_CLASS = "cell-selection-edges";
|
|
61
67
|
type CellSelectionEdgeStyle = {
|
|
62
68
|
/** Full-side inset border applied via ::after */
|
|
63
69
|
["--selection-edge-shadows"]?: string;
|
|
64
|
-
/** Partial
|
|
70
|
+
/** Partial borders for merged-cell step (stair) segments */
|
|
65
71
|
["--selection-edge-gradients"]?: string;
|
|
66
72
|
["--selection-edge-sizes"]?: string;
|
|
67
73
|
["--selection-edge-positions"]?: string;
|
|
68
74
|
/** Hide internal horizontal grid lines inside the selection with background color */
|
|
69
75
|
borderBottomColor?: string;
|
|
70
76
|
};
|
|
77
|
+
/**
|
|
78
|
+
* Maps a logical row range inside a merged cell to height ratios / pixels.
|
|
79
|
+
* When `rowHeights` is omitted, falls back to equal row splits.
|
|
80
|
+
*/
|
|
81
|
+
declare function rowRangeToHeightRatios(rowIndex: number, span: number, fromRow: number, toRowExclusive: number, rowHeights?: number[]): {
|
|
82
|
+
offsetRatio: number;
|
|
83
|
+
lengthRatio: number;
|
|
84
|
+
offsetPx?: number;
|
|
85
|
+
lengthPx?: number;
|
|
86
|
+
};
|
|
71
87
|
/**
|
|
72
88
|
* Draws the selection border with ::after (extended -1px at the bottom) plus
|
|
73
89
|
* inset box-shadow / partial gradients so it does not break on the cell's
|
|
74
90
|
* border-bottom.
|
|
75
91
|
*
|
|
92
|
+
* Merged cells that overlap the selection are filled as a whole, so top/bottom
|
|
93
|
+
* edges follow the cell's visual box when it contains the selection start/end.
|
|
94
|
+
* Step (stair) segments use height-weighted ratios when expand makes rows unequal.
|
|
95
|
+
*
|
|
76
96
|
* @param isVisuallySelectedAt Whether a logical cell is visually selected
|
|
77
97
|
* (including adjacent merged cells). Used to suppress internal step borders
|
|
78
98
|
* when multiple columns have rowSpan.
|
|
99
|
+
* @param rowHeights Per-row heights inside this merged span.
|
|
79
100
|
*/
|
|
80
|
-
declare function getCellSelectionEdgeStyle(rowIndex: number, colIndex: number, bounds: CellSelectionBounds | null, rowSpan?: number, isVisuallySelectedAt?: (row: number, col: number) => boolean): CellSelectionEdgeStyle | undefined;
|
|
101
|
+
declare function getCellSelectionEdgeStyle(rowIndex: number, colIndex: number, bounds: CellSelectionBounds | null, rowSpan?: number, isVisuallySelectedAt?: (row: number, col: number) => boolean, rowHeights?: number[]): CellSelectionEdgeStyle | undefined;
|
|
81
102
|
declare function hasCellSelectionEdges(style: CellSelectionEdgeStyle | undefined): boolean;
|
|
82
103
|
|
|
83
104
|
type RowSpanInfo = {
|
|
@@ -112,10 +133,10 @@ type DataTableRowContextValue = {
|
|
|
112
133
|
rowSpan: {
|
|
113
134
|
enableRowSpan: boolean;
|
|
114
135
|
primaryRowSpanKey?: string;
|
|
136
|
+
primaryRowSpanColumnId?: string;
|
|
115
137
|
columnRowSpanMap: ColumnRowSpanMap;
|
|
116
138
|
hoveredRowIndex: number | null;
|
|
117
|
-
|
|
118
|
-
selectedGroupKeys: Set<string>;
|
|
139
|
+
selectedRowIndices: Set<number>;
|
|
119
140
|
onRowHover: (rowIndex: number, rowData: RowData) => void;
|
|
120
141
|
};
|
|
121
142
|
selection: {
|
|
@@ -172,6 +193,7 @@ type UseGlideTableResult<T extends Record<string, unknown>> = {
|
|
|
172
193
|
rowContextValue: DataTableRowContextValue;
|
|
173
194
|
handleToggleSelect: (row: Row<T>) => void;
|
|
174
195
|
clearHover: () => void;
|
|
196
|
+
copySelection: DataTableCopyActions["copySelection"];
|
|
175
197
|
};
|
|
176
198
|
declare function useGlideTable<T extends Record<string, unknown>>(options: UseGlideTableOptions<T>): UseGlideTableResult<T>;
|
|
177
199
|
|
|
@@ -190,24 +212,72 @@ declare function useCellEdit<T extends Record<string, unknown>>({ data, rows, on
|
|
|
190
212
|
cancelEdit: () => void;
|
|
191
213
|
};
|
|
192
214
|
|
|
215
|
+
type ParsedClipboardTSV = {
|
|
216
|
+
values: string[][];
|
|
217
|
+
/**
|
|
218
|
+
* Relative tree depth per row when the TSV looks like subtree-copy indentation
|
|
219
|
+
* (first row unindented, at least one later row with leading empty cells).
|
|
220
|
+
* Otherwise all zeros — leading blanks are preserved as real cell values.
|
|
221
|
+
*/
|
|
222
|
+
depths: number[];
|
|
223
|
+
};
|
|
224
|
+
/** Parse Excel/Sheets-style TSV from the clipboard. Trailing newlines are ignored. */
|
|
225
|
+
declare function parseClipboardTSV(text: string): string[][];
|
|
226
|
+
/**
|
|
227
|
+
* Parse TSV and recover relative tree depth from leading tabs
|
|
228
|
+
* (encoded by subtree copy as leading empty cells).
|
|
229
|
+
*/
|
|
230
|
+
declare function parseClipboardTSVWithDepths(text: string): ParsedClipboardTSV;
|
|
231
|
+
/** Resolve visible column ids starting at `startCol` for `width` columns. */
|
|
232
|
+
declare function resolvePasteColumnIds<T extends Record<string, unknown>>(rows: Row<T>[], startCol: number, width: number): string[];
|
|
233
|
+
declare function buildRowsPastePayload<T extends Record<string, unknown>>(rows: Row<T>[], startRow: number, startCol: number, text: string, mode: PasteMode, endRow?: number): RowsPastePayload | null;
|
|
234
|
+
declare function isEditablePasteTarget(target: EventTarget | null): boolean;
|
|
235
|
+
|
|
236
|
+
type CopySelectionOptions = {
|
|
237
|
+
/** When true, collapsed tree descendants are included. Defaults to false. */
|
|
238
|
+
includeDescendants?: boolean;
|
|
239
|
+
};
|
|
193
240
|
type UseCellSelectionOptions<T extends Record<string, unknown>> = {
|
|
194
241
|
data: T[];
|
|
195
242
|
rows: Row<T>[];
|
|
196
243
|
enabled?: boolean;
|
|
244
|
+
/** Enables Ctrl/Cmd+Shift+C subtree copy. Defaults to true when tree expand is enabled. */
|
|
245
|
+
enableSubtreeCopy?: boolean;
|
|
246
|
+
/** Enables Ctrl/Cmd+Shift+V insert paste. Defaults to true. */
|
|
247
|
+
enableInsertPaste?: boolean;
|
|
197
248
|
onDataChange?: (data: T[]) => void;
|
|
198
249
|
onBatchChange?: (changes: Array<{
|
|
199
250
|
rowId: string;
|
|
200
251
|
columnId: string;
|
|
201
252
|
value: unknown;
|
|
202
253
|
}>) => void;
|
|
254
|
+
onRowsPaste?: (payload: RowsPastePayload) => void;
|
|
203
255
|
};
|
|
204
|
-
declare function useCellSelection<T extends Record<string, unknown>>({ data, rows, enabled, onDataChange, onBatchChange, }: UseCellSelectionOptions<T>): {
|
|
256
|
+
declare function useCellSelection<T extends Record<string, unknown>>({ data, rows, enabled, enableSubtreeCopy, enableInsertPaste, onDataChange, onBatchChange, onRowsPaste, }: UseCellSelectionOptions<T>): {
|
|
205
257
|
dragState: DragState;
|
|
206
258
|
activeSelectionBounds: CellSelectionBounds | null;
|
|
207
259
|
handleCellMouseDown: (rowIndex: number, colIndex: number) => void;
|
|
208
260
|
handleCellMouseEnter: (rowIndex: number, colIndex: number) => void;
|
|
209
261
|
handleFillHandleMouseDown: (rowIndex: number, colIndex: number) => void;
|
|
262
|
+
copySelection: (options?: CopySelectionOptions) => Promise<boolean>;
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
type CopySelectionMode = "visible" | "subtree";
|
|
266
|
+
type CopyRowEntry<T extends Record<string, unknown>> = {
|
|
267
|
+
row: T;
|
|
268
|
+
/** Tree depth relative to the table root (0 = top-level). */
|
|
269
|
+
depth: number;
|
|
210
270
|
};
|
|
271
|
+
declare function flattenSubtreeRows<T extends Record<string, unknown>>(row: T): T[];
|
|
272
|
+
/**
|
|
273
|
+
* Collects copy rows with tree depth so paste can rebuild parent/child nesting.
|
|
274
|
+
* Descendant depth is derived from the walk, not only from `level`.
|
|
275
|
+
*/
|
|
276
|
+
declare function collectCopyRowEntries<T extends Record<string, unknown>>(visibleRows: Row<T>[], bounds: CellSelectionBounds, mode?: CopySelectionMode): CopyRowEntry<T>[];
|
|
277
|
+
declare function collectCopyRows<T extends Record<string, unknown>>(visibleRows: Row<T>[], bounds: CellSelectionBounds, mode?: CopySelectionMode): T[];
|
|
278
|
+
declare function serializeCopyRowsToTSV<T extends Record<string, unknown>>(copyRows: T[], visibleRows: Row<T>[], bounds: CellSelectionBounds, depths?: number[]): string;
|
|
279
|
+
declare function serializeSelectionToTSV<T extends Record<string, unknown>>(visibleRows: Row<T>[], bounds: CellSelectionBounds, mode?: CopySelectionMode): string;
|
|
280
|
+
declare function writeSelectionToClipboard<T extends Record<string, unknown>>(visibleRows: Row<T>[], bounds: CellSelectionBounds, mode?: CopySelectionMode): Promise<boolean>;
|
|
211
281
|
|
|
212
282
|
type CellChange = {
|
|
213
283
|
rowId: string;
|
|
@@ -247,10 +317,14 @@ declare function toggleExpandedRowId(rowId: string, previous: Set<string>): Set<
|
|
|
247
317
|
/**
|
|
248
318
|
* Builds a tree from flat/nested data, then returns only rows visible under expandedRows.
|
|
249
319
|
* When enabled=false, returns data as-is.
|
|
320
|
+
*
|
|
321
|
+
* Flat rows attach to the nearest *preceding* parent with a matching toggle key
|
|
322
|
+
* (so duplicate keys after paste stay under the pasted parent). Parents must appear
|
|
323
|
+
* before their children; a child whose parent is later in the array becomes a root.
|
|
250
324
|
*/
|
|
251
325
|
declare const useConvertTreeData: <T extends Record<string, unknown>>({ data, enabled, toggleField, childField, flattenField, qtyField, preventExpand, startIndex, expandedRows, onExpandedRowsChange, }: UseConvertTreeDataParams<T>) => T[];
|
|
252
326
|
|
|
253
327
|
declare function resolveRowSelection(mode: RowSelectionMode, controlledSelection: RowSelectionState | undefined, internalSelection: RowSelectionState): RowSelectionState;
|
|
254
328
|
declare function applySelectionUpdater(mode: RowSelectionMode, updater: Updater<RowSelectionState>, previous: RowSelectionState): RowSelectionState;
|
|
255
329
|
|
|
256
|
-
export { CELL_SELECTION_EDGES_CLASS, type CellSelectionBounds, type ColumnRowSpanMap, DEFAULT_TREE_CHILDREN_FIELD, DEFAULT_TREE_ID_FIELD, DEFAULT_TREE_PARENT_ID_FIELD, DEFAULT_TREE_QTY_FIELD, DataTableLabels, DataTableProps, type DragState, type EditingCell, RowSelectionMode, type RowSpanInfo, type TreeRow, type UseConvertTreeDataParams, type UseGlideTableOptions, type UseGlideTableResult, applyCellEdit, applyFillData, applySelectionUpdater, buildColumnRowSpanMap, canExpandRow, collectFillChanges, collectRowSpanColumns, getCellEditDraftValue, getCellSelectionEdgeStyle, getColumnEditType, getRowIndexInMergedCell, hasCellSelectionEdges, isCellInSelection, isColumnEditable, parseCellEditValue, resolveRowSelection, resolveRowSpanAt, toggleExpandedRowId, useCellEdit, useCellSelection, useConvertTreeData, useGlideTable };
|
|
330
|
+
export { CELL_SELECTION_EDGES_CLASS, type CellSelectionBounds, type ColumnRowSpanMap, type CopyRowEntry, type CopySelectionMode, DEFAULT_TREE_CHILDREN_FIELD, DEFAULT_TREE_ID_FIELD, DEFAULT_TREE_PARENT_ID_FIELD, DEFAULT_TREE_QTY_FIELD, DataTableCopyActions, DataTableLabels, DataTableProps, type DragState, type EditingCell, PasteMode, RowSelectionMode, type RowSpanInfo, RowsPastePayload, type TreeRow, type UseConvertTreeDataParams, type UseGlideTableOptions, type UseGlideTableResult, applyCellEdit, applyFillData, applySelectionUpdater, buildColumnRowSpanMap, buildRowsPastePayload, canExpandRow, collectCopyRowEntries, collectCopyRows, collectFillChanges, collectRowSpanColumns, flattenSubtreeRows, getCellEditDraftValue, getCellSelectionEdgeStyle, getColumnEditType, getRowIndexInMergedCell, hasCellSelectionEdges, isCellInSelection, isColumnEditable, isEditablePasteTarget, measureMergedSpanRowHeights, parseCellEditValue, parseClipboardTSV, parseClipboardTSVWithDepths, resolvePasteColumnIds, resolveRowSelection, resolveRowSpanAt, rowRangeToHeightRatios, serializeCopyRowsToTSV, serializeSelectionToTSV, toggleExpandedRowId, useCellEdit, useCellSelection, useConvertTreeData, useGlideTable, writeSelectionToClipboard };
|
package/dist/core.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as CellEditType, a as DataTableClassNames, R as RowSelectionMode,
|
|
2
|
-
export { D as DEFAULT_DATA_TABLE_LABELS, r as resolveDataTableLabels } from './types-
|
|
1
|
+
import { C as CellEditType, a as DataTableClassNames, R as RowSelectionMode, d as DataTableProps, c as DataTableLabels, b as DataTableCopyActions, P as PasteMode, f as RowsPastePayload } from './types-DOLnknDe.js';
|
|
2
|
+
export { D as DEFAULT_DATA_TABLE_LABELS, r as resolveDataTableLabels } from './types-DOLnknDe.js';
|
|
3
3
|
import { Row, ColumnDef, Table, Updater, RowSelectionState } from '@tanstack/react-table';
|
|
4
4
|
export { ColumnDef, RowSelectionState } from '@tanstack/react-table';
|
|
5
5
|
import { Virtualizer, VirtualItem } from '@tanstack/react-virtual';
|
|
@@ -55,29 +55,50 @@ type DragState = {
|
|
|
55
55
|
fillAnchor: CellPosition | null;
|
|
56
56
|
fillEnd: CellPosition | null;
|
|
57
57
|
};
|
|
58
|
+
/**
|
|
59
|
+
* Reads per-row heights for a merged cell span from the table body.
|
|
60
|
+
* Expand + merge yields unequal row heights (e.g. parent 25px / child 22px);
|
|
61
|
+
* step borders must use these instead of equal-ratio splits.
|
|
62
|
+
*/
|
|
63
|
+
declare function measureMergedSpanRowHeights(rowIndex: number, rowSpan: number, cellElement?: HTMLElement | null): number[] | undefined;
|
|
58
64
|
declare function getRowIndexInMergedCell(clientY: number, cellElement: HTMLElement, rowIndex: number, rowSpan: number): number;
|
|
59
65
|
declare function isCellInSelection(rowIndex: number, colIndex: number, bounds: CellSelectionBounds | null, rowSpan?: number): boolean;
|
|
60
66
|
declare const CELL_SELECTION_EDGES_CLASS = "cell-selection-edges";
|
|
61
67
|
type CellSelectionEdgeStyle = {
|
|
62
68
|
/** Full-side inset border applied via ::after */
|
|
63
69
|
["--selection-edge-shadows"]?: string;
|
|
64
|
-
/** Partial
|
|
70
|
+
/** Partial borders for merged-cell step (stair) segments */
|
|
65
71
|
["--selection-edge-gradients"]?: string;
|
|
66
72
|
["--selection-edge-sizes"]?: string;
|
|
67
73
|
["--selection-edge-positions"]?: string;
|
|
68
74
|
/** Hide internal horizontal grid lines inside the selection with background color */
|
|
69
75
|
borderBottomColor?: string;
|
|
70
76
|
};
|
|
77
|
+
/**
|
|
78
|
+
* Maps a logical row range inside a merged cell to height ratios / pixels.
|
|
79
|
+
* When `rowHeights` is omitted, falls back to equal row splits.
|
|
80
|
+
*/
|
|
81
|
+
declare function rowRangeToHeightRatios(rowIndex: number, span: number, fromRow: number, toRowExclusive: number, rowHeights?: number[]): {
|
|
82
|
+
offsetRatio: number;
|
|
83
|
+
lengthRatio: number;
|
|
84
|
+
offsetPx?: number;
|
|
85
|
+
lengthPx?: number;
|
|
86
|
+
};
|
|
71
87
|
/**
|
|
72
88
|
* Draws the selection border with ::after (extended -1px at the bottom) plus
|
|
73
89
|
* inset box-shadow / partial gradients so it does not break on the cell's
|
|
74
90
|
* border-bottom.
|
|
75
91
|
*
|
|
92
|
+
* Merged cells that overlap the selection are filled as a whole, so top/bottom
|
|
93
|
+
* edges follow the cell's visual box when it contains the selection start/end.
|
|
94
|
+
* Step (stair) segments use height-weighted ratios when expand makes rows unequal.
|
|
95
|
+
*
|
|
76
96
|
* @param isVisuallySelectedAt Whether a logical cell is visually selected
|
|
77
97
|
* (including adjacent merged cells). Used to suppress internal step borders
|
|
78
98
|
* when multiple columns have rowSpan.
|
|
99
|
+
* @param rowHeights Per-row heights inside this merged span.
|
|
79
100
|
*/
|
|
80
|
-
declare function getCellSelectionEdgeStyle(rowIndex: number, colIndex: number, bounds: CellSelectionBounds | null, rowSpan?: number, isVisuallySelectedAt?: (row: number, col: number) => boolean): CellSelectionEdgeStyle | undefined;
|
|
101
|
+
declare function getCellSelectionEdgeStyle(rowIndex: number, colIndex: number, bounds: CellSelectionBounds | null, rowSpan?: number, isVisuallySelectedAt?: (row: number, col: number) => boolean, rowHeights?: number[]): CellSelectionEdgeStyle | undefined;
|
|
81
102
|
declare function hasCellSelectionEdges(style: CellSelectionEdgeStyle | undefined): boolean;
|
|
82
103
|
|
|
83
104
|
type RowSpanInfo = {
|
|
@@ -112,10 +133,10 @@ type DataTableRowContextValue = {
|
|
|
112
133
|
rowSpan: {
|
|
113
134
|
enableRowSpan: boolean;
|
|
114
135
|
primaryRowSpanKey?: string;
|
|
136
|
+
primaryRowSpanColumnId?: string;
|
|
115
137
|
columnRowSpanMap: ColumnRowSpanMap;
|
|
116
138
|
hoveredRowIndex: number | null;
|
|
117
|
-
|
|
118
|
-
selectedGroupKeys: Set<string>;
|
|
139
|
+
selectedRowIndices: Set<number>;
|
|
119
140
|
onRowHover: (rowIndex: number, rowData: RowData) => void;
|
|
120
141
|
};
|
|
121
142
|
selection: {
|
|
@@ -172,6 +193,7 @@ type UseGlideTableResult<T extends Record<string, unknown>> = {
|
|
|
172
193
|
rowContextValue: DataTableRowContextValue;
|
|
173
194
|
handleToggleSelect: (row: Row<T>) => void;
|
|
174
195
|
clearHover: () => void;
|
|
196
|
+
copySelection: DataTableCopyActions["copySelection"];
|
|
175
197
|
};
|
|
176
198
|
declare function useGlideTable<T extends Record<string, unknown>>(options: UseGlideTableOptions<T>): UseGlideTableResult<T>;
|
|
177
199
|
|
|
@@ -190,24 +212,72 @@ declare function useCellEdit<T extends Record<string, unknown>>({ data, rows, on
|
|
|
190
212
|
cancelEdit: () => void;
|
|
191
213
|
};
|
|
192
214
|
|
|
215
|
+
type ParsedClipboardTSV = {
|
|
216
|
+
values: string[][];
|
|
217
|
+
/**
|
|
218
|
+
* Relative tree depth per row when the TSV looks like subtree-copy indentation
|
|
219
|
+
* (first row unindented, at least one later row with leading empty cells).
|
|
220
|
+
* Otherwise all zeros — leading blanks are preserved as real cell values.
|
|
221
|
+
*/
|
|
222
|
+
depths: number[];
|
|
223
|
+
};
|
|
224
|
+
/** Parse Excel/Sheets-style TSV from the clipboard. Trailing newlines are ignored. */
|
|
225
|
+
declare function parseClipboardTSV(text: string): string[][];
|
|
226
|
+
/**
|
|
227
|
+
* Parse TSV and recover relative tree depth from leading tabs
|
|
228
|
+
* (encoded by subtree copy as leading empty cells).
|
|
229
|
+
*/
|
|
230
|
+
declare function parseClipboardTSVWithDepths(text: string): ParsedClipboardTSV;
|
|
231
|
+
/** Resolve visible column ids starting at `startCol` for `width` columns. */
|
|
232
|
+
declare function resolvePasteColumnIds<T extends Record<string, unknown>>(rows: Row<T>[], startCol: number, width: number): string[];
|
|
233
|
+
declare function buildRowsPastePayload<T extends Record<string, unknown>>(rows: Row<T>[], startRow: number, startCol: number, text: string, mode: PasteMode, endRow?: number): RowsPastePayload | null;
|
|
234
|
+
declare function isEditablePasteTarget(target: EventTarget | null): boolean;
|
|
235
|
+
|
|
236
|
+
type CopySelectionOptions = {
|
|
237
|
+
/** When true, collapsed tree descendants are included. Defaults to false. */
|
|
238
|
+
includeDescendants?: boolean;
|
|
239
|
+
};
|
|
193
240
|
type UseCellSelectionOptions<T extends Record<string, unknown>> = {
|
|
194
241
|
data: T[];
|
|
195
242
|
rows: Row<T>[];
|
|
196
243
|
enabled?: boolean;
|
|
244
|
+
/** Enables Ctrl/Cmd+Shift+C subtree copy. Defaults to true when tree expand is enabled. */
|
|
245
|
+
enableSubtreeCopy?: boolean;
|
|
246
|
+
/** Enables Ctrl/Cmd+Shift+V insert paste. Defaults to true. */
|
|
247
|
+
enableInsertPaste?: boolean;
|
|
197
248
|
onDataChange?: (data: T[]) => void;
|
|
198
249
|
onBatchChange?: (changes: Array<{
|
|
199
250
|
rowId: string;
|
|
200
251
|
columnId: string;
|
|
201
252
|
value: unknown;
|
|
202
253
|
}>) => void;
|
|
254
|
+
onRowsPaste?: (payload: RowsPastePayload) => void;
|
|
203
255
|
};
|
|
204
|
-
declare function useCellSelection<T extends Record<string, unknown>>({ data, rows, enabled, onDataChange, onBatchChange, }: UseCellSelectionOptions<T>): {
|
|
256
|
+
declare function useCellSelection<T extends Record<string, unknown>>({ data, rows, enabled, enableSubtreeCopy, enableInsertPaste, onDataChange, onBatchChange, onRowsPaste, }: UseCellSelectionOptions<T>): {
|
|
205
257
|
dragState: DragState;
|
|
206
258
|
activeSelectionBounds: CellSelectionBounds | null;
|
|
207
259
|
handleCellMouseDown: (rowIndex: number, colIndex: number) => void;
|
|
208
260
|
handleCellMouseEnter: (rowIndex: number, colIndex: number) => void;
|
|
209
261
|
handleFillHandleMouseDown: (rowIndex: number, colIndex: number) => void;
|
|
262
|
+
copySelection: (options?: CopySelectionOptions) => Promise<boolean>;
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
type CopySelectionMode = "visible" | "subtree";
|
|
266
|
+
type CopyRowEntry<T extends Record<string, unknown>> = {
|
|
267
|
+
row: T;
|
|
268
|
+
/** Tree depth relative to the table root (0 = top-level). */
|
|
269
|
+
depth: number;
|
|
210
270
|
};
|
|
271
|
+
declare function flattenSubtreeRows<T extends Record<string, unknown>>(row: T): T[];
|
|
272
|
+
/**
|
|
273
|
+
* Collects copy rows with tree depth so paste can rebuild parent/child nesting.
|
|
274
|
+
* Descendant depth is derived from the walk, not only from `level`.
|
|
275
|
+
*/
|
|
276
|
+
declare function collectCopyRowEntries<T extends Record<string, unknown>>(visibleRows: Row<T>[], bounds: CellSelectionBounds, mode?: CopySelectionMode): CopyRowEntry<T>[];
|
|
277
|
+
declare function collectCopyRows<T extends Record<string, unknown>>(visibleRows: Row<T>[], bounds: CellSelectionBounds, mode?: CopySelectionMode): T[];
|
|
278
|
+
declare function serializeCopyRowsToTSV<T extends Record<string, unknown>>(copyRows: T[], visibleRows: Row<T>[], bounds: CellSelectionBounds, depths?: number[]): string;
|
|
279
|
+
declare function serializeSelectionToTSV<T extends Record<string, unknown>>(visibleRows: Row<T>[], bounds: CellSelectionBounds, mode?: CopySelectionMode): string;
|
|
280
|
+
declare function writeSelectionToClipboard<T extends Record<string, unknown>>(visibleRows: Row<T>[], bounds: CellSelectionBounds, mode?: CopySelectionMode): Promise<boolean>;
|
|
211
281
|
|
|
212
282
|
type CellChange = {
|
|
213
283
|
rowId: string;
|
|
@@ -247,10 +317,14 @@ declare function toggleExpandedRowId(rowId: string, previous: Set<string>): Set<
|
|
|
247
317
|
/**
|
|
248
318
|
* Builds a tree from flat/nested data, then returns only rows visible under expandedRows.
|
|
249
319
|
* When enabled=false, returns data as-is.
|
|
320
|
+
*
|
|
321
|
+
* Flat rows attach to the nearest *preceding* parent with a matching toggle key
|
|
322
|
+
* (so duplicate keys after paste stay under the pasted parent). Parents must appear
|
|
323
|
+
* before their children; a child whose parent is later in the array becomes a root.
|
|
250
324
|
*/
|
|
251
325
|
declare const useConvertTreeData: <T extends Record<string, unknown>>({ data, enabled, toggleField, childField, flattenField, qtyField, preventExpand, startIndex, expandedRows, onExpandedRowsChange, }: UseConvertTreeDataParams<T>) => T[];
|
|
252
326
|
|
|
253
327
|
declare function resolveRowSelection(mode: RowSelectionMode, controlledSelection: RowSelectionState | undefined, internalSelection: RowSelectionState): RowSelectionState;
|
|
254
328
|
declare function applySelectionUpdater(mode: RowSelectionMode, updater: Updater<RowSelectionState>, previous: RowSelectionState): RowSelectionState;
|
|
255
329
|
|
|
256
|
-
export { CELL_SELECTION_EDGES_CLASS, type CellSelectionBounds, type ColumnRowSpanMap, DEFAULT_TREE_CHILDREN_FIELD, DEFAULT_TREE_ID_FIELD, DEFAULT_TREE_PARENT_ID_FIELD, DEFAULT_TREE_QTY_FIELD, DataTableLabels, DataTableProps, type DragState, type EditingCell, RowSelectionMode, type RowSpanInfo, type TreeRow, type UseConvertTreeDataParams, type UseGlideTableOptions, type UseGlideTableResult, applyCellEdit, applyFillData, applySelectionUpdater, buildColumnRowSpanMap, canExpandRow, collectFillChanges, collectRowSpanColumns, getCellEditDraftValue, getCellSelectionEdgeStyle, getColumnEditType, getRowIndexInMergedCell, hasCellSelectionEdges, isCellInSelection, isColumnEditable, parseCellEditValue, resolveRowSelection, resolveRowSpanAt, toggleExpandedRowId, useCellEdit, useCellSelection, useConvertTreeData, useGlideTable };
|
|
330
|
+
export { CELL_SELECTION_EDGES_CLASS, type CellSelectionBounds, type ColumnRowSpanMap, type CopyRowEntry, type CopySelectionMode, DEFAULT_TREE_CHILDREN_FIELD, DEFAULT_TREE_ID_FIELD, DEFAULT_TREE_PARENT_ID_FIELD, DEFAULT_TREE_QTY_FIELD, DataTableCopyActions, DataTableLabels, DataTableProps, type DragState, type EditingCell, PasteMode, RowSelectionMode, type RowSpanInfo, RowsPastePayload, type TreeRow, type UseConvertTreeDataParams, type UseGlideTableOptions, type UseGlideTableResult, applyCellEdit, applyFillData, applySelectionUpdater, buildColumnRowSpanMap, buildRowsPastePayload, canExpandRow, collectCopyRowEntries, collectCopyRows, collectFillChanges, collectRowSpanColumns, flattenSubtreeRows, getCellEditDraftValue, getCellSelectionEdgeStyle, getColumnEditType, getRowIndexInMergedCell, hasCellSelectionEdges, isCellInSelection, isColumnEditable, isEditablePasteTarget, measureMergedSpanRowHeights, parseCellEditValue, parseClipboardTSV, parseClipboardTSVWithDepths, resolvePasteColumnIds, resolveRowSelection, resolveRowSpanAt, rowRangeToHeightRatios, serializeCopyRowsToTSV, serializeSelectionToTSV, toggleExpandedRowId, useCellEdit, useCellSelection, useConvertTreeData, useGlideTable, writeSelectionToClipboard };
|