react-glide-table 1.1.1 → 1.1.3

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/dist/core.cjs ADDED
@@ -0,0 +1,1198 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/core/index.ts
21
+ var core_exports = {};
22
+ __export(core_exports, {
23
+ CELL_SELECTION_EDGES_CLASS: () => CELL_SELECTION_EDGES_CLASS,
24
+ DEFAULT_DATA_TABLE_LABELS: () => DEFAULT_DATA_TABLE_LABELS,
25
+ DEFAULT_TREE_CHILDREN_FIELD: () => DEFAULT_TREE_CHILDREN_FIELD,
26
+ DEFAULT_TREE_ID_FIELD: () => DEFAULT_TREE_ID_FIELD,
27
+ DEFAULT_TREE_PARENT_ID_FIELD: () => DEFAULT_TREE_PARENT_ID_FIELD,
28
+ DEFAULT_TREE_QTY_FIELD: () => DEFAULT_TREE_QTY_FIELD,
29
+ applyCellEdit: () => applyCellEdit,
30
+ applyFillData: () => applyFillData,
31
+ applySelectionUpdater: () => applySelectionUpdater,
32
+ buildColumnRowSpanMap: () => buildColumnRowSpanMap,
33
+ canExpandRow: () => canExpandRow,
34
+ collectFillChanges: () => collectFillChanges,
35
+ collectRowSpanColumns: () => collectRowSpanColumns,
36
+ getCellEditDraftValue: () => getCellEditDraftValue,
37
+ getCellSelectionEdgeStyle: () => getCellSelectionEdgeStyle,
38
+ getColumnEditType: () => getColumnEditType,
39
+ getRowIndexInMergedCell: () => getRowIndexInMergedCell,
40
+ hasCellSelectionEdges: () => hasCellSelectionEdges,
41
+ isCellInSelection: () => isCellInSelection,
42
+ isColumnEditable: () => isColumnEditable,
43
+ parseCellEditValue: () => parseCellEditValue,
44
+ resolveDataTableLabels: () => resolveDataTableLabels,
45
+ resolveRowSelection: () => resolveRowSelection,
46
+ resolveRowSpanAt: () => resolveRowSpanAt,
47
+ toggleExpandedRowId: () => toggleExpandedRowId,
48
+ useCellEdit: () => useCellEdit,
49
+ useCellSelection: () => useCellSelection,
50
+ useConvertTreeData: () => useConvertTreeData,
51
+ useGlideTable: () => useGlideTable
52
+ });
53
+ module.exports = __toCommonJS(core_exports);
54
+
55
+ // src/core/labels.ts
56
+ var DEFAULT_DATA_TABLE_LABELS = {
57
+ empty: "No data",
58
+ loading: "Loading...",
59
+ selection: (selectedCount) => selectedCount > 0 ? `\u2713 ${selectedCount} selected` : null,
60
+ expandRow: "Expand row",
61
+ collapseRow: "Collapse row"
62
+ };
63
+ function resolveDataTableLabels(partial) {
64
+ return {
65
+ ...DEFAULT_DATA_TABLE_LABELS,
66
+ ...partial
67
+ };
68
+ }
69
+
70
+ // src/core/treeDefaults.ts
71
+ var DEFAULT_TREE_ID_FIELD = "id";
72
+ var DEFAULT_TREE_PARENT_ID_FIELD = "parentId";
73
+ var DEFAULT_TREE_CHILDREN_FIELD = "children";
74
+ var DEFAULT_TREE_QTY_FIELD = "qty";
75
+
76
+ // src/core/useGlideTable.ts
77
+ var import_react_table = require("@tanstack/react-table");
78
+ var import_react_virtual = require("@tanstack/react-virtual");
79
+ var import_react4 = require("react");
80
+
81
+ // src/components/ui/table/constants.ts
82
+ var DATA_TABLE_ROW_HEIGHT = 44;
83
+ var DATA_TABLE_VIRTUAL_OVERSCAN = 8;
84
+
85
+ // src/components/ui/table/features/cell-edit/useCellEdit.ts
86
+ var import_react = require("react");
87
+
88
+ // src/components/ui/table/features/cell-edit/cellEdit.ts
89
+ function getColumnAccessorKey(columnDef) {
90
+ if (columnDef.accessorKey !== void 0 && columnDef.accessorKey !== null) {
91
+ return String(columnDef.accessorKey);
92
+ }
93
+ return columnDef.id;
94
+ }
95
+ function isColumnEditable(columnDef) {
96
+ return Boolean(columnDef.meta?.editable);
97
+ }
98
+ function getColumnEditType(columnDef) {
99
+ return columnDef.meta?.editType ?? "text";
100
+ }
101
+ function parseCellEditValue(raw, editType) {
102
+ if (editType === "text") {
103
+ return { ok: true, value: raw };
104
+ }
105
+ const trimmed = raw.trim();
106
+ if (trimmed === "") {
107
+ return { ok: true, value: null };
108
+ }
109
+ const parsed = Number(trimmed);
110
+ if (Number.isNaN(parsed)) {
111
+ return { ok: false };
112
+ }
113
+ return { ok: true, value: parsed };
114
+ }
115
+ function getCellEditDraftValue(value) {
116
+ if (value === null || value === void 0) return "";
117
+ return String(value);
118
+ }
119
+ function applyCellEdit(data, rows, rowIndex, colIndex, raw) {
120
+ const cell = rows[rowIndex]?.getVisibleCells()[colIndex];
121
+ if (!cell) return null;
122
+ const columnDef = cell.column.columnDef;
123
+ if (!isColumnEditable(columnDef)) return null;
124
+ const accessorKey = getColumnAccessorKey(columnDef);
125
+ if (!accessorKey) return null;
126
+ const parsed = parseCellEditValue(raw, getColumnEditType(columnDef));
127
+ if (!parsed.ok) return null;
128
+ const newData = data.map((row) => ({ ...row }));
129
+ if (!newData[rowIndex]) return null;
130
+ newData[rowIndex][accessorKey] = parsed.value;
131
+ return newData;
132
+ }
133
+
134
+ // src/components/ui/table/features/cell-edit/useCellEdit.ts
135
+ function useCellEdit({
136
+ data,
137
+ rows,
138
+ onDataChange,
139
+ onCellChange
140
+ }) {
141
+ const [editingCell, setEditingCell] = (0, import_react.useState)(null);
142
+ const [draftValue, setDraftValue] = (0, import_react.useState)("");
143
+ const draftValueRef = (0, import_react.useRef)(draftValue);
144
+ const editingCellRef = (0, import_react.useRef)(editingCell);
145
+ (0, import_react.useEffect)(() => {
146
+ draftValueRef.current = draftValue;
147
+ }, [draftValue]);
148
+ (0, import_react.useEffect)(() => {
149
+ editingCellRef.current = editingCell;
150
+ }, [editingCell]);
151
+ const cancelEdit = (0, import_react.useCallback)(() => {
152
+ setEditingCell(null);
153
+ setDraftValue("");
154
+ }, []);
155
+ const commitEdit = (0, import_react.useCallback)(
156
+ (raw) => {
157
+ const current = editingCellRef.current;
158
+ if (!current) return true;
159
+ if (!onCellChange && !onDataChange) {
160
+ cancelEdit();
161
+ return true;
162
+ }
163
+ const row = rows[current.rowIndex];
164
+ const cell = row?.getVisibleCells()[current.colIndex];
165
+ if (!row || !cell) {
166
+ cancelEdit();
167
+ return true;
168
+ }
169
+ const value = raw ?? draftValueRef.current;
170
+ if (!isColumnEditable(cell.column.columnDef)) {
171
+ cancelEdit();
172
+ return true;
173
+ }
174
+ const parsed = parseCellEditValue(value, getColumnEditType(cell.column.columnDef));
175
+ if (!parsed.ok) return false;
176
+ if (onCellChange) {
177
+ onCellChange(row.id, cell.column.id, parsed.value);
178
+ cancelEdit();
179
+ return true;
180
+ }
181
+ const next = applyCellEdit(data, rows, current.rowIndex, current.colIndex, value);
182
+ if (!next) return false;
183
+ onDataChange?.(next);
184
+ cancelEdit();
185
+ return true;
186
+ },
187
+ [cancelEdit, data, onCellChange, onDataChange, rows]
188
+ );
189
+ const startEdit = (0, import_react.useCallback)(
190
+ (rowIndex, colIndex) => {
191
+ const cell = rows[rowIndex]?.getVisibleCells()[colIndex];
192
+ if (!cell || !isColumnEditable(cell.column.columnDef)) return;
193
+ const current = editingCellRef.current;
194
+ if (current && (current.rowIndex !== rowIndex || current.colIndex !== colIndex) && !commitEdit()) {
195
+ return;
196
+ }
197
+ setEditingCell({ rowIndex, colIndex });
198
+ setDraftValue(getCellEditDraftValue(cell.getValue()));
199
+ },
200
+ [commitEdit, rows]
201
+ );
202
+ return {
203
+ editingCell,
204
+ draftValue,
205
+ setDraftValue,
206
+ startEdit,
207
+ commitEdit,
208
+ cancelEdit
209
+ };
210
+ }
211
+
212
+ // src/components/ui/table/features/cell-selection/useCellSelection.ts
213
+ var import_react2 = require("react");
214
+
215
+ // src/components/ui/table/features/cell-selection/cellSelection.ts
216
+ var INITIAL_DRAG_STATE = {
217
+ isSelecting: false,
218
+ isFillDragging: false,
219
+ start: null,
220
+ end: null,
221
+ fillAnchor: null,
222
+ fillEnd: null
223
+ };
224
+ function getCellSelectionBounds(start, end) {
225
+ if (!start || !end) return null;
226
+ return {
227
+ startRow: Math.min(start.row, end.row),
228
+ endRow: Math.max(start.row, end.row),
229
+ startCol: Math.min(start.col, end.col),
230
+ endCol: Math.max(start.col, end.col)
231
+ };
232
+ }
233
+ function getRowIndexInMergedCell(clientY, cellElement, rowIndex, rowSpan) {
234
+ if (rowSpan <= 1) return rowIndex;
235
+ const rect = cellElement.getBoundingClientRect();
236
+ const relativeY = clientY - rect.top;
237
+ const rowHeight = rect.height / rowSpan;
238
+ const offset = Math.min(
239
+ Math.max(Math.floor(relativeY / rowHeight), 0),
240
+ rowSpan - 1
241
+ );
242
+ return rowIndex + offset;
243
+ }
244
+ function isCellInSelection(rowIndex, colIndex, bounds, rowSpan = 1) {
245
+ if (!bounds) return false;
246
+ const cellEndRow = rowIndex + rowSpan - 1;
247
+ return cellEndRow >= bounds.startRow && rowIndex <= bounds.endRow && colIndex >= bounds.startCol && colIndex <= bounds.endCol;
248
+ }
249
+ function getActiveSelectionBounds(dragState, selectionBounds) {
250
+ if (dragState.isFillDragging && dragState.fillAnchor && dragState.fillEnd) {
251
+ return getCellSelectionBounds(dragState.fillAnchor, dragState.fillEnd);
252
+ }
253
+ return selectionBounds;
254
+ }
255
+ var SELECTION_EDGE_WIDTH_PX = 2;
256
+ var SELECTION_EDGE_COLOR = "var(--color-brand-primary)";
257
+ var CELL_SELECTION_EDGES_CLASS = "cell-selection-edges";
258
+ function getMergedCellStepEdges(rowIndex, colIndex, bounds, rowSpan, isVisuallySelectedAt) {
259
+ const cellEndRow = rowIndex + rowSpan - 1;
260
+ const span = cellEndRow - rowIndex + 1;
261
+ if (span <= 1) return [];
262
+ const edges = [];
263
+ const isNeighborSelected = (row, neighborCol) => {
264
+ if (isVisuallySelectedAt) {
265
+ return isVisuallySelectedAt(row, neighborCol);
266
+ }
267
+ return row >= bounds.startRow && row <= bounds.endRow && neighborCol >= bounds.startCol && neighborCol <= bounds.endCol;
268
+ };
269
+ const pushUnselectedRuns = (side, neighborCol, fromRow, toRowExclusive) => {
270
+ let runStart = null;
271
+ for (let row = fromRow; row < toRowExclusive; row++) {
272
+ if (!isNeighborSelected(row, neighborCol)) {
273
+ if (runStart === null) runStart = row;
274
+ continue;
275
+ }
276
+ if (runStart !== null) {
277
+ edges.push({
278
+ side,
279
+ offsetRatio: (runStart - rowIndex) / span,
280
+ heightRatio: (row - runStart) / span
281
+ });
282
+ runStart = null;
283
+ }
284
+ }
285
+ if (runStart !== null) {
286
+ edges.push({
287
+ side,
288
+ offsetRatio: (runStart - rowIndex) / span,
289
+ heightRatio: (toRowExclusive - runStart) / span
290
+ });
291
+ }
292
+ };
293
+ const collectSide = (side, neighborCol) => {
294
+ if (bounds.startRow > rowIndex) {
295
+ pushUnselectedRuns(
296
+ side,
297
+ neighborCol,
298
+ rowIndex,
299
+ Math.min(bounds.startRow, cellEndRow + 1)
300
+ );
301
+ }
302
+ if (bounds.endRow < cellEndRow) {
303
+ pushUnselectedRuns(
304
+ side,
305
+ neighborCol,
306
+ Math.max(bounds.endRow + 1, rowIndex),
307
+ cellEndRow + 1
308
+ );
309
+ }
310
+ };
311
+ if (colIndex < bounds.endCol) {
312
+ collectSide("right", colIndex + 1);
313
+ }
314
+ if (colIndex > bounds.startCol) {
315
+ collectSide("left", colIndex - 1);
316
+ }
317
+ return edges;
318
+ }
319
+ function buildPartialVerticalGradient(edge) {
320
+ const startPct = edge.offsetRatio * 100;
321
+ const endPct = (edge.offsetRatio + edge.heightRatio) * 100;
322
+ const overlapPx = SELECTION_EDGE_WIDTH_PX + 1;
323
+ const isTopProtrusion = edge.offsetRatio === 0 && edge.heightRatio < 1;
324
+ const isBottomProtrusion = edge.offsetRatio > 0;
325
+ const startStop = isBottomProtrusion ? `calc(${startPct}% - ${overlapPx}px)` : `${startPct}%`;
326
+ const endStop = isTopProtrusion ? `calc(${endPct}% + ${overlapPx}px)` : `${endPct}%`;
327
+ const xPos = edge.side === "left" ? "0" : "100%";
328
+ const layers = [
329
+ {
330
+ image: `linear-gradient(to bottom, transparent 0%, transparent ${startStop}, ${SELECTION_EDGE_COLOR} ${startStop}, ${SELECTION_EDGE_COLOR} ${endStop}, transparent ${endStop}, transparent 100%)`,
331
+ size: `${SELECTION_EDGE_WIDTH_PX}px 100%`,
332
+ position: `${xPos} 0`
333
+ }
334
+ ];
335
+ if (isTopProtrusion || isBottomProtrusion) {
336
+ const capTop = isTopProtrusion ? `calc(${endPct}% - ${SELECTION_EDGE_WIDTH_PX}px)` : `calc(${startPct}% - ${SELECTION_EDGE_WIDTH_PX}px)`;
337
+ layers.push({
338
+ image: `linear-gradient(${SELECTION_EDGE_COLOR}, ${SELECTION_EDGE_COLOR})`,
339
+ size: `${SELECTION_EDGE_WIDTH_PX}px ${SELECTION_EDGE_WIDTH_PX}px`,
340
+ position: `${xPos} ${capTop}`
341
+ });
342
+ }
343
+ return layers;
344
+ }
345
+ function getCellSelectionEdgeStyle(rowIndex, colIndex, bounds, rowSpan = 1, isVisuallySelectedAt) {
346
+ if (!isCellInSelection(rowIndex, colIndex, bounds, rowSpan) || !bounds)
347
+ return void 0;
348
+ const cellEndRow = rowIndex + rowSpan - 1;
349
+ const isTopEdge = bounds.startRow >= rowIndex && bounds.startRow <= cellEndRow;
350
+ const isBottomEdge = bounds.endRow >= rowIndex && bounds.endRow <= cellEndRow;
351
+ const isLeftEdge = colIndex === bounds.startCol;
352
+ const isRightEdge = colIndex === bounds.endCol;
353
+ const selectionContinuesBelow = cellEndRow < bounds.endRow;
354
+ const shadows = [];
355
+ if (isTopEdge) {
356
+ shadows.push(
357
+ `inset 0 ${SELECTION_EDGE_WIDTH_PX}px 0 0 ${SELECTION_EDGE_COLOR}`
358
+ );
359
+ }
360
+ if (isBottomEdge) {
361
+ shadows.push(
362
+ `inset 0 -${SELECTION_EDGE_WIDTH_PX}px 0 0 ${SELECTION_EDGE_COLOR}`
363
+ );
364
+ }
365
+ if (isLeftEdge) {
366
+ shadows.push(
367
+ `inset ${SELECTION_EDGE_WIDTH_PX}px 0 0 0 ${SELECTION_EDGE_COLOR}`
368
+ );
369
+ }
370
+ if (isRightEdge) {
371
+ shadows.push(
372
+ `inset -${SELECTION_EDGE_WIDTH_PX}px 0 0 0 ${SELECTION_EDGE_COLOR}`
373
+ );
374
+ }
375
+ const stepEdges = getMergedCellStepEdges(
376
+ rowIndex,
377
+ colIndex,
378
+ bounds,
379
+ rowSpan,
380
+ isVisuallySelectedAt
381
+ );
382
+ const gradients = [];
383
+ const sizes = [];
384
+ const positions = [];
385
+ for (const edge of stepEdges) {
386
+ for (const partial of buildPartialVerticalGradient(edge)) {
387
+ gradients.push(partial.image);
388
+ sizes.push(partial.size);
389
+ positions.push(partial.position);
390
+ }
391
+ }
392
+ if (shadows.length === 0 && gradients.length === 0 && !selectionContinuesBelow) {
393
+ return void 0;
394
+ }
395
+ const style = {};
396
+ if (shadows.length > 0) {
397
+ style["--selection-edge-shadows"] = shadows.join(", ");
398
+ }
399
+ if (gradients.length > 0) {
400
+ style["--selection-edge-gradients"] = gradients.join(", ");
401
+ style["--selection-edge-sizes"] = sizes.join(", ");
402
+ style["--selection-edge-positions"] = positions.join(", ");
403
+ }
404
+ if (selectionContinuesBelow) {
405
+ style.borderBottomColor = "var(--color-brand-surface)";
406
+ }
407
+ return style;
408
+ }
409
+ function hasCellSelectionEdges(style) {
410
+ return Boolean(
411
+ style?.["--selection-edge-shadows"] || style?.["--selection-edge-gradients"]
412
+ );
413
+ }
414
+
415
+ // src/components/ui/table/features/cell-selection/fillData.ts
416
+ function getColumnAccessorKey2(columnDef) {
417
+ if ("accessorKey" in columnDef && columnDef.accessorKey) {
418
+ return String(columnDef.accessorKey);
419
+ }
420
+ return columnDef.id;
421
+ }
422
+ function collectFillTargets(rows, sourceBounds, fillBounds) {
423
+ const targets = [];
424
+ const sourceHeight = sourceBounds.endRow - sourceBounds.startRow + 1;
425
+ const sourceWidth = sourceBounds.endCol - sourceBounds.startCol + 1;
426
+ for (let rowIndex = fillBounds.startRow; rowIndex <= fillBounds.endRow; rowIndex += 1) {
427
+ for (let colIndex = fillBounds.startCol; colIndex <= fillBounds.endCol; colIndex += 1) {
428
+ if (isCellInSelection(rowIndex, colIndex, sourceBounds)) continue;
429
+ const offsetRow = rowIndex - sourceBounds.startRow;
430
+ const offsetCol = colIndex - sourceBounds.startCol;
431
+ const sourceRowIndex = sourceBounds.startRow + (offsetRow % sourceHeight + sourceHeight) % sourceHeight;
432
+ const sourceColIndex = sourceBounds.startCol + (offsetCol % sourceWidth + sourceWidth) % sourceWidth;
433
+ const targetRow = rows[rowIndex];
434
+ const targetCell = targetRow?.getVisibleCells()[colIndex];
435
+ const sourceCell = rows[sourceRowIndex]?.getVisibleCells()[sourceColIndex];
436
+ if (!targetRow || !targetCell || !sourceCell) continue;
437
+ const accessorKey = getColumnAccessorKey2(
438
+ targetCell.column.columnDef
439
+ );
440
+ if (!accessorKey) continue;
441
+ targets.push({
442
+ rowIndex,
443
+ accessorKey,
444
+ columnId: targetCell.column.id,
445
+ value: sourceCell.getValue(),
446
+ rowId: targetRow.id
447
+ });
448
+ }
449
+ }
450
+ return targets;
451
+ }
452
+ function collectFillChanges(rows, sourceBounds, fillBounds) {
453
+ return collectFillTargets(rows, sourceBounds, fillBounds).map(
454
+ ({ rowId, columnId, value }) => ({ rowId, columnId, value })
455
+ );
456
+ }
457
+ function applyFillData(data, rows, sourceBounds, fillBounds) {
458
+ const newData = data.map((row) => ({ ...row }));
459
+ const targets = collectFillTargets(rows, sourceBounds, fillBounds);
460
+ for (const target of targets) {
461
+ if (!newData[target.rowIndex]) continue;
462
+ newData[target.rowIndex][target.accessorKey] = target.value;
463
+ }
464
+ return newData;
465
+ }
466
+ function hasFillExtension(sourceBounds, fillBounds) {
467
+ if (!sourceBounds) return false;
468
+ return fillBounds.startRow < sourceBounds.startRow || fillBounds.endRow > sourceBounds.endRow || fillBounds.startCol < sourceBounds.startCol || fillBounds.endCol > sourceBounds.endCol;
469
+ }
470
+
471
+ // src/components/ui/table/features/cell-selection/useCellSelection.ts
472
+ function useCellSelection({
473
+ data,
474
+ rows,
475
+ enabled = true,
476
+ onDataChange,
477
+ onBatchChange
478
+ }) {
479
+ const [dragState, setDragState] = (0, import_react2.useState)(INITIAL_DRAG_STATE);
480
+ const cellSelectionBounds = getCellSelectionBounds(dragState.start, dragState.end);
481
+ const activeSelectionBounds = enabled ? getActiveSelectionBounds(dragState, cellSelectionBounds) : null;
482
+ const handleCellMouseDown = (0, import_react2.useCallback)(
483
+ (rowIndex, colIndex) => {
484
+ if (!enabled) return;
485
+ setDragState({
486
+ isSelecting: true,
487
+ isFillDragging: false,
488
+ start: { row: rowIndex, col: colIndex },
489
+ end: { row: rowIndex, col: colIndex },
490
+ fillAnchor: null,
491
+ fillEnd: null
492
+ });
493
+ },
494
+ [enabled]
495
+ );
496
+ const handleCellMouseEnter = (0, import_react2.useCallback)(
497
+ (rowIndex, colIndex) => {
498
+ if (!enabled) return;
499
+ setDragState((prev) => {
500
+ if (prev.isSelecting) {
501
+ return { ...prev, end: { row: rowIndex, col: colIndex } };
502
+ }
503
+ if (prev.isFillDragging) {
504
+ return { ...prev, fillEnd: { row: rowIndex, col: colIndex } };
505
+ }
506
+ return prev;
507
+ });
508
+ },
509
+ [enabled]
510
+ );
511
+ const handleFillHandleMouseDown = (0, import_react2.useCallback)(
512
+ (rowIndex, colIndex) => {
513
+ if (!enabled) return;
514
+ setDragState((prev) => {
515
+ const bounds = getCellSelectionBounds(prev.start, prev.end);
516
+ if (!bounds) return prev;
517
+ return {
518
+ ...prev,
519
+ isSelecting: false,
520
+ isFillDragging: true,
521
+ fillAnchor: { row: bounds.startRow, col: bounds.startCol },
522
+ fillEnd: { row: rowIndex, col: colIndex }
523
+ };
524
+ });
525
+ },
526
+ [enabled]
527
+ );
528
+ (0, import_react2.useEffect)(() => {
529
+ if (!enabled) {
530
+ setDragState(INITIAL_DRAG_STATE);
531
+ }
532
+ }, [enabled]);
533
+ (0, import_react2.useEffect)(() => {
534
+ if (!enabled) return;
535
+ const handleKeyDown = (e) => {
536
+ if ((e.ctrlKey || e.metaKey) && e.key === "c" && activeSelectionBounds) {
537
+ const { startRow, endRow, startCol, endCol } = activeSelectionBounds;
538
+ const selectedData = rows.slice(startRow, endRow + 1).map((row) => {
539
+ const cells = row.getVisibleCells();
540
+ return cells.slice(startCol, endCol + 1).map((cell) => cell.getValue()).join(" ");
541
+ }).join("\n");
542
+ navigator.clipboard.writeText(selectedData);
543
+ }
544
+ };
545
+ window.addEventListener("keydown", handleKeyDown);
546
+ return () => window.removeEventListener("keydown", handleKeyDown);
547
+ }, [activeSelectionBounds, enabled, rows]);
548
+ (0, import_react2.useEffect)(() => {
549
+ if (!enabled) return;
550
+ const handleMouseUp = () => {
551
+ setDragState((prev) => {
552
+ if (prev.isFillDragging && prev.fillAnchor && prev.fillEnd) {
553
+ const sourceBounds = getCellSelectionBounds(prev.start, prev.end);
554
+ const newBounds = getCellSelectionBounds(prev.fillAnchor, prev.fillEnd);
555
+ if (newBounds) {
556
+ if (hasFillExtension(sourceBounds, newBounds) && sourceBounds) {
557
+ if (onBatchChange) {
558
+ const changes = collectFillChanges(rows, sourceBounds, newBounds);
559
+ if (changes.length > 0) {
560
+ onBatchChange(changes);
561
+ }
562
+ } else if (onDataChange) {
563
+ onDataChange(applyFillData(data, rows, sourceBounds, newBounds));
564
+ }
565
+ }
566
+ return {
567
+ isSelecting: false,
568
+ isFillDragging: false,
569
+ start: { row: newBounds.startRow, col: newBounds.startCol },
570
+ end: { row: newBounds.endRow, col: newBounds.endCol },
571
+ fillAnchor: null,
572
+ fillEnd: null
573
+ };
574
+ }
575
+ }
576
+ if (prev.isSelecting) {
577
+ return { ...prev, isSelecting: false };
578
+ }
579
+ if (prev.isFillDragging) {
580
+ return { ...prev, isFillDragging: false, fillAnchor: null, fillEnd: null };
581
+ }
582
+ return prev;
583
+ });
584
+ };
585
+ window.addEventListener("mouseup", handleMouseUp);
586
+ return () => window.removeEventListener("mouseup", handleMouseUp);
587
+ }, [data, enabled, onBatchChange, onDataChange, rows]);
588
+ return {
589
+ dragState: enabled ? dragState : INITIAL_DRAG_STATE,
590
+ activeSelectionBounds,
591
+ handleCellMouseDown,
592
+ handleCellMouseEnter,
593
+ handleFillHandleMouseDown
594
+ };
595
+ }
596
+
597
+ // src/components/ui/table/features/row-expand/row-expand.ts
598
+ var import_react3 = require("react");
599
+ function getFieldValue(row, key) {
600
+ return row[key];
601
+ }
602
+ function canExpandRow(row) {
603
+ const children = row.children;
604
+ const level = row.level;
605
+ return Array.isArray(children) && children.length > 0 && (level === 0 || level === void 0);
606
+ }
607
+ function toggleExpandedRowId(rowId, previous) {
608
+ const next = new Set(previous);
609
+ if (next.has(rowId)) {
610
+ next.delete(rowId);
611
+ } else {
612
+ next.add(rowId);
613
+ }
614
+ return next;
615
+ }
616
+ var useConvertTreeData = ({
617
+ data,
618
+ enabled = true,
619
+ toggleField = DEFAULT_TREE_ID_FIELD,
620
+ childField = DEFAULT_TREE_PARENT_ID_FIELD,
621
+ flattenField = DEFAULT_TREE_CHILDREN_FIELD,
622
+ qtyField = DEFAULT_TREE_QTY_FIELD,
623
+ preventExpand = false,
624
+ startIndex = 1,
625
+ expandedRows,
626
+ onExpandedRowsChange
627
+ }) => {
628
+ const onExpandedRowsChangeRef = (0, import_react3.useRef)(onExpandedRowsChange);
629
+ const hasInitializedRef = (0, import_react3.useRef)(false);
630
+ (0, import_react3.useEffect)(() => {
631
+ onExpandedRowsChangeRef.current = onExpandedRowsChange;
632
+ }, [onExpandedRowsChange]);
633
+ (0, import_react3.useEffect)(() => {
634
+ if (!data || data.length === 0) {
635
+ hasInitializedRef.current = false;
636
+ return;
637
+ }
638
+ if (!enabled || hasInitializedRef.current) return;
639
+ const ids = data.map((item) => getFieldValue(item, toggleField)).filter((value) => typeof value === "string" && value.length > 0);
640
+ onExpandedRowsChangeRef.current?.(new Set(ids));
641
+ hasInitializedRef.current = true;
642
+ }, [enabled, data, toggleField]);
643
+ const processedData = (0, import_react3.useMemo)(() => {
644
+ if (!enabled || !data || data.length === 0) return [];
645
+ const flattenedData = [];
646
+ const flattenItems = (items) => {
647
+ items.forEach((item) => {
648
+ const newItem = { ...item };
649
+ const nested = newItem[flattenField];
650
+ if (Array.isArray(nested)) {
651
+ const children = nested.map(
652
+ (child) => typeof child === "object" && child !== null ? { ...child } : child
653
+ );
654
+ delete newItem[flattenField];
655
+ flattenedData.push(newItem);
656
+ children.forEach((child) => {
657
+ if (typeof child === "object" && child !== null) {
658
+ ;
659
+ child[childField] = newItem[toggleField];
660
+ }
661
+ });
662
+ flattenItems(children);
663
+ } else {
664
+ flattenedData.push(newItem);
665
+ }
666
+ });
667
+ };
668
+ flattenItems(data);
669
+ const dataWithLevels = flattenedData.map((item) => ({
670
+ ...item,
671
+ level: 0,
672
+ children: [],
673
+ processed: false
674
+ }));
675
+ const itemMap = /* @__PURE__ */ new Map();
676
+ dataWithLevels.forEach((item) => {
677
+ const key = getFieldValue(item, toggleField);
678
+ if (typeof key !== "string" || !key) return;
679
+ if (!itemMap.has(key)) {
680
+ itemMap.set(key, []);
681
+ }
682
+ itemMap.get(key)?.push(item);
683
+ });
684
+ const rootItems = [];
685
+ dataWithLevels.forEach((item) => {
686
+ if (!getFieldValue(item, childField)) {
687
+ rootItems.push(item);
688
+ item.processed = true;
689
+ }
690
+ });
691
+ dataWithLevels.forEach((item) => {
692
+ const parentKey = getFieldValue(item, childField);
693
+ if (!parentKey || item.processed) return;
694
+ const parentItems = dataWithLevels.filter(
695
+ (parent) => getFieldValue(parent, toggleField) === parentKey && !getFieldValue(parent, childField)
696
+ );
697
+ if (parentItems.length > 0) {
698
+ const parent = parentItems[0];
699
+ item.level = parent.level + 1;
700
+ parent.children.push(item);
701
+ item.processed = true;
702
+ } else {
703
+ const otherParents = itemMap.get(String(parentKey)) || [];
704
+ if (otherParents.length > 0) {
705
+ const parent = otherParents[0];
706
+ item.level = parent.level + 1;
707
+ parent.children.push(item);
708
+ item.processed = true;
709
+ } else {
710
+ rootItems.push(item);
711
+ item.processed = true;
712
+ }
713
+ }
714
+ });
715
+ return rootItems;
716
+ }, [enabled, data, toggleField, childField, flattenField]);
717
+ const flattenTree = (0, import_react3.useMemo)(() => {
718
+ if (!enabled) return [];
719
+ const flatten = (nodes, result = [], level = 0) => {
720
+ nodes.forEach((node, index) => {
721
+ const currentIndex = level === 0 ? `${index + startIndex}` : `${level}-${index + 1}`;
722
+ const toggleValue = getFieldValue(node, toggleField);
723
+ const uniqueId = `${index}-${String(toggleValue ?? "")}`;
724
+ result.push({
725
+ ...node,
726
+ treeNo: currentIndex,
727
+ uniqueId,
728
+ processed: true
729
+ });
730
+ const shouldExpandChildren = node.children.length > 0 && (preventExpand || typeof toggleValue === "string" && expandedRows?.has(toggleValue));
731
+ if (shouldExpandChildren) {
732
+ flatten(node.children, result, index + startIndex);
733
+ }
734
+ });
735
+ return result;
736
+ };
737
+ const flattenedData = flatten(processedData, [], 0);
738
+ flattenedData.forEach((item) => {
739
+ if (getFieldValue(item, childField)) {
740
+ const parentItem = flattenedData.find(
741
+ (parent) => getFieldValue(parent, toggleField) === getFieldValue(item, childField)
742
+ );
743
+ const parentAmount = parentItem ? Number(getFieldValue(parentItem, qtyField) ?? 1) : 1;
744
+ item.parentCount = parentAmount || 1;
745
+ } else {
746
+ item.parentCount = 1;
747
+ }
748
+ });
749
+ return flattenedData;
750
+ }, [
751
+ enabled,
752
+ processedData,
753
+ startIndex,
754
+ toggleField,
755
+ childField,
756
+ qtyField,
757
+ preventExpand,
758
+ expandedRows
759
+ ]);
760
+ const sortedData = (0, import_react3.useMemo)(() => {
761
+ if (!enabled) {
762
+ return data ?? [];
763
+ }
764
+ return [...flattenTree].sort((a, b) => {
765
+ const aParts = String(a.treeNo ?? "").split("-").map(Number);
766
+ const bParts = String(b.treeNo ?? "").split("-").map(Number);
767
+ for (let i = 0; i < Math.max(aParts.length, bParts.length); i++) {
768
+ const aVal = aParts[i] || 0;
769
+ const bVal = bParts[i] || 0;
770
+ if (aVal !== bVal) {
771
+ return aVal - bVal;
772
+ }
773
+ }
774
+ return 0;
775
+ });
776
+ }, [enabled, data, flattenTree]);
777
+ return sortedData;
778
+ };
779
+
780
+ // src/components/ui/table/features/row-selection/rowSelection.ts
781
+ function resolveRowSelection(mode, controlledSelection, internalSelection) {
782
+ if (mode === "none") return {};
783
+ return controlledSelection ?? internalSelection;
784
+ }
785
+ function normalizeSingleSelection(next) {
786
+ const selectedIds = Object.keys(next).filter((id) => next[id]);
787
+ if (selectedIds.length <= 1) return next;
788
+ return { [selectedIds[selectedIds.length - 1]]: true };
789
+ }
790
+ function applySelectionUpdater(mode, updater, previous) {
791
+ const next = typeof updater === "function" ? updater(previous) : updater;
792
+ return mode === "single" ? normalizeSingleSelection(next) : next;
793
+ }
794
+
795
+ // src/components/ui/table/features/row-span/rowSpan.ts
796
+ function getRowFieldValue(row, key) {
797
+ return row[key];
798
+ }
799
+ function computeRowSpans(data, rowSpanKey) {
800
+ if (data.length === 0) return [];
801
+ const result = [];
802
+ for (let index = 0; index < data.length; index++) {
803
+ const currentValue = getRowFieldValue(data[index], rowSpanKey);
804
+ const previousValue = index > 0 ? getRowFieldValue(data[index - 1], rowSpanKey) : void 0;
805
+ if (index > 0 && currentValue === previousValue) {
806
+ result.push({ rowSpan: 0, isFirstInGroup: false });
807
+ continue;
808
+ }
809
+ let span = 1;
810
+ for (let nextIndex = index + 1; nextIndex < data.length; nextIndex++) {
811
+ if (getRowFieldValue(data[nextIndex], rowSpanKey) === currentValue) {
812
+ span++;
813
+ } else {
814
+ break;
815
+ }
816
+ }
817
+ result.push({ rowSpan: span, isFirstInGroup: true });
818
+ }
819
+ return result;
820
+ }
821
+ function resolveRowSpanAt(rowSpans, rowIndex) {
822
+ if (!rowSpans?.[rowIndex]) {
823
+ return { startRow: rowIndex, rowSpan: 1 };
824
+ }
825
+ const current = rowSpans[rowIndex];
826
+ if (current.rowSpan > 0) {
827
+ return { startRow: rowIndex, rowSpan: current.rowSpan };
828
+ }
829
+ for (let row = rowIndex - 1; row >= 0; row--) {
830
+ const info = rowSpans[row];
831
+ if (info && info.rowSpan > 0) {
832
+ return { startRow: row, rowSpan: info.rowSpan };
833
+ }
834
+ }
835
+ return { startRow: rowIndex, rowSpan: 1 };
836
+ }
837
+ function buildColumnRowSpanMap(data, columnKeys) {
838
+ const map = /* @__PURE__ */ new Map();
839
+ for (const { columnId, rowSpanKey } of columnKeys) {
840
+ map.set(columnId, computeRowSpans(data, rowSpanKey));
841
+ }
842
+ return map;
843
+ }
844
+ function collectRowSpanColumns(columns) {
845
+ const result = [];
846
+ const visit = (defs) => {
847
+ for (const columnDef of defs) {
848
+ if ("columns" in columnDef && columnDef.columns?.length) {
849
+ visit(columnDef.columns);
850
+ continue;
851
+ }
852
+ const columnId = columnDef.id ?? ("accessorKey" in columnDef && columnDef.accessorKey ? String(columnDef.accessorKey) : void 0);
853
+ if (!columnId || !columnDef.meta?.rowSpan) continue;
854
+ result.push({
855
+ columnId,
856
+ rowSpanKey: columnDef.meta.rowSpanKey ?? columnId
857
+ });
858
+ }
859
+ };
860
+ visit(columns);
861
+ return result;
862
+ }
863
+
864
+ // src/core/useGlideTable.ts
865
+ function useGlideTable(options) {
866
+ const {
867
+ data,
868
+ columns,
869
+ rowSelectionMode = "none",
870
+ rowSelection: controlledRowSelection,
871
+ onRowSelectionChange,
872
+ selectionLabel,
873
+ emptyText,
874
+ loadingText,
875
+ labels: labelsProp,
876
+ enableRowSpan = false,
877
+ getRowId,
878
+ onRowClick,
879
+ getRowClassName,
880
+ getRowCanSelect,
881
+ selectOnRowClick = true,
882
+ enableCellSelection = true,
883
+ onDataChange,
884
+ onCellChange,
885
+ onBatchChange,
886
+ preserveRowSelection = false,
887
+ toggleField,
888
+ childField,
889
+ flattenField,
890
+ qtyField,
891
+ expandedRows: controlledExpandedRows,
892
+ onExpandedRowsChange,
893
+ preventExpand = false,
894
+ enableVirtualization = true,
895
+ estimateRowHeight = DATA_TABLE_ROW_HEIGHT,
896
+ virtualOverscan = DATA_TABLE_VIRTUAL_OVERSCAN
897
+ } = options;
898
+ const labels = (0, import_react4.useMemo)(() => {
899
+ const resolved = resolveDataTableLabels(labelsProp);
900
+ return {
901
+ ...resolved,
902
+ empty: labelsProp?.empty ?? emptyText ?? resolved.empty,
903
+ loading: labelsProp?.loading ?? loadingText ?? resolved.loading,
904
+ selection: labelsProp?.selection ?? selectionLabel ?? resolved.selection
905
+ };
906
+ }, [labelsProp, emptyText, loadingText, selectionLabel]);
907
+ const enableExpand = Boolean(toggleField);
908
+ const [internalRowSelection, setInternalRowSelection] = (0, import_react4.useState)({});
909
+ const [internalExpandedRows, setInternalExpandedRows] = (0, import_react4.useState)(
910
+ () => /* @__PURE__ */ new Set()
911
+ );
912
+ const [hoveredRowIndex, setHoveredRowIndex] = (0, import_react4.useState)(null);
913
+ const [hoveredGroupKey, setHoveredGroupKey] = (0, import_react4.useState)(null);
914
+ const scrollRef = (0, import_react4.useRef)(null);
915
+ const shouldVirtualize = enableVirtualization && !enableRowSpan;
916
+ (0, import_react4.useEffect)(() => {
917
+ if (enableVirtualization && enableRowSpan) {
918
+ console.warn(
919
+ "[useGlideTable] enableRowSpan is on; virtualization is disabled to preserve cell merges."
920
+ );
921
+ }
922
+ }, [enableVirtualization, enableRowSpan]);
923
+ const rowSelection = resolveRowSelection(
924
+ rowSelectionMode,
925
+ controlledRowSelection,
926
+ internalRowSelection
927
+ );
928
+ const expandedRows = controlledExpandedRows ?? internalExpandedRows;
929
+ const handleExpandedRowsChange = (0, import_react4.useCallback)(
930
+ (next) => {
931
+ if (onExpandedRowsChange) {
932
+ onExpandedRowsChange(next);
933
+ return;
934
+ }
935
+ setInternalExpandedRows(next);
936
+ },
937
+ [onExpandedRowsChange]
938
+ );
939
+ const tableData = useConvertTreeData({
940
+ data,
941
+ enabled: enableExpand,
942
+ toggleField,
943
+ childField,
944
+ flattenField,
945
+ qtyField,
946
+ expandedRows,
947
+ onExpandedRowsChange: enableExpand ? handleExpandedRowsChange : void 0,
948
+ preventExpand
949
+ });
950
+ const table = (0, import_react_table.useReactTable)({
951
+ data: tableData,
952
+ columns,
953
+ state: {
954
+ rowSelection: rowSelectionMode === "none" ? {} : rowSelection
955
+ },
956
+ enableRowSelection: rowSelectionMode === "none" ? false : getRowCanSelect ? (row) => getRowCanSelect(row.original, row.index) : true,
957
+ enableMultiRowSelection: rowSelectionMode === "multi",
958
+ onRowSelectionChange: (updater) => {
959
+ if (onRowSelectionChange) {
960
+ onRowSelectionChange(
961
+ (previous) => applySelectionUpdater(rowSelectionMode, updater, previous)
962
+ );
963
+ return;
964
+ }
965
+ setInternalRowSelection(
966
+ (previous) => applySelectionUpdater(rowSelectionMode, updater, previous)
967
+ );
968
+ },
969
+ getCoreRowModel: (0, import_react_table.getCoreRowModel)(),
970
+ getRowId: getRowId ? (originalRow, index) => getRowId(originalRow, index) : (_originalRow, index) => String(index)
971
+ });
972
+ const rowSpanColumnKeys = (0, import_react4.useMemo)(() => {
973
+ if (!enableRowSpan) return [];
974
+ return collectRowSpanColumns(columns);
975
+ }, [enableRowSpan, columns]);
976
+ const primaryRowSpanKey = rowSpanColumnKeys[0]?.rowSpanKey;
977
+ const columnRowSpanMap = (0, import_react4.useMemo)(
978
+ () => buildColumnRowSpanMap(tableData, rowSpanColumnKeys),
979
+ [tableData, rowSpanColumnKeys]
980
+ );
981
+ const selectedRows = table.getSelectedRowModel().rows;
982
+ const selectedCount = selectedRows.length;
983
+ const rows = table.getRowModel().rows;
984
+ const columnCount = table.getAllLeafColumns().length || 1;
985
+ const rowVirtualizer = (0, import_react_virtual.useVirtualizer)({
986
+ count: shouldVirtualize ? rows.length : 0,
987
+ getScrollElement: () => scrollRef.current,
988
+ estimateSize: () => estimateRowHeight,
989
+ overscan: virtualOverscan
990
+ });
991
+ const virtualRows = rowVirtualizer.getVirtualItems();
992
+ const totalSize = rowVirtualizer.getTotalSize();
993
+ const paddingTop = virtualRows.length > 0 ? virtualRows[0]?.start ?? 0 : 0;
994
+ const paddingBottom = virtualRows.length > 0 ? totalSize - (virtualRows[virtualRows.length - 1]?.end ?? 0) : 0;
995
+ const selectedGroupKeys = (0, import_react4.useMemo)(() => {
996
+ if (!enableRowSpan || !primaryRowSpanKey) return /* @__PURE__ */ new Set();
997
+ const keys = /* @__PURE__ */ new Set();
998
+ for (const selectedRow of selectedRows) {
999
+ const value = selectedRow.original[primaryRowSpanKey];
1000
+ if (value !== null && value !== void 0) keys.add(String(value));
1001
+ }
1002
+ return keys;
1003
+ }, [enableRowSpan, primaryRowSpanKey, selectedRows]);
1004
+ const {
1005
+ dragState,
1006
+ activeSelectionBounds,
1007
+ handleCellMouseDown,
1008
+ handleCellMouseEnter,
1009
+ handleFillHandleMouseDown
1010
+ } = useCellSelection({
1011
+ data: tableData,
1012
+ rows,
1013
+ enabled: enableCellSelection,
1014
+ onDataChange,
1015
+ onBatchChange
1016
+ });
1017
+ const {
1018
+ editingCell,
1019
+ draftValue,
1020
+ setDraftValue,
1021
+ startEdit,
1022
+ commitEdit,
1023
+ cancelEdit
1024
+ } = useCellEdit({ data: tableData, rows, onDataChange, onCellChange });
1025
+ const handleCellMouseDownWithCommit = (0, import_react4.useCallback)(
1026
+ (rowIndex, colIndex) => {
1027
+ const isSameEditingCell = editingCell?.rowIndex === rowIndex && editingCell?.colIndex === colIndex;
1028
+ if (editingCell && !isSameEditingCell && !commitEdit()) {
1029
+ return;
1030
+ }
1031
+ handleCellMouseDown(rowIndex, colIndex);
1032
+ },
1033
+ [commitEdit, editingCell, handleCellMouseDown]
1034
+ );
1035
+ const clearHover = (0, import_react4.useCallback)(() => {
1036
+ setHoveredRowIndex(null);
1037
+ setHoveredGroupKey(null);
1038
+ }, []);
1039
+ const handleRowHover = (0, import_react4.useCallback)(
1040
+ (rowIndex, rowData) => {
1041
+ setHoveredRowIndex(rowIndex);
1042
+ if (!primaryRowSpanKey) {
1043
+ setHoveredGroupKey(null);
1044
+ return;
1045
+ }
1046
+ const groupValue = rowData[primaryRowSpanKey];
1047
+ setHoveredGroupKey(
1048
+ groupValue === null || groupValue === void 0 ? null : String(groupValue)
1049
+ );
1050
+ },
1051
+ [primaryRowSpanKey]
1052
+ );
1053
+ const handleToggleSelect = (0, import_react4.useCallback)(
1054
+ (row) => {
1055
+ if (!row.getCanSelect()) return;
1056
+ if (preserveRowSelection && row.getIsSelected()) {
1057
+ return;
1058
+ }
1059
+ row.toggleSelected();
1060
+ },
1061
+ [preserveRowSelection]
1062
+ );
1063
+ const handleToggleExpand = (0, import_react4.useCallback)(
1064
+ (rowKey) => {
1065
+ if (preventExpand) return;
1066
+ handleExpandedRowsChange(toggleExpandedRowId(rowKey, expandedRows));
1067
+ },
1068
+ [preventExpand, handleExpandedRowsChange, expandedRows]
1069
+ );
1070
+ const rowContextValue = (0, import_react4.useMemo)(() => {
1071
+ return {
1072
+ rowSpan: {
1073
+ enableRowSpan,
1074
+ primaryRowSpanKey,
1075
+ columnRowSpanMap,
1076
+ hoveredRowIndex,
1077
+ hoveredGroupKey,
1078
+ selectedGroupKeys,
1079
+ onRowHover: handleRowHover
1080
+ },
1081
+ selection: {
1082
+ rowSelectionMode,
1083
+ selectOnRowClick,
1084
+ onRowClick,
1085
+ getRowClassName
1086
+ },
1087
+ cellSelection: {
1088
+ enableCellSelection,
1089
+ activeSelectionBounds,
1090
+ dragState,
1091
+ onCellMouseDown: handleCellMouseDownWithCommit,
1092
+ onCellMouseEnter: handleCellMouseEnter,
1093
+ onFillHandleMouseDown: handleFillHandleMouseDown
1094
+ },
1095
+ cellEdit: {
1096
+ editingCell,
1097
+ draftValue,
1098
+ onDraftValueChange: setDraftValue,
1099
+ onStartEdit: startEdit,
1100
+ onCommitEdit: commitEdit,
1101
+ onCancelEdit: cancelEdit
1102
+ },
1103
+ expand: {
1104
+ enableExpand,
1105
+ toggleField,
1106
+ expandedRows,
1107
+ preventExpand,
1108
+ onToggleExpand: handleToggleExpand,
1109
+ expandRowLabel: labels.expandRow,
1110
+ collapseRowLabel: labels.collapseRow
1111
+ }
1112
+ };
1113
+ }, [
1114
+ enableRowSpan,
1115
+ primaryRowSpanKey,
1116
+ columnRowSpanMap,
1117
+ hoveredRowIndex,
1118
+ hoveredGroupKey,
1119
+ selectedGroupKeys,
1120
+ handleRowHover,
1121
+ rowSelectionMode,
1122
+ selectOnRowClick,
1123
+ onRowClick,
1124
+ getRowClassName,
1125
+ enableCellSelection,
1126
+ activeSelectionBounds,
1127
+ dragState,
1128
+ handleCellMouseDownWithCommit,
1129
+ handleCellMouseEnter,
1130
+ handleFillHandleMouseDown,
1131
+ editingCell,
1132
+ draftValue,
1133
+ setDraftValue,
1134
+ startEdit,
1135
+ commitEdit,
1136
+ cancelEdit,
1137
+ enableExpand,
1138
+ toggleField,
1139
+ expandedRows,
1140
+ preventExpand,
1141
+ handleToggleExpand,
1142
+ labels.expandRow,
1143
+ labels.collapseRow
1144
+ ]);
1145
+ return {
1146
+ table,
1147
+ tableData,
1148
+ rows,
1149
+ columnCount,
1150
+ selectedCount,
1151
+ labels,
1152
+ emptyText: labels.empty,
1153
+ loadingText: labels.loading,
1154
+ selectionLabel: labels.selection,
1155
+ enableCellSelection,
1156
+ shouldVirtualize,
1157
+ scrollRef,
1158
+ rowVirtualizer,
1159
+ virtualRows,
1160
+ paddingTop,
1161
+ paddingBottom,
1162
+ rowContextValue,
1163
+ handleToggleSelect,
1164
+ clearHover
1165
+ };
1166
+ }
1167
+ // Annotate the CommonJS export names for ESM import in node:
1168
+ 0 && (module.exports = {
1169
+ CELL_SELECTION_EDGES_CLASS,
1170
+ DEFAULT_DATA_TABLE_LABELS,
1171
+ DEFAULT_TREE_CHILDREN_FIELD,
1172
+ DEFAULT_TREE_ID_FIELD,
1173
+ DEFAULT_TREE_PARENT_ID_FIELD,
1174
+ DEFAULT_TREE_QTY_FIELD,
1175
+ applyCellEdit,
1176
+ applyFillData,
1177
+ applySelectionUpdater,
1178
+ buildColumnRowSpanMap,
1179
+ canExpandRow,
1180
+ collectFillChanges,
1181
+ collectRowSpanColumns,
1182
+ getCellEditDraftValue,
1183
+ getCellSelectionEdgeStyle,
1184
+ getColumnEditType,
1185
+ getRowIndexInMergedCell,
1186
+ hasCellSelectionEdges,
1187
+ isCellInSelection,
1188
+ isColumnEditable,
1189
+ parseCellEditValue,
1190
+ resolveDataTableLabels,
1191
+ resolveRowSelection,
1192
+ resolveRowSpanAt,
1193
+ toggleExpandedRowId,
1194
+ useCellEdit,
1195
+ useCellSelection,
1196
+ useConvertTreeData,
1197
+ useGlideTable
1198
+ });