react-glide-table 2.2.1 → 2.3.1

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/compound.cjs CHANGED
@@ -28,7 +28,7 @@ module.exports = __toCommonJS(compound_exports);
28
28
 
29
29
  // src/components/ui/table/components/DataTable/DataTable.tsx
30
30
  var import_react_table3 = require("@tanstack/react-table");
31
- var import_react9 = require("react");
31
+ var import_react10 = require("react");
32
32
 
33
33
  // src/components/ui/table/components/DataTable/DataTableRow.tsx
34
34
  var import_react_table = require("@tanstack/react-table");
@@ -58,7 +58,9 @@ var DataTableContext = (0, import_react.createContext)(null);
58
58
  function useDataTableRowContext() {
59
59
  const context = (0, import_react.use)(DataTableContext);
60
60
  if (!context) {
61
- throw new Error("useDataTableRowContext must be used within a DataTableContextProvider");
61
+ throw new Error(
62
+ "useDataTableRowContext must be used within a DataTableContextProvider"
63
+ );
62
64
  }
63
65
  return context;
64
66
  }
@@ -530,8 +532,105 @@ function flattenHeaderLeaves(column) {
530
532
  }
531
533
 
532
534
  // src/components/ui/table/features/column-resize/columnResize.ts
535
+ function clamp(value, min, max) {
536
+ return Math.min(Math.max(value, min), max);
537
+ }
538
+ function floorOf(column) {
539
+ return column.minWidth ?? 0;
540
+ }
541
+ function ceilOf(column) {
542
+ return column.maxWidth ?? Number.POSITIVE_INFINITY;
543
+ }
544
+ function preferOf(column) {
545
+ const floor = floorOf(column);
546
+ const ceil = ceilOf(column);
547
+ const preferred = column.maxWidth ?? column.minWidth ?? 0;
548
+ return clamp(preferred, floor, Number.isFinite(ceil) ? ceil : preferred);
549
+ }
550
+ function resolveColumnLayoutWidths(containerWidth, columns) {
551
+ const widths = /* @__PURE__ */ new Map();
552
+ const fixed = [];
553
+ const bounded = [];
554
+ let flexCount = 0;
555
+ for (const column of columns) {
556
+ if (column.width != null) {
557
+ fixed.push(column);
558
+ } else if (column.minWidth != null || column.maxWidth != null) {
559
+ bounded.push(column);
560
+ } else {
561
+ flexCount += 1;
562
+ }
563
+ }
564
+ let used = 0;
565
+ for (const column of fixed) {
566
+ let size = column.width;
567
+ if (column.minWidth != null) size = Math.max(size, column.minWidth);
568
+ if (column.maxWidth != null) size = Math.min(size, column.maxWidth);
569
+ widths.set(column.id, size);
570
+ used += size;
571
+ }
572
+ if (bounded.length === 0) {
573
+ return widths;
574
+ }
575
+ const boundedSizes = /* @__PURE__ */ new Map();
576
+ let preferredSum = 0;
577
+ let floorSum = 0;
578
+ for (const column of bounded) {
579
+ const preferred = preferOf(column);
580
+ boundedSizes.set(column.id, preferred);
581
+ preferredSum += preferred;
582
+ floorSum += floorOf(column);
583
+ }
584
+ if (containerWidth > 0) {
585
+ const remaining = Math.max(0, containerWidth - used);
586
+ if (remaining >= preferredSum) {
587
+ } else if (remaining >= floorSum) {
588
+ let deficit = preferredSum - remaining;
589
+ const open = bounded.map((column) => ({
590
+ id: column.id,
591
+ current: boundedSizes.get(column.id),
592
+ floor: floorOf(column)
593
+ }));
594
+ while (deficit >= 1) {
595
+ const shrinkable = open.filter((entry) => entry.current > entry.floor);
596
+ if (shrinkable.length === 0) break;
597
+ const portion = Math.floor(deficit / shrinkable.length);
598
+ const rem = deficit % shrinkable.length;
599
+ let consumed = 0;
600
+ for (let index = 0; index < shrinkable.length; index += 1) {
601
+ const entry = shrinkable[index];
602
+ const reduce = Math.min(
603
+ entry.current - entry.floor,
604
+ portion + (index < rem ? 1 : 0)
605
+ );
606
+ entry.current -= reduce;
607
+ consumed += reduce;
608
+ }
609
+ if (consumed === 0) break;
610
+ deficit -= consumed;
611
+ }
612
+ for (const entry of open) {
613
+ boundedSizes.set(entry.id, entry.current);
614
+ }
615
+ } else {
616
+ for (const column of bounded) {
617
+ boundedSizes.set(column.id, floorOf(column));
618
+ }
619
+ }
620
+ }
621
+ for (const [id, size] of boundedSizes) {
622
+ widths.set(id, Math.round(size));
623
+ }
624
+ return widths;
625
+ }
533
626
  function getColumnSizeStyle(size, options) {
534
- const { force = false, lockMax = false, minWidth, maxWidth } = options ?? {};
627
+ const {
628
+ force = false,
629
+ lockMax = false,
630
+ minWidth,
631
+ maxWidth,
632
+ layoutWidth
633
+ } = options ?? {};
535
634
  if (lockMax) {
536
635
  return {
537
636
  width: size,
@@ -539,14 +638,27 @@ function getColumnSizeStyle(size, options) {
539
638
  maxWidth: size
540
639
  };
541
640
  }
641
+ if (layoutWidth != null) {
642
+ return {
643
+ width: layoutWidth,
644
+ minWidth: layoutWidth,
645
+ maxWidth: layoutWidth
646
+ };
647
+ }
648
+ const resolvedSize = size;
542
649
  const hasExplicitSize = force || size !== DATA_TABLE_COLUMN_SIZE;
543
650
  if (!hasExplicitSize && minWidth == null && maxWidth == null) {
544
651
  return void 0;
545
652
  }
546
653
  const style = {};
547
654
  if (hasExplicitSize) {
548
- style.width = size;
549
- style.minWidth = minWidth ?? size;
655
+ const used = minWidth != null || maxWidth != null ? clamp(
656
+ resolvedSize,
657
+ minWidth ?? Number.NEGATIVE_INFINITY,
658
+ maxWidth ?? Number.POSITIVE_INFINITY
659
+ ) : resolvedSize;
660
+ style.width = used;
661
+ style.minWidth = minWidth ?? used;
550
662
  } else if (minWidth != null) {
551
663
  style.minWidth = minWidth;
552
664
  }
@@ -1196,6 +1308,12 @@ function isInteractiveMouseTarget(target) {
1196
1308
  ].join(",");
1197
1309
  return target.closest(interactiveSelector) !== null;
1198
1310
  }
1311
+ function blurActiveElementOutside(container) {
1312
+ const active = document.activeElement;
1313
+ if (!(active instanceof HTMLElement) || active === document.body) return;
1314
+ if (container instanceof Node && container.contains(active)) return;
1315
+ active.blur();
1316
+ }
1199
1317
  function resolveExpandCellIndex(cells, toggleField) {
1200
1318
  if (!toggleField) return 0;
1201
1319
  const matchedIndex = cells.findIndex(
@@ -1228,7 +1346,7 @@ function DataTableRow({
1228
1346
  columnFreeze,
1229
1347
  inlineSearch
1230
1348
  } = useDataTableRowContext();
1231
- const { enableColumnResize } = columnResize;
1349
+ const { enableColumnResize, layoutWidths } = columnResize;
1232
1350
  const { enableColumnFreeze, offsets: freezeOffsets } = columnFreeze;
1233
1351
  const {
1234
1352
  enabled: enableInlineSearch,
@@ -1423,7 +1541,8 @@ function DataTableRow({
1423
1541
  force: enableColumnResize,
1424
1542
  lockMax: enableColumnResize,
1425
1543
  minWidth: meta?.minWidth,
1426
- maxWidth: meta?.maxWidth
1544
+ maxWidth: meta?.maxWidth,
1545
+ layoutWidth: layoutWidths?.get(columnId)
1427
1546
  });
1428
1547
  const freezeOffset = enableColumnFreeze ? freezeOffsets.get(columnId) : void 0;
1429
1548
  const freezeStyle = getColumnFreezeStyle(freezeOffset);
@@ -1463,6 +1582,7 @@ function DataTableRow({
1463
1582
  if (!enableCellSelection) return;
1464
1583
  if (isInteractiveMouseTarget(event.target)) return;
1465
1584
  event.preventDefault();
1585
+ blurActiveElementOutside(event.currentTarget);
1466
1586
  onCellMouseDown(
1467
1587
  resolveCellRowIndex(event.clientY, event.currentTarget),
1468
1588
  cellIndex,
@@ -1626,6 +1746,7 @@ function DataTableRow({
1626
1746
  onMouseDown: (event) => {
1627
1747
  event.stopPropagation();
1628
1748
  event.preventDefault();
1749
+ blurActiveElementOutside(event.currentTarget);
1629
1750
  onFillHandleMouseDown(rowIndex, cellIndex);
1630
1751
  }
1631
1752
  }
@@ -2209,7 +2330,7 @@ function useColumnReorder(options) {
2209
2330
  // src/core/useGlideTable.ts
2210
2331
  var import_react_table2 = require("@tanstack/react-table");
2211
2332
  var import_react_virtual = require("@tanstack/react-virtual");
2212
- var import_react8 = require("react");
2333
+ var import_react9 = require("react");
2213
2334
 
2214
2335
  // src/components/ui/table/features/cell-edit/useCellEdit.ts
2215
2336
  var import_react5 = require("react");
@@ -2537,10 +2658,304 @@ function formatDefaultCellValue(value) {
2537
2658
  return String(value);
2538
2659
  }
2539
2660
 
2661
+ // src/components/ui/table/features/cell-selection/pasteData.ts
2662
+ function countLeadingEmptyCells(cells) {
2663
+ let depth = 0;
2664
+ while (depth < cells.length && cells[depth] === "") {
2665
+ depth += 1;
2666
+ }
2667
+ return depth;
2668
+ }
2669
+ function looksLikeSubtreeIndentation(leadingEmptyCounts) {
2670
+ if (leadingEmptyCounts.length === 0) return false;
2671
+ const firstDepth = leadingEmptyCounts[0] ?? 0;
2672
+ if (firstDepth !== 0) return false;
2673
+ return leadingEmptyCounts.some((depth) => depth > 0);
2674
+ }
2675
+ function parseClipboardTSVWithDepths(text) {
2676
+ if (!text) return { values: [], depths: [] };
2677
+ const normalized = text.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
2678
+ const withoutTrailing = normalized.replace(/\n+$/, "");
2679
+ if (!withoutTrailing) return { values: [], depths: [] };
2680
+ const rows = withoutTrailing.split("\n").map((line) => line.split(" "));
2681
+ const leadingEmptyCounts = rows.map(countLeadingEmptyCells);
2682
+ const treatAsDepth = looksLikeSubtreeIndentation(leadingEmptyCounts);
2683
+ const values = [];
2684
+ const depths = [];
2685
+ for (let index = 0; index < rows.length; index += 1) {
2686
+ const cells = rows[index] ?? [];
2687
+ const depth = leadingEmptyCounts[index] ?? 0;
2688
+ if (treatAsDepth) {
2689
+ values.push(cells.slice(depth));
2690
+ depths.push(depth);
2691
+ } else {
2692
+ values.push(cells);
2693
+ depths.push(0);
2694
+ }
2695
+ }
2696
+ return { values, depths };
2697
+ }
2698
+ function resolvePasteColumnIds(rows, startCol, width) {
2699
+ if (width <= 0) return [];
2700
+ const cells = rows[0]?.getVisibleCells() ?? [];
2701
+ const columnIds = [];
2702
+ for (let offset = 0; offset < width; offset += 1) {
2703
+ const cell = cells[startCol + offset];
2704
+ if (!cell) break;
2705
+ columnIds.push(cell.column.id);
2706
+ }
2707
+ return columnIds;
2708
+ }
2709
+ function buildRowsPastePayload(rows, startRow, startCol, text, mode, endRow = startRow) {
2710
+ const { values, depths } = parseClipboardTSVWithDepths(text);
2711
+ if (values.length === 0) return null;
2712
+ const width = Math.max(...values.map((row) => row.length), 0);
2713
+ if (width === 0) return null;
2714
+ const columnIds = resolvePasteColumnIds(rows, startCol, width);
2715
+ if (columnIds.length === 0) return null;
2716
+ const rowIds = [];
2717
+ for (let offset = 0; offset < values.length; offset += 1) {
2718
+ const row = rows[startRow + offset];
2719
+ if (!row) break;
2720
+ rowIds.push(row.id);
2721
+ }
2722
+ const anchorRow = rows[endRow] ?? rows[startRow];
2723
+ return {
2724
+ mode,
2725
+ startRow,
2726
+ startCol,
2727
+ endRow,
2728
+ rowIds,
2729
+ anchorRowId: anchorRow?.id ?? "",
2730
+ columnIds,
2731
+ values,
2732
+ depths
2733
+ };
2734
+ }
2735
+ function isEditablePasteTarget(target) {
2736
+ if (!(target instanceof HTMLElement)) return false;
2737
+ const tag = target.tagName;
2738
+ if (tag === "INPUT" || tag === "TEXTAREA" || tag === "SELECT") return true;
2739
+ return Boolean(target.isContentEditable);
2740
+ }
2741
+
2540
2742
  // src/components/ui/table/features/cell-selection/useCellSelection.ts
2541
- var import_react6 = require("react");
2743
+ var import_react7 = require("react");
2542
2744
 
2543
2745
  // src/components/ui/table/features/cell-selection/copyData.ts
2746
+ var import_react6 = require("react");
2747
+ function isReactNodeIterable(node) {
2748
+ return typeof node === "object" && node !== null && !(0, import_react6.isValidElement)(node) && Symbol.iterator in node;
2749
+ }
2750
+ function getElementTypeName(type) {
2751
+ if (typeof type === "string") return type;
2752
+ if (typeof type === "function") {
2753
+ const fn = type;
2754
+ return fn.displayName || fn.name || "";
2755
+ }
2756
+ if (typeof type === "object" && type !== null) {
2757
+ const component = type;
2758
+ return component.displayName || component.render?.displayName || component.render?.name || "";
2759
+ }
2760
+ return "";
2761
+ }
2762
+ function isButtonReactElement(node) {
2763
+ const typeName = getElementTypeName(node.type);
2764
+ if (typeName === "button" || /button/i.test(typeName)) return true;
2765
+ const props = node.props;
2766
+ if (props.role === "button") return true;
2767
+ if (typeName === "input" && props.type === "button") return true;
2768
+ return false;
2769
+ }
2770
+ function isImageReactElement(node) {
2771
+ const typeName = getElementTypeName(node.type);
2772
+ return typeName === "img" || typeName === "image" || /image/i.test(typeName);
2773
+ }
2774
+ var IMAGE_URL_PROP_KEYS = ["src", "url", "href", "imageUrl", "srcUrl"];
2775
+ function isLikelyUrl(value) {
2776
+ const trimmed = value.trim();
2777
+ if (!trimmed) return false;
2778
+ if (/^(https?:|blob:|data:|\/\/)/i.test(trimmed)) return true;
2779
+ if (trimmed.startsWith("/") && trimmed.includes("/")) return true;
2780
+ return false;
2781
+ }
2782
+ function pickUrlFromUnknown(value) {
2783
+ if (typeof value === "string") {
2784
+ return isLikelyUrl(value) ? value.trim() : "";
2785
+ }
2786
+ if (Array.isArray(value)) {
2787
+ return value.map((item) => pickUrlFromUnknown(item)).filter((item) => item.length > 0).join(", ");
2788
+ }
2789
+ if (value && typeof value === "object") {
2790
+ const record = value;
2791
+ for (const key of IMAGE_URL_PROP_KEYS) {
2792
+ const candidate = record[key];
2793
+ if (typeof candidate === "string" && candidate.trim()) {
2794
+ return candidate.trim();
2795
+ }
2796
+ }
2797
+ }
2798
+ return "";
2799
+ }
2800
+ function imageElementText(node) {
2801
+ const props = node.props;
2802
+ for (const key of IMAGE_URL_PROP_KEYS) {
2803
+ const candidate = props[key];
2804
+ if (typeof candidate === "string" && candidate.trim()) {
2805
+ return candidate.trim();
2806
+ }
2807
+ }
2808
+ return "";
2809
+ }
2810
+ function reactNodeContainsImage(node) {
2811
+ if ((0, import_react6.isValidElement)(node)) {
2812
+ if (isImageReactElement(node)) return true;
2813
+ return reactNodeContainsImage(node.props.children);
2814
+ }
2815
+ if (isReactNodeIterable(node)) {
2816
+ for (const child of node) {
2817
+ if (reactNodeContainsImage(child)) return true;
2818
+ }
2819
+ }
2820
+ return false;
2821
+ }
2822
+ function readImgUrl(img) {
2823
+ const attr = img.getAttribute("src")?.trim() ?? "";
2824
+ if (attr) return attr;
2825
+ if (img instanceof HTMLImageElement) {
2826
+ const current = img.currentSrc?.trim() ?? "";
2827
+ if (current && current !== img.baseURI) return current;
2828
+ }
2829
+ return "";
2830
+ }
2831
+ function readDomImageUrls(rowIndex, colIndex, root) {
2832
+ const scope = root ?? (typeof document === "undefined" ? null : document);
2833
+ if (!scope) return "";
2834
+ const cells = scope.querySelectorAll(
2835
+ `[data-row-index="${rowIndex}"][data-col-index="${colIndex}"]`
2836
+ );
2837
+ for (const cell of cells) {
2838
+ const urls = Array.from(cell.querySelectorAll("img")).flatMap((img) => {
2839
+ const url = readImgUrl(img);
2840
+ return url ? [url] : [];
2841
+ });
2842
+ if (urls.length > 0) return urls.join(", ");
2843
+ }
2844
+ return "";
2845
+ }
2846
+ function reactNodeToText(node) {
2847
+ if (node == null || typeof node === "boolean") return "";
2848
+ if (typeof node === "string" || typeof node === "number" || typeof node === "bigint") {
2849
+ return String(node);
2850
+ }
2851
+ if (isReactNodeIterable(node)) {
2852
+ let text = "";
2853
+ for (const child of node) {
2854
+ text += reactNodeToText(child);
2855
+ }
2856
+ return text;
2857
+ }
2858
+ if ((0, import_react6.isValidElement)(node)) {
2859
+ if (isButtonReactElement(node)) return "";
2860
+ const props = node.props;
2861
+ const childText = reactNodeToText(props.children);
2862
+ if (childText) return childText;
2863
+ const fromImage = imageElementText(node);
2864
+ if (fromImage) return fromImage;
2865
+ if (isImageReactElement(node)) return "";
2866
+ if (typeof props.alt === "string" && props.alt) return props.alt;
2867
+ if (typeof props.title === "string" && props.title) return props.title;
2868
+ return "";
2869
+ }
2870
+ return "";
2871
+ }
2872
+ function sanitizeClipboardCell(text) {
2873
+ return text.replace(/\s+/g, " ").trim();
2874
+ }
2875
+ function createCopyRenderRow(rowData, index) {
2876
+ return {
2877
+ id: getOriginalRowId(rowData) || String(index),
2878
+ index,
2879
+ original: rowData,
2880
+ getIsCellDragSelected: () => false
2881
+ };
2882
+ }
2883
+ function buildVisibleRowLookup(visibleRows) {
2884
+ const lookup = /* @__PURE__ */ new Map();
2885
+ for (const row of visibleRows) {
2886
+ lookup.set(row.original, row);
2887
+ }
2888
+ return lookup;
2889
+ }
2890
+ function resolveCopyColumnId(cell) {
2891
+ if (cell.column.id) return cell.column.id;
2892
+ const columnDef = cell.column.columnDef;
2893
+ if (columnDef.id) return columnDef.id;
2894
+ if (columnDef.accessorKey != null && columnDef.accessorKey !== "") {
2895
+ return String(columnDef.accessorKey);
2896
+ }
2897
+ return "";
2898
+ }
2899
+ function isPrimitiveCopyValue(value) {
2900
+ return value == null || typeof value !== "object";
2901
+ }
2902
+ function extractRenderedCopyText(node, value, cellPosition, root) {
2903
+ const rendered = sanitizeClipboardCell(reactNodeToText(node));
2904
+ if (reactNodeContainsImage(node)) {
2905
+ const fromDom = cellPosition != null ? sanitizeClipboardCell(
2906
+ readDomImageUrls(cellPosition.rowIndex, cellPosition.colIndex, root)
2907
+ ) : "";
2908
+ if (fromDom) return fromDom;
2909
+ if (rendered && isLikelyUrl(rendered)) return rendered;
2910
+ return sanitizeClipboardCell(pickUrlFromUnknown(value));
2911
+ }
2912
+ return rendered;
2913
+ }
2914
+ function formatCopyCellText(rowData, columnDef, columnId, visibleRow, fallbackIndex, sourceCell, cellPosition, options) {
2915
+ const meta = columnDef.meta;
2916
+ const value = sourceCell ? sourceCell.getValue() : readRowColumnValue(rowData, columnDef);
2917
+ const cellRender = meta?.cellRender;
2918
+ if (typeof cellRender === "function") {
2919
+ try {
2920
+ const row = visibleRow ?? createCopyRenderRow(rowData, fallbackIndex);
2921
+ const node = cellRender({
2922
+ value,
2923
+ row,
2924
+ index: row.index,
2925
+ columnId,
2926
+ cellProps: meta?.cellProps,
2927
+ update: () => {
2928
+ }
2929
+ });
2930
+ return extractRenderedCopyText(node, value, cellPosition, options?.root);
2931
+ } catch {
2932
+ return formatCellValue(value);
2933
+ }
2934
+ }
2935
+ if (options?.registry && meta?.kind && isPrimitiveCopyValue(value)) {
2936
+ try {
2937
+ const row = visibleRow ?? createCopyRenderRow(rowData, fallbackIndex);
2938
+ const ctx = {
2939
+ value,
2940
+ row,
2941
+ index: row.index,
2942
+ columnId,
2943
+ cellProps: meta.cellProps,
2944
+ update: () => {
2945
+ }
2946
+ };
2947
+ const renderer = resolveCellRenderer(options.registry, meta.kind, ctx);
2948
+ if (renderer) {
2949
+ const node = renderer.render(ctx);
2950
+ const rendered = extractRenderedCopyText(node, value, cellPosition, options.root);
2951
+ if (rendered) return rendered;
2952
+ }
2953
+ } catch {
2954
+ return formatCellValue(value);
2955
+ }
2956
+ }
2957
+ return formatCellValue(value);
2958
+ }
2544
2959
  function formatPrimitive(value) {
2545
2960
  if (value === null || value === void 0) return "";
2546
2961
  if (typeof value === "string") return value;
@@ -2627,37 +3042,47 @@ function collectCopyRowEntries(visibleRows, bounds, mode = "visible") {
2627
3042
  }
2628
3043
  return result;
2629
3044
  }
2630
- function serializeCopyRowsToTSV(copyRows, visibleRows, bounds, depths) {
3045
+ function serializeCopyRowsToTSV(copyRows, visibleRows, bounds, depths, options) {
2631
3046
  if (copyRows.length === 0) return "";
2632
3047
  const { startCol, endCol } = bounds;
2633
3048
  const columnCells = visibleRows[0]?.getVisibleCells().slice(startCol, endCol + 1) ?? [];
2634
3049
  if (columnCells.length === 0) return "";
2635
3050
  const resolvedDepths = depths && depths.length === copyRows.length ? depths : copyRows.map((row) => getRowDepth(row));
2636
3051
  const minDepth = Math.min(...resolvedDepths);
3052
+ const visibleRowByOriginal = buildVisibleRowLookup(visibleRows);
2637
3053
  return copyRows.map((rowData, index) => {
2638
3054
  const relativeDepth = Math.max(0, (resolvedDepths[index] ?? 0) - minDepth);
2639
- const line = columnCells.map(
2640
- (cell) => formatCellValue(
2641
- readRowColumnValue(
2642
- rowData,
2643
- cell.column.columnDef
2644
- )
2645
- )
2646
- ).join(" ");
3055
+ const visibleRow = visibleRowByOriginal.get(rowData);
3056
+ const matchingCells = visibleRow?.getVisibleCells().slice(startCol, endCol + 1);
3057
+ const line = columnCells.map((templateCell, colOffset) => {
3058
+ const sourceCell = matchingCells?.[colOffset];
3059
+ const column = sourceCell?.column ?? templateCell.column;
3060
+ return formatCopyCellText(
3061
+ rowData,
3062
+ column.columnDef,
3063
+ resolveCopyColumnId(sourceCell ?? templateCell),
3064
+ visibleRow,
3065
+ visibleRow?.index ?? index,
3066
+ sourceCell,
3067
+ visibleRow != null ? { rowIndex: visibleRow.index, colIndex: startCol + colOffset } : void 0,
3068
+ options
3069
+ );
3070
+ }).join(" ");
2647
3071
  return `${" ".repeat(relativeDepth)}${line}`;
2648
3072
  }).join("\n");
2649
3073
  }
2650
- function serializeSelectionToTSV(visibleRows, bounds, mode = "visible") {
3074
+ function serializeSelectionToTSV(visibleRows, bounds, mode = "visible", options) {
2651
3075
  const entries = collectCopyRowEntries(visibleRows, bounds, mode);
2652
3076
  return serializeCopyRowsToTSV(
2653
3077
  entries.map((entry) => entry.row),
2654
3078
  visibleRows,
2655
3079
  bounds,
2656
- entries.map((entry) => entry.depth)
3080
+ entries.map((entry) => entry.depth),
3081
+ options
2657
3082
  );
2658
3083
  }
2659
- async function writeSelectionToClipboard(visibleRows, bounds, mode = "visible") {
2660
- const text = serializeSelectionToTSV(visibleRows, bounds, mode);
3084
+ async function writeSelectionToClipboard(visibleRows, bounds, mode = "visible", options) {
3085
+ const text = serializeSelectionToTSV(visibleRows, bounds, mode, options);
2661
3086
  if (!text) return false;
2662
3087
  try {
2663
3088
  await navigator.clipboard.writeText(text);
@@ -2723,87 +3148,6 @@ function hasFillExtension(sourceBounds, fillBounds) {
2723
3148
  return fillBounds.startRow < sourceBounds.startRow || fillBounds.endRow > sourceBounds.endRow || fillBounds.startCol < sourceBounds.startCol || fillBounds.endCol > sourceBounds.endCol;
2724
3149
  }
2725
3150
 
2726
- // src/components/ui/table/features/cell-selection/pasteData.ts
2727
- function countLeadingEmptyCells(cells) {
2728
- let depth = 0;
2729
- while (depth < cells.length && cells[depth] === "") {
2730
- depth += 1;
2731
- }
2732
- return depth;
2733
- }
2734
- function looksLikeSubtreeIndentation(leadingEmptyCounts) {
2735
- if (leadingEmptyCounts.length === 0) return false;
2736
- const firstDepth = leadingEmptyCounts[0] ?? 0;
2737
- if (firstDepth !== 0) return false;
2738
- return leadingEmptyCounts.some((depth) => depth > 0);
2739
- }
2740
- function parseClipboardTSVWithDepths(text) {
2741
- if (!text) return { values: [], depths: [] };
2742
- const normalized = text.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
2743
- const withoutTrailing = normalized.replace(/\n+$/, "");
2744
- if (!withoutTrailing) return { values: [], depths: [] };
2745
- const rows = withoutTrailing.split("\n").map((line) => line.split(" "));
2746
- const leadingEmptyCounts = rows.map(countLeadingEmptyCells);
2747
- const treatAsDepth = looksLikeSubtreeIndentation(leadingEmptyCounts);
2748
- const values = [];
2749
- const depths = [];
2750
- for (let index = 0; index < rows.length; index += 1) {
2751
- const cells = rows[index] ?? [];
2752
- const depth = leadingEmptyCounts[index] ?? 0;
2753
- if (treatAsDepth) {
2754
- values.push(cells.slice(depth));
2755
- depths.push(depth);
2756
- } else {
2757
- values.push(cells);
2758
- depths.push(0);
2759
- }
2760
- }
2761
- return { values, depths };
2762
- }
2763
- function resolvePasteColumnIds(rows, startCol, width) {
2764
- if (width <= 0) return [];
2765
- const cells = rows[0]?.getVisibleCells() ?? [];
2766
- const columnIds = [];
2767
- for (let offset = 0; offset < width; offset += 1) {
2768
- const cell = cells[startCol + offset];
2769
- if (!cell) break;
2770
- columnIds.push(cell.column.id);
2771
- }
2772
- return columnIds;
2773
- }
2774
- function buildRowsPastePayload(rows, startRow, startCol, text, mode, endRow = startRow) {
2775
- const { values, depths } = parseClipboardTSVWithDepths(text);
2776
- if (values.length === 0) return null;
2777
- const width = Math.max(...values.map((row) => row.length), 0);
2778
- if (width === 0) return null;
2779
- const columnIds = resolvePasteColumnIds(rows, startCol, width);
2780
- if (columnIds.length === 0) return null;
2781
- const rowIds = [];
2782
- for (let offset = 0; offset < values.length; offset += 1) {
2783
- const row = rows[startRow + offset];
2784
- if (!row) break;
2785
- rowIds.push(row.id);
2786
- }
2787
- const anchorRow = rows[endRow] ?? rows[startRow];
2788
- return {
2789
- mode,
2790
- startRow,
2791
- startCol,
2792
- endRow,
2793
- rowIds,
2794
- anchorRowId: anchorRow?.id ?? "",
2795
- columnIds,
2796
- values,
2797
- depths
2798
- };
2799
- }
2800
- function isEditablePasteTarget(target) {
2801
- if (!(target instanceof HTMLElement)) return false;
2802
- const tag = target.tagName;
2803
- if (tag === "INPUT" || tag === "TEXTAREA" || tag === "SELECT") return true;
2804
- return Boolean(target.isContentEditable);
2805
- }
2806
-
2807
3151
  // src/components/ui/table/features/cell-selection/useCellSelection.ts
2808
3152
  function useCellSelection({
2809
3153
  data,
@@ -2815,17 +3159,19 @@ function useCellSelection({
2815
3159
  onDataChange,
2816
3160
  onBatchChange,
2817
3161
  onRowsPaste,
2818
- onCellNavigate
3162
+ onCellNavigate,
3163
+ cellRendererRegistry,
3164
+ rootRef
2819
3165
  }) {
2820
- const [dragState, setDragState] = (0, import_react6.useState)(INITIAL_DRAG_STATE);
2821
- const pendingPasteModeRef = (0, import_react6.useRef)(null);
2822
- const dragStateRef = (0, import_react6.useRef)(dragState);
2823
- const onCellNavigateRef = (0, import_react6.useRef)(onCellNavigate);
3166
+ const [dragState, setDragState] = (0, import_react7.useState)(INITIAL_DRAG_STATE);
3167
+ const pendingPasteModeRef = (0, import_react7.useRef)(null);
3168
+ const dragStateRef = (0, import_react7.useRef)(dragState);
3169
+ const onCellNavigateRef = (0, import_react7.useRef)(onCellNavigate);
2824
3170
  dragStateRef.current = dragState;
2825
3171
  onCellNavigateRef.current = onCellNavigate;
2826
3172
  const cellSelectionBounds = getCellSelectionBounds(dragState.start, dragState.end);
2827
3173
  const activeSelectionBounds = enabled ? getActiveSelectionBounds(dragState, cellSelectionBounds) : null;
2828
- const handleCellMouseDown = (0, import_react6.useCallback)(
3174
+ const handleCellMouseDown = (0, import_react7.useCallback)(
2829
3175
  (rowIndex, colIndex, options) => {
2830
3176
  if (!enabled) return;
2831
3177
  setDragState((prev) => {
@@ -2851,7 +3197,7 @@ function useCellSelection({
2851
3197
  },
2852
3198
  [enabled]
2853
3199
  );
2854
- const handleCellMouseEnter = (0, import_react6.useCallback)(
3200
+ const handleCellMouseEnter = (0, import_react7.useCallback)(
2855
3201
  (rowIndex, colIndex) => {
2856
3202
  if (!enabled) return;
2857
3203
  setDragState((prev) => {
@@ -2866,7 +3212,7 @@ function useCellSelection({
2866
3212
  },
2867
3213
  [enabled]
2868
3214
  );
2869
- const handleFillHandleMouseDown = (0, import_react6.useCallback)(
3215
+ const handleFillHandleMouseDown = (0, import_react7.useCallback)(
2870
3216
  (rowIndex, colIndex) => {
2871
3217
  if (!enabled) return;
2872
3218
  setDragState((prev) => {
@@ -2883,12 +3229,20 @@ function useCellSelection({
2883
3229
  },
2884
3230
  [enabled]
2885
3231
  );
2886
- (0, import_react6.useEffect)(() => {
3232
+ const clearSelection = (0, import_react7.useCallback)(() => {
3233
+ const prev = dragStateRef.current;
3234
+ if (prev.start === null && prev.end === null && !prev.isSelecting && !prev.isFillDragging) {
3235
+ return;
3236
+ }
3237
+ dragStateRef.current = INITIAL_DRAG_STATE;
3238
+ setDragState(INITIAL_DRAG_STATE);
3239
+ }, []);
3240
+ (0, import_react7.useEffect)(() => {
2887
3241
  if (!enabled) {
2888
- setDragState(INITIAL_DRAG_STATE);
3242
+ clearSelection();
2889
3243
  }
2890
- }, [enabled]);
2891
- (0, import_react6.useEffect)(() => {
3244
+ }, [clearSelection, enabled]);
3245
+ (0, import_react7.useEffect)(() => {
2892
3246
  if (!enabled) return;
2893
3247
  const handleKeyDown = (e) => {
2894
3248
  if (e.ctrlKey || e.metaKey || e.altKey) return;
@@ -2935,19 +3289,32 @@ function useCellSelection({
2935
3289
  window.addEventListener("keydown", handleKeyDown);
2936
3290
  return () => window.removeEventListener("keydown", handleKeyDown);
2937
3291
  }, [columnCount, enabled, rows]);
2938
- const copySelection = (0, import_react6.useCallback)(
3292
+ const copySelection = (0, import_react7.useCallback)(
2939
3293
  async (options) => {
2940
3294
  if (!enabled || !activeSelectionBounds) return false;
2941
3295
  const mode = options?.includeDescendants && enableSubtreeCopy ? "subtree" : "visible";
2942
- return writeSelectionToClipboard(rows, activeSelectionBounds, mode);
3296
+ return writeSelectionToClipboard(rows, activeSelectionBounds, mode, {
3297
+ registry: cellRendererRegistry,
3298
+ root: rootRef?.current
3299
+ });
2943
3300
  },
2944
- [activeSelectionBounds, enableSubtreeCopy, enabled, rows]
3301
+ [
3302
+ activeSelectionBounds,
3303
+ cellRendererRegistry,
3304
+ enableSubtreeCopy,
3305
+ enabled,
3306
+ rootRef,
3307
+ rows
3308
+ ]
2945
3309
  );
2946
- (0, import_react6.useEffect)(() => {
3310
+ (0, import_react7.useEffect)(() => {
2947
3311
  if (!enabled) return;
2948
3312
  const handleKeyDown = (e) => {
2949
3313
  if (!activeSelectionBounds) return;
2950
3314
  if (!(e.ctrlKey || e.metaKey)) return;
3315
+ if (isEditablePasteTarget(e.target) || isEditablePasteTarget(document.activeElement)) {
3316
+ return;
3317
+ }
2951
3318
  const isSubtreeShortcut = enableSubtreeCopy && e.shiftKey && e.key.toLowerCase() === "c";
2952
3319
  const isVisibleCopyShortcut = !e.shiftKey && e.key.toLowerCase() === "c";
2953
3320
  if (!isSubtreeShortcut && !isVisibleCopyShortcut) return;
@@ -2957,7 +3324,7 @@ function useCellSelection({
2957
3324
  window.addEventListener("keydown", handleKeyDown);
2958
3325
  return () => window.removeEventListener("keydown", handleKeyDown);
2959
3326
  }, [activeSelectionBounds, copySelection, enableSubtreeCopy, enabled]);
2960
- const emitRowsPaste = (0, import_react6.useCallback)(
3327
+ const emitRowsPaste = (0, import_react7.useCallback)(
2961
3328
  (text, mode) => {
2962
3329
  if (!onRowsPaste || !activeSelectionBounds) return false;
2963
3330
  const payload = buildRowsPastePayload(
@@ -2974,7 +3341,7 @@ function useCellSelection({
2974
3341
  },
2975
3342
  [activeSelectionBounds, onRowsPaste, rows]
2976
3343
  );
2977
- (0, import_react6.useEffect)(() => {
3344
+ (0, import_react7.useEffect)(() => {
2978
3345
  if (!enabled || !onRowsPaste) return;
2979
3346
  const pasteHandledRef = { current: false };
2980
3347
  const ignoreNextPasteRef = { current: false };
@@ -3042,7 +3409,7 @@ function useCellSelection({
3042
3409
  enabled,
3043
3410
  onRowsPaste
3044
3411
  ]);
3045
- (0, import_react6.useEffect)(() => {
3412
+ (0, import_react7.useEffect)(() => {
3046
3413
  if (!enabled) return;
3047
3414
  const handleMouseUp = () => {
3048
3415
  setDragState((prev) => {
@@ -3088,12 +3455,13 @@ function useCellSelection({
3088
3455
  handleCellMouseDown,
3089
3456
  handleCellMouseEnter,
3090
3457
  handleFillHandleMouseDown,
3458
+ clearSelection,
3091
3459
  copySelection
3092
3460
  };
3093
3461
  }
3094
3462
 
3095
3463
  // src/components/ui/table/features/inline-search/useInlineSearch.ts
3096
- var import_react7 = require("react");
3464
+ var import_react8 = require("react");
3097
3465
  var EMPTY_MATCH_KEYS = /* @__PURE__ */ new Set();
3098
3466
  function useInlineSearch({
3099
3467
  enabled = false,
@@ -3110,46 +3478,46 @@ function useInlineSearch({
3110
3478
  onNavigateToResult,
3111
3479
  rootRef
3112
3480
  }) {
3113
- const searchInputId = (0, import_react7.useId)();
3114
- const searchInputRef = (0, import_react7.useRef)(null);
3115
- const [internalShowSearch, setInternalShowSearch] = (0, import_react7.useState)(false);
3116
- const [internalSearchValue, setInternalSearchValue] = (0, import_react7.useState)("");
3117
- const [internalResults, setInternalResults] = (0, import_react7.useState)(
3481
+ const searchInputId = (0, import_react8.useId)();
3482
+ const searchInputRef = (0, import_react8.useRef)(null);
3483
+ const [internalShowSearch, setInternalShowSearch] = (0, import_react8.useState)(false);
3484
+ const [internalSearchValue, setInternalSearchValue] = (0, import_react8.useState)("");
3485
+ const [internalResults, setInternalResults] = (0, import_react8.useState)(
3118
3486
  []
3119
3487
  );
3120
- const [searchStatus, setSearchStatus] = (0, import_react7.useState)();
3121
- const searchStatusRef = (0, import_react7.useRef)(searchStatus);
3488
+ const [searchStatus, setSearchStatus] = (0, import_react8.useState)();
3489
+ const searchStatusRef = (0, import_react8.useRef)(searchStatus);
3122
3490
  searchStatusRef.current = searchStatus;
3123
- const abortControllerRef = (0, import_react7.useRef)(null);
3124
- const searchHandleRef = (0, import_react7.useRef)(void 0);
3125
- const initialStartRowRef = (0, import_react7.useRef)(initialStartRow);
3491
+ const abortControllerRef = (0, import_react8.useRef)(null);
3492
+ const searchHandleRef = (0, import_react8.useRef)(void 0);
3493
+ const initialStartRowRef = (0, import_react8.useRef)(initialStartRow);
3126
3494
  initialStartRowRef.current = initialStartRow;
3127
- const getCellValueRef = (0, import_react7.useRef)(getCellValue);
3495
+ const getCellValueRef = (0, import_react8.useRef)(getCellValue);
3128
3496
  getCellValueRef.current = getCellValue;
3129
3497
  const showSearch = controlledShowSearch ?? internalShowSearch;
3130
3498
  const searchValue = controlledSearchValue ?? internalSearchValue;
3131
3499
  const searchResults = controlledSearchResults ?? internalResults;
3132
- const setSearchValue = (0, import_react7.useCallback)(
3500
+ const setSearchValue = (0, import_react8.useCallback)(
3133
3501
  (value) => {
3134
3502
  setInternalSearchValue(value);
3135
3503
  onSearchValueChange?.(value);
3136
3504
  },
3137
3505
  [onSearchValueChange]
3138
3506
  );
3139
- const cancelSearch = (0, import_react7.useCallback)(() => {
3507
+ const cancelSearch = (0, import_react8.useCallback)(() => {
3140
3508
  if (searchHandleRef.current !== void 0) {
3141
3509
  window.cancelAnimationFrame(searchHandleRef.current);
3142
3510
  searchHandleRef.current = void 0;
3143
3511
  }
3144
3512
  abortControllerRef.current?.abort();
3145
3513
  }, []);
3146
- const emitResultsChanged = (0, import_react7.useCallback)(
3514
+ const emitResultsChanged = (0, import_react8.useCallback)(
3147
3515
  (results, navIndex) => {
3148
3516
  onSearchResultsChanged?.(results, navIndex);
3149
3517
  },
3150
3518
  [onSearchResultsChanged]
3151
3519
  );
3152
- const navigateToIndex = (0, import_react7.useCallback)(
3520
+ const navigateToIndex = (0, import_react8.useCallback)(
3153
3521
  (results, navIndex) => {
3154
3522
  if (onSearchResultsChanged) return;
3155
3523
  if (navIndex < 0 || navIndex >= results.length) return;
@@ -3159,7 +3527,7 @@ function useInlineSearch({
3159
3527
  },
3160
3528
  [onNavigateToResult, onSearchResultsChanged]
3161
3529
  );
3162
- const beginSearch = (0, import_react7.useCallback)(
3530
+ const beginSearch = (0, import_react8.useCallback)(
3163
3531
  (query) => {
3164
3532
  if (controlledSearchResults !== void 0) return;
3165
3533
  const totalRows = rowCount;
@@ -3231,12 +3599,12 @@ function useInlineSearch({
3231
3599
  rowCount
3232
3600
  ]
3233
3601
  );
3234
- const openSearch = (0, import_react7.useCallback)(() => {
3602
+ const openSearch = (0, import_react8.useCallback)(() => {
3235
3603
  if (controlledShowSearch === void 0) {
3236
3604
  setInternalShowSearch(true);
3237
3605
  }
3238
3606
  }, [controlledShowSearch]);
3239
- const closeSearch = (0, import_react7.useCallback)(() => {
3607
+ const closeSearch = (0, import_react8.useCallback)(() => {
3240
3608
  if (controlledShowSearch === void 0) {
3241
3609
  setInternalShowSearch(false);
3242
3610
  }
@@ -3251,7 +3619,7 @@ function useInlineSearch({
3251
3619
  emitResultsChanged,
3252
3620
  onSearchClose
3253
3621
  ]);
3254
- const goToNext = (0, import_react7.useCallback)(() => {
3622
+ const goToNext = (0, import_react8.useCallback)(() => {
3255
3623
  if (!searchStatus || searchStatus.results === 0) return;
3256
3624
  const newIndex = nextSearchIndex(
3257
3625
  searchStatus.selectedIndex,
@@ -3261,7 +3629,7 @@ function useInlineSearch({
3261
3629
  emitResultsChanged(searchResults, newIndex);
3262
3630
  navigateToIndex(searchResults, newIndex);
3263
3631
  }, [emitResultsChanged, navigateToIndex, searchResults, searchStatus]);
3264
- const goToPrevious = (0, import_react7.useCallback)(() => {
3632
+ const goToPrevious = (0, import_react8.useCallback)(() => {
3265
3633
  if (!searchStatus || searchStatus.results === 0) return;
3266
3634
  const newIndex = previousSearchIndex(
3267
3635
  searchStatus.selectedIndex,
@@ -3271,7 +3639,7 @@ function useInlineSearch({
3271
3639
  emitResultsChanged(searchResults, newIndex);
3272
3640
  navigateToIndex(searchResults, newIndex);
3273
3641
  }, [emitResultsChanged, navigateToIndex, searchResults, searchStatus]);
3274
- (0, import_react7.useEffect)(() => {
3642
+ (0, import_react8.useEffect)(() => {
3275
3643
  if (controlledSearchResults === void 0) return;
3276
3644
  if (controlledSearchResults.length > 0) {
3277
3645
  setSearchStatus((current) => ({
@@ -3283,7 +3651,7 @@ function useInlineSearch({
3283
3651
  setSearchStatus(void 0);
3284
3652
  }
3285
3653
  }, [controlledSearchResults, rowCount]);
3286
- (0, import_react7.useEffect)(() => {
3654
+ (0, import_react8.useEffect)(() => {
3287
3655
  if (!enabled) return;
3288
3656
  setSearchStatus(void 0);
3289
3657
  setInternalResults([]);
@@ -3296,7 +3664,7 @@ function useInlineSearch({
3296
3664
  cancelSearch();
3297
3665
  }
3298
3666
  }, [enabled, showSearch]);
3299
- (0, import_react7.useEffect)(() => {
3667
+ (0, import_react8.useEffect)(() => {
3300
3668
  if (!enabled || !showSearch) return;
3301
3669
  if (controlledSearchResults !== void 0) return;
3302
3670
  if (searchValue.trim() === "") {
@@ -3316,7 +3684,7 @@ function useInlineSearch({
3316
3684
  searchValue,
3317
3685
  showSearch
3318
3686
  ]);
3319
- (0, import_react7.useEffect)(() => {
3687
+ (0, import_react8.useEffect)(() => {
3320
3688
  if (!enabled) return;
3321
3689
  const handleKeyDown = (event) => {
3322
3690
  if (!(event.ctrlKey || event.metaKey)) return;
@@ -3343,12 +3711,12 @@ function useInlineSearch({
3343
3711
  window.addEventListener("keydown", handleKeyDown, true);
3344
3712
  return () => window.removeEventListener("keydown", handleKeyDown, true);
3345
3713
  }, [controlledShowSearch, enabled, rootRef, showSearch]);
3346
- (0, import_react7.useEffect)(() => () => cancelSearch(), [cancelSearch]);
3347
- const searchMatchKeys = (0, import_react7.useMemo)(
3714
+ (0, import_react8.useEffect)(() => () => cancelSearch(), [cancelSearch]);
3715
+ const searchMatchKeys = (0, import_react8.useMemo)(
3348
3716
  () => buildSearchMatchKeys(searchResults),
3349
3717
  [searchResults]
3350
3718
  );
3351
- const activeMatch = (0, import_react7.useMemo)(() => {
3719
+ const activeMatch = (0, import_react8.useMemo)(() => {
3352
3720
  if (!searchStatus || searchStatus.selectedIndex < 0) return null;
3353
3721
  return searchResults[searchStatus.selectedIndex] ?? null;
3354
3722
  }, [searchResults, searchStatus]);
@@ -3483,7 +3851,7 @@ function useGlideTable(options) {
3483
3851
  searchResults,
3484
3852
  onSearchResultsChanged
3485
3853
  } = options;
3486
- const labels = (0, import_react8.useMemo)(() => {
3854
+ const labels = (0, import_react9.useMemo)(() => {
3487
3855
  const resolved = resolveDataTableLabels(labelsProp);
3488
3856
  return {
3489
3857
  ...resolved,
@@ -3494,17 +3862,21 @@ function useGlideTable(options) {
3494
3862
  }, [labelsProp, emptyText, loadingText, selectionLabel]);
3495
3863
  const enableExpand = Boolean(toggleField);
3496
3864
  const resolvedEnableSubtreeCopy = enableSubtreeCopy ?? enableExpand;
3497
- const [internalRowSelection, setInternalRowSelection] = (0, import_react8.useState)({});
3498
- const [internalColumnSizing, setInternalColumnSizing] = (0, import_react8.useState)({});
3499
- const [internalColumnOrder, setInternalColumnOrder] = (0, import_react8.useState)([]);
3500
- const [internalExpandedRows, setInternalExpandedRows] = (0, import_react8.useState)(
3865
+ const [internalRowSelection, setInternalRowSelection] = (0, import_react9.useState)({});
3866
+ const [internalColumnSizing, setInternalColumnSizing] = (0, import_react9.useState)({});
3867
+ const [internalColumnOrder, setInternalColumnOrder] = (0, import_react9.useState)([]);
3868
+ const [internalExpandedRows, setInternalExpandedRows] = (0, import_react9.useState)(
3501
3869
  () => /* @__PURE__ */ new Set()
3502
3870
  );
3503
- const [hoveredRowIndex, setHoveredRowIndex] = (0, import_react8.useState)(null);
3504
- const scrollRef = (0, import_react8.useRef)(null);
3505
- const rootRef = (0, import_react8.useRef)(null);
3871
+ const [hoveredRowIndex, setHoveredRowIndex] = (0, import_react9.useState)(null);
3872
+ const scrollRef = (0, import_react9.useRef)(null);
3873
+ const rootRef = (0, import_react9.useRef)(null);
3874
+ const cellRendererRegistry = (0, import_react9.useMemo)(
3875
+ () => createCellRendererRegistry(cellRenderers),
3876
+ [cellRenderers]
3877
+ );
3506
3878
  const shouldVirtualize = enableVirtualization && !enableRowSpan;
3507
- (0, import_react8.useEffect)(() => {
3879
+ (0, import_react9.useEffect)(() => {
3508
3880
  if (enableVirtualization && enableRowSpan) {
3509
3881
  console.warn(
3510
3882
  "[useGlideTable] enableRowSpan is on; virtualization is disabled to preserve cell merges."
@@ -3518,11 +3890,11 @@ function useGlideTable(options) {
3518
3890
  );
3519
3891
  const columnSizing = controlledColumnSizing ?? internalColumnSizing;
3520
3892
  const columnOrder = controlledColumnOrder ?? internalColumnOrder;
3521
- const tableColumns = (0, import_react8.useMemo)(() => {
3893
+ const tableColumns = (0, import_react9.useMemo)(() => {
3522
3894
  if (!enableColumnReorder) return columns;
3523
3895
  return applyLeafColumnOrder(columns, columnOrder);
3524
3896
  }, [columnOrder, columns, enableColumnReorder]);
3525
- const setColumnOrder = (0, import_react8.useCallback)(
3897
+ const setColumnOrder = (0, import_react9.useCallback)(
3526
3898
  (next) => {
3527
3899
  if (onColumnOrderChange) {
3528
3900
  onColumnOrderChange(next);
@@ -3533,7 +3905,7 @@ function useGlideTable(options) {
3533
3905
  [onColumnOrderChange]
3534
3906
  );
3535
3907
  const expandedRows = controlledExpandedRows ?? internalExpandedRows;
3536
- const handleExpandedRowsChange = (0, import_react8.useCallback)(
3908
+ const handleExpandedRowsChange = (0, import_react9.useCallback)(
3537
3909
  (next) => {
3538
3910
  if (onExpandedRowsChange) {
3539
3911
  onExpandedRowsChange(next);
@@ -3594,13 +3966,13 @@ function useGlideTable(options) {
3594
3966
  getCoreRowModel: (0, import_react_table2.getCoreRowModel)(),
3595
3967
  getRowId: getRowId ? (originalRow, index) => getRowId(originalRow, index) : (_originalRow, index) => String(index)
3596
3968
  });
3597
- const rowSpanColumnKeys = (0, import_react8.useMemo)(() => {
3969
+ const rowSpanColumnKeys = (0, import_react9.useMemo)(() => {
3598
3970
  if (!enableRowSpan) return [];
3599
3971
  return collectRowSpanColumns(columns);
3600
3972
  }, [enableRowSpan, columns]);
3601
3973
  const primaryRowSpanKey = rowSpanColumnKeys[0]?.rowSpanKey;
3602
3974
  const primaryRowSpanColumnId = rowSpanColumnKeys[0]?.columnId;
3603
- const columnRowSpanMap = (0, import_react8.useMemo)(
3975
+ const columnRowSpanMap = (0, import_react9.useMemo)(
3604
3976
  () => buildColumnRowSpanMap(tableData, rowSpanColumnKeys),
3605
3977
  [tableData, rowSpanColumnKeys]
3606
3978
  );
@@ -3609,7 +3981,7 @@ function useGlideTable(options) {
3609
3981
  const rows = table.getRowModel().rows;
3610
3982
  const columnCount = table.getAllLeafColumns().length || 1;
3611
3983
  const visibleLeafColumns = table.getVisibleLeafColumns();
3612
- const columnFreezeOffsets = (0, import_react8.useMemo)(() => {
3984
+ const columnFreezeOffsets = (0, import_react9.useMemo)(() => {
3613
3985
  if (!enableColumnFreeze) return EMPTY_COLUMN_FREEZE_OFFSETS;
3614
3986
  return buildColumnFreezeOffsets(
3615
3987
  visibleLeafColumns.map((column) => ({
@@ -3629,14 +4001,14 @@ function useGlideTable(options) {
3629
4001
  const totalSize = rowVirtualizer.getTotalSize();
3630
4002
  const paddingTop = virtualRows.length > 0 ? virtualRows[0]?.start ?? 0 : 0;
3631
4003
  const paddingBottom = virtualRows.length > 0 ? totalSize - (virtualRows[virtualRows.length - 1]?.end ?? 0) : 0;
3632
- const selectedRowIndices = (0, import_react8.useMemo)(() => {
4004
+ const selectedRowIndices = (0, import_react9.useMemo)(() => {
3633
4005
  const indices = /* @__PURE__ */ new Set();
3634
4006
  for (const selectedRow of selectedRows) {
3635
4007
  indices.add(selectedRow.index);
3636
4008
  }
3637
4009
  return indices;
3638
4010
  }, [selectedRows]);
3639
- const scrollCellIntoView = (0, import_react8.useCallback)(
4011
+ const scrollCellIntoView = (0, import_react9.useCallback)(
3640
4012
  (rowIndex, colIndex, options2) => {
3641
4013
  const align = options2?.align ?? "nearest";
3642
4014
  const blockAlign = align === "center" ? "center" : "nearest";
@@ -3663,7 +4035,7 @@ function useGlideTable(options) {
3663
4035
  },
3664
4036
  [rowVirtualizer, shouldVirtualize]
3665
4037
  );
3666
- const handleCellNavigate = (0, import_react8.useCallback)(
4038
+ const handleCellNavigate = (0, import_react9.useCallback)(
3667
4039
  (position) => {
3668
4040
  scrollCellIntoView(position.row, position.col, { align: "nearest" });
3669
4041
  },
@@ -3675,6 +4047,7 @@ function useGlideTable(options) {
3675
4047
  handleCellMouseDown,
3676
4048
  handleCellMouseEnter,
3677
4049
  handleFillHandleMouseDown,
4050
+ clearSelection: clearCellSelection,
3678
4051
  copySelection
3679
4052
  } = useCellSelection({
3680
4053
  data: tableData,
@@ -3686,8 +4059,46 @@ function useGlideTable(options) {
3686
4059
  onDataChange,
3687
4060
  onBatchChange,
3688
4061
  onRowsPaste,
3689
- onCellNavigate: handleCellNavigate
4062
+ onCellNavigate: handleCellNavigate,
4063
+ cellRendererRegistry,
4064
+ rootRef
3690
4065
  });
4066
+ const clearRowSelection = (0, import_react9.useCallback)(() => {
4067
+ if (rowSelectionMode === "none") return;
4068
+ const hasSelection = Object.values(rowSelection).some(Boolean);
4069
+ if (!hasSelection) return;
4070
+ if (onRowSelectionChange) {
4071
+ onRowSelectionChange(() => ({}));
4072
+ return;
4073
+ }
4074
+ setInternalRowSelection({});
4075
+ }, [onRowSelectionChange, rowSelection, rowSelectionMode]);
4076
+ (0, import_react9.useEffect)(() => {
4077
+ const clearAllSelections = () => {
4078
+ clearCellSelection();
4079
+ clearRowSelection();
4080
+ };
4081
+ const handleKeyDown = (event) => {
4082
+ if (event.key !== "Escape") return;
4083
+ if (event.defaultPrevented) return;
4084
+ if (isEditablePasteTarget(event.target) || isEditablePasteTarget(document.activeElement)) {
4085
+ return;
4086
+ }
4087
+ clearAllSelections();
4088
+ };
4089
+ const handleMouseDown = (event) => {
4090
+ const root = rootRef.current;
4091
+ if (!root) return;
4092
+ if (event.target instanceof Node && root.contains(event.target)) return;
4093
+ clearAllSelections();
4094
+ };
4095
+ window.addEventListener("keydown", handleKeyDown);
4096
+ document.addEventListener("mousedown", handleMouseDown);
4097
+ return () => {
4098
+ window.removeEventListener("keydown", handleKeyDown);
4099
+ document.removeEventListener("mousedown", handleMouseDown);
4100
+ };
4101
+ }, [clearCellSelection, clearRowSelection]);
3691
4102
  const {
3692
4103
  editingCell,
3693
4104
  draftValue,
@@ -3696,11 +4107,7 @@ function useGlideTable(options) {
3696
4107
  commitEdit,
3697
4108
  cancelEdit
3698
4109
  } = useCellEdit({ data: tableData, rows, onDataChange, onCellChange });
3699
- const cellRendererRegistry = (0, import_react8.useMemo)(
3700
- () => createCellRendererRegistry(cellRenderers),
3701
- [cellRenderers]
3702
- );
3703
- const commitRenderedCellValue = (0, import_react8.useCallback)(
4110
+ const commitRenderedCellValue = (0, import_react9.useCallback)(
3704
4111
  (rowId, columnId, value) => commitCellValue({
3705
4112
  data: tableData,
3706
4113
  rows,
@@ -3712,11 +4119,11 @@ function useGlideTable(options) {
3712
4119
  }),
3713
4120
  [onCellChange, onDataChange, rows, tableData]
3714
4121
  );
3715
- const getCellContext = (0, import_react8.useCallback)(
4122
+ const getCellContext = (0, import_react9.useCallback)(
3716
4123
  (cell) => withCellUpdate(cell.getContext(), commitRenderedCellValue),
3717
4124
  [commitRenderedCellValue]
3718
4125
  );
3719
- const handleCellMouseDownWithCommit = (0, import_react8.useCallback)(
4126
+ const handleCellMouseDownWithCommit = (0, import_react9.useCallback)(
3720
4127
  (rowIndex, colIndex, options2) => {
3721
4128
  const isSameEditingCell = editingCell?.rowIndex === rowIndex && editingCell?.colIndex === colIndex;
3722
4129
  if (editingCell && !isSameEditingCell && !commitEdit()) {
@@ -3726,7 +4133,7 @@ function useGlideTable(options) {
3726
4133
  },
3727
4134
  [commitEdit, editingCell, handleCellMouseDown]
3728
4135
  );
3729
- const navigateToSearchResult = (0, import_react8.useCallback)(
4136
+ const navigateToSearchResult = (0, import_react9.useCallback)(
3730
4137
  (item) => {
3731
4138
  const [colIndex, rowIndex] = item;
3732
4139
  handleCellMouseDownWithCommit(rowIndex, colIndex);
@@ -3734,7 +4141,7 @@ function useGlideTable(options) {
3734
4141
  },
3735
4142
  [handleCellMouseDownWithCommit, scrollCellIntoView]
3736
4143
  );
3737
- const resolveSearchRowId = (0, import_react8.useCallback)(
4144
+ const resolveSearchRowId = (0, import_react9.useCallback)(
3738
4145
  (row, index) => {
3739
4146
  if (getRowId) return getRowId(row, index);
3740
4147
  if (enableExpand) {
@@ -3758,7 +4165,7 @@ function useGlideTable(options) {
3758
4165
  },
3759
4166
  [enableExpand, getRowId, toggleField]
3760
4167
  );
3761
- const searchCorpus = (0, import_react8.useMemo)(() => {
4168
+ const searchCorpus = (0, import_react9.useMemo)(() => {
3762
4169
  if (!enableInlineSearch) return [];
3763
4170
  if (enableExpand && toggleField) {
3764
4171
  return buildTreeSearchCorpus(tableData, {
@@ -3774,16 +4181,16 @@ function useGlideTable(options) {
3774
4181
  tableData,
3775
4182
  toggleField
3776
4183
  ]);
3777
- const searchCorpusRef = (0, import_react8.useRef)(searchCorpus);
4184
+ const searchCorpusRef = (0, import_react9.useRef)(searchCorpus);
3778
4185
  searchCorpusRef.current = searchCorpus;
3779
- const visibleRowIndexById = (0, import_react8.useMemo)(() => {
4186
+ const visibleRowIndexById = (0, import_react9.useMemo)(() => {
3780
4187
  const map = /* @__PURE__ */ new Map();
3781
4188
  for (const row of rows) {
3782
4189
  map.set(resolveSearchRowId(row.original, row.index), row.index);
3783
4190
  }
3784
4191
  return map;
3785
4192
  }, [resolveSearchRowId, rows]);
3786
- const getSearchCellValue = (0, import_react8.useCallback)(
4193
+ const getSearchCellValue = (0, import_react9.useCallback)(
3787
4194
  (rowIndex, colIndex) => {
3788
4195
  const corpusRow = searchCorpusRef.current[rowIndex];
3789
4196
  const column = visibleLeafColumns[colIndex];
@@ -3806,14 +4213,14 @@ function useGlideTable(options) {
3806
4213
  },
3807
4214
  [rows, visibleLeafColumns, visibleRowIndexById]
3808
4215
  );
3809
- const pendingSearchNavRef = (0, import_react8.useRef)(null);
3810
- const focusSearchResult = (0, import_react8.useCallback)(
4216
+ const pendingSearchNavRef = (0, import_react9.useRef)(null);
4217
+ const focusSearchResult = (0, import_react9.useCallback)(
3811
4218
  (colIndex, visibleRowIndex) => {
3812
4219
  navigateToSearchResult([colIndex, visibleRowIndex]);
3813
4220
  },
3814
4221
  [navigateToSearchResult]
3815
4222
  );
3816
- const navigateToCorpusSearchResult = (0, import_react8.useCallback)(
4223
+ const navigateToCorpusSearchResult = (0, import_react9.useCallback)(
3817
4224
  (item) => {
3818
4225
  const [colIndex, corpusRowIndex] = item;
3819
4226
  const corpusRow = searchCorpusRef.current[corpusRowIndex];
@@ -3846,7 +4253,7 @@ function useGlideTable(options) {
3846
4253
  visibleRowIndexById
3847
4254
  ]
3848
4255
  );
3849
- (0, import_react8.useEffect)(() => {
4256
+ (0, import_react9.useEffect)(() => {
3850
4257
  const pending = pendingSearchNavRef.current;
3851
4258
  if (!pending) return;
3852
4259
  const visibleRowIndex = visibleRowIndexById.get(pending.rowId);
@@ -3870,7 +4277,7 @@ function useGlideTable(options) {
3870
4277
  onNavigateToResult: navigateToCorpusSearchResult,
3871
4278
  rootRef
3872
4279
  });
3873
- const visibleSearchMatchKeys = (0, import_react8.useMemo)(() => {
4280
+ const visibleSearchMatchKeys = (0, import_react9.useMemo)(() => {
3874
4281
  if (!enableInlineSearch) return EMPTY_SEARCH_MATCH_KEYS;
3875
4282
  return mapSearchResultsToVisibleKeys(
3876
4283
  inlineSearch.searchResults,
@@ -3883,7 +4290,7 @@ function useGlideTable(options) {
3883
4290
  searchCorpus,
3884
4291
  visibleRowIndexById
3885
4292
  ]);
3886
- const visibleActiveMatch = (0, import_react8.useMemo)(() => {
4293
+ const visibleActiveMatch = (0, import_react9.useMemo)(() => {
3887
4294
  if (!enableInlineSearch || !inlineSearch.activeMatch) return null;
3888
4295
  return mapSearchResultToVisibleItem(
3889
4296
  inlineSearch.activeMatch,
@@ -3896,13 +4303,13 @@ function useGlideTable(options) {
3896
4303
  searchCorpus,
3897
4304
  visibleRowIndexById
3898
4305
  ]);
3899
- const clearHover = (0, import_react8.useCallback)(() => {
4306
+ const clearHover = (0, import_react9.useCallback)(() => {
3900
4307
  setHoveredRowIndex(null);
3901
4308
  }, []);
3902
- const handleRowHover = (0, import_react8.useCallback)((rowIndex, _rowData) => {
4309
+ const handleRowHover = (0, import_react9.useCallback)((rowIndex, _rowData) => {
3903
4310
  setHoveredRowIndex(rowIndex);
3904
4311
  }, []);
3905
- const handleToggleSelect = (0, import_react8.useCallback)(
4312
+ const handleToggleSelect = (0, import_react9.useCallback)(
3906
4313
  (row) => {
3907
4314
  if (!row.getCanSelect()) return;
3908
4315
  if (preserveRowSelection && row.getIsSelected()) {
@@ -3912,14 +4319,14 @@ function useGlideTable(options) {
3912
4319
  },
3913
4320
  [preserveRowSelection]
3914
4321
  );
3915
- const handleToggleExpand = (0, import_react8.useCallback)(
4322
+ const handleToggleExpand = (0, import_react9.useCallback)(
3916
4323
  (rowKey) => {
3917
4324
  if (preventExpand) return;
3918
4325
  handleExpandedRowsChange(toggleExpandedRowId(rowKey, expandedRows));
3919
4326
  },
3920
4327
  [preventExpand, handleExpandedRowsChange, expandedRows]
3921
4328
  );
3922
- const rowContextValue = (0, import_react8.useMemo)(() => {
4329
+ const rowContextValue = (0, import_react9.useMemo)(() => {
3923
4330
  return {
3924
4331
  rowSpan: {
3925
4332
  enableRowSpan,
@@ -4018,12 +4425,12 @@ function useGlideTable(options) {
4018
4425
  visibleSearchMatchKeys,
4019
4426
  visibleActiveMatch
4020
4427
  ]);
4021
- const copySelectionRef = (0, import_react8.useRef)(copySelection);
4022
- (0, import_react8.useEffect)(() => {
4428
+ const copySelectionRef = (0, import_react9.useRef)(copySelection);
4429
+ (0, import_react9.useEffect)(() => {
4023
4430
  copySelectionRef.current = copySelection;
4024
4431
  }, [copySelection]);
4025
- const stableCopySelection = (0, import_react8.useCallback)((options2) => copySelectionRef.current(options2), []);
4026
- (0, import_react8.useEffect)(() => {
4432
+ const stableCopySelection = (0, import_react9.useCallback)((options2) => copySelectionRef.current(options2), []);
4433
+ (0, import_react9.useEffect)(() => {
4027
4434
  onCopyActionsReady?.({ copySelection: stableCopySelection });
4028
4435
  }, [onCopyActionsReady, stableCopySelection]);
4029
4436
  return {
@@ -4157,17 +4564,74 @@ function DataTable({
4157
4564
  const RowSlot = slots?.Row ?? DataTableRow;
4158
4565
  const PendingSlot = slots?.Pending ?? DefaultPending;
4159
4566
  const EmptySlot = slots?.Empty ?? DefaultEmpty;
4160
- const freezeOffsets = rowContextValue.columnFreeze.offsets;
4161
4567
  const headerGroups = getMergedHeaderGroups(table.getHeaderGroups());
4162
4568
  const leafColumnIds = table.getVisibleLeafColumns().map((column) => column.id);
4569
+ const columnLayoutMetaSignature = table.getVisibleLeafColumns().map((column) => {
4570
+ const meta = column.columnDef.meta;
4571
+ return `${column.id}:${meta?.width ?? ""}:${meta?.minWidth ?? ""}:${meta?.maxWidth ?? ""}`;
4572
+ }).join("|");
4163
4573
  const { isReordering, draggingColumnId, dropTarget, onHeaderPointerDown } = useColumnReorder({
4164
4574
  enabled: enableColumnReorder,
4165
4575
  columnOrder: leafColumnIds,
4166
4576
  onColumnOrderChange: setColumnOrder
4167
4577
  });
4168
- const contextValue = (0, import_react9.useMemo)(
4169
- () => ({ ...rowContextValue, classNames }),
4170
- [rowContextValue, classNames]
4578
+ const [containerWidth, setContainerWidth] = (0, import_react10.useState)(0);
4579
+ (0, import_react10.useEffect)(() => {
4580
+ if (enableColumnResize || isPending) return;
4581
+ const element = scrollRef.current;
4582
+ if (!element) return;
4583
+ const updateWidth = () => {
4584
+ setContainerWidth(Math.floor(element.clientWidth));
4585
+ };
4586
+ updateWidth();
4587
+ if (typeof ResizeObserver === "undefined") return;
4588
+ const observer = new ResizeObserver(() => {
4589
+ updateWidth();
4590
+ });
4591
+ observer.observe(element);
4592
+ return () => observer.disconnect();
4593
+ }, [enableColumnResize, isPending, scrollRef, rows.length, leafColumnIds.join("|")]);
4594
+ const layoutWidths = (0, import_react10.useMemo)(() => {
4595
+ if (enableColumnResize) return void 0;
4596
+ const columns = table.getVisibleLeafColumns().map((column) => ({
4597
+ id: column.id,
4598
+ width: column.columnDef.meta?.width,
4599
+ minWidth: column.columnDef.meta?.minWidth,
4600
+ maxWidth: column.columnDef.meta?.maxWidth
4601
+ }));
4602
+ return resolveColumnLayoutWidths(containerWidth, columns);
4603
+ }, [enableColumnResize, containerWidth, table, columnLayoutMetaSignature]);
4604
+ const freezeOffsets = (0, import_react10.useMemo)(() => {
4605
+ if (!enableColumnFreeze || enableColumnResize || !layoutWidths) {
4606
+ return rowContextValue.columnFreeze.offsets;
4607
+ }
4608
+ const columns = table.getVisibleLeafColumns().map((column) => ({
4609
+ id: column.id,
4610
+ size: layoutWidths.get(column.id) ?? column.getSize(),
4611
+ side: resolveColumnFreezeSide(column.columnDef.meta?.frozen)
4612
+ }));
4613
+ return buildColumnFreezeOffsets(columns);
4614
+ }, [
4615
+ enableColumnFreeze,
4616
+ enableColumnResize,
4617
+ layoutWidths,
4618
+ rowContextValue.columnFreeze.offsets,
4619
+ table
4620
+ ]);
4621
+ const contextValue = (0, import_react10.useMemo)(
4622
+ () => ({
4623
+ ...rowContextValue,
4624
+ classNames,
4625
+ columnFreeze: {
4626
+ ...rowContextValue.columnFreeze,
4627
+ offsets: freezeOffsets
4628
+ },
4629
+ columnResize: {
4630
+ ...rowContextValue.columnResize,
4631
+ layoutWidths
4632
+ }
4633
+ }),
4634
+ [rowContextValue, classNames, freezeOffsets, layoutWidths]
4171
4635
  );
4172
4636
  if (isPending) {
4173
4637
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
@@ -4248,7 +4712,8 @@ function DataTable({
4248
4712
  force: enableColumnResize,
4249
4713
  lockMax: enableColumnResize,
4250
4714
  minWidth: header.column.columnDef.meta?.minWidth,
4251
- maxWidth: header.column.columnDef.meta?.maxWidth
4715
+ maxWidth: header.column.columnDef.meta?.maxWidth,
4716
+ layoutWidth: layoutWidths?.get(header.column.id)
4252
4717
  });
4253
4718
  const freezeOffset = enableColumnFreeze ? resolveHeaderFreezeOffset(header.column, freezeOffsets) : void 0;
4254
4719
  const freezeStyle = getColumnFreezeStyle(freezeOffset, {
@@ -4261,7 +4726,9 @@ function DataTable({
4261
4726
  };
4262
4727
  const isPlaceholder = header.isPlaceholder;
4263
4728
  const leafColumns = header.column.getLeafColumns();
4264
- const leafIds = leafColumns.map((leafColumn) => leafColumn.id);
4729
+ const leafIds = leafColumns.map(
4730
+ (leafColumn) => leafColumn.id
4731
+ );
4265
4732
  const isLeafHeader = !isPlaceholder && header.subHeaders.length === 0;
4266
4733
  const canDrag = enableColumnReorder && !isPlaceholder && leafIds.length > 0 && leafColumns.every(
4267
4734
  (leafColumn) => isColumnReorderable(leafColumn.columnDef.meta)
@@ -4417,10 +4884,10 @@ function DataTable({
4417
4884
  }
4418
4885
 
4419
4886
  // src/components/ui/table/components/Table/Table.tsx
4420
- var import_react13 = require("react");
4887
+ var import_react14 = require("react");
4421
4888
 
4422
4889
  // src/components/ui/table/features/cell-render/ResolvedTableCell.tsx
4423
- var import_react10 = require("react");
4890
+ var import_react11 = require("react");
4424
4891
  function ResolvedTableCell({
4425
4892
  info
4426
4893
  }) {
@@ -4429,7 +4896,7 @@ function ResolvedTableCell({
4429
4896
  const meta = column.columnDef.meta;
4430
4897
  const value = getValue();
4431
4898
  const columnId = column.id;
4432
- const update = (0, import_react10.useCallback)(
4899
+ const update = (0, import_react11.useCallback)(
4433
4900
  (next) => {
4434
4901
  cellRender.commitValue(row.id, columnId, next);
4435
4902
  },
@@ -4540,6 +5007,7 @@ function buildColumnDef(props, sort, onSort) {
4540
5007
  cellRender: render,
4541
5008
  frozen,
4542
5009
  reorderable,
5010
+ width,
4543
5011
  minWidth,
4544
5012
  maxWidth,
4545
5013
  className,
@@ -4587,10 +5055,10 @@ function countLeafColumns(nodes) {
4587
5055
  }
4588
5056
 
4589
5057
  // src/components/ui/table/components/Table/parseTableChildren.ts
4590
- var import_react12 = require("react");
5058
+ var import_react13 = require("react");
4591
5059
 
4592
5060
  // src/components/ui/table/components/Table/tableChildTypes.ts
4593
- var import_react11 = require("react");
5061
+ var import_react12 = require("react");
4594
5062
  var TABLE_HEADER_DISPLAY_NAME = "Table.Header";
4595
5063
  var TABLE_BODY_DISPLAY_NAME = "Table.Body";
4596
5064
  var TABLE_COLUMN_DISPLAY_NAME = "Table.Column";
@@ -4603,19 +5071,19 @@ function getComponentDisplayName(type) {
4603
5071
  return void 0;
4604
5072
  }
4605
5073
  function isTableHeaderElement(child) {
4606
- return (0, import_react11.isValidElement)(child) && getComponentDisplayName(child.type) === TABLE_HEADER_DISPLAY_NAME;
5074
+ return (0, import_react12.isValidElement)(child) && getComponentDisplayName(child.type) === TABLE_HEADER_DISPLAY_NAME;
4607
5075
  }
4608
5076
  function isTableBodyElement(child) {
4609
- return (0, import_react11.isValidElement)(child) && getComponentDisplayName(child.type) === TABLE_BODY_DISPLAY_NAME;
5077
+ return (0, import_react12.isValidElement)(child) && getComponentDisplayName(child.type) === TABLE_BODY_DISPLAY_NAME;
4610
5078
  }
4611
5079
  function isTableColumnElement(child) {
4612
- return (0, import_react11.isValidElement)(child) && getComponentDisplayName(child.type) === TABLE_COLUMN_DISPLAY_NAME;
5080
+ return (0, import_react12.isValidElement)(child) && getComponentDisplayName(child.type) === TABLE_COLUMN_DISPLAY_NAME;
4613
5081
  }
4614
5082
  function isTableColumnGroupElement(child) {
4615
- return (0, import_react11.isValidElement)(child) && getComponentDisplayName(child.type) === TABLE_COLUMN_GROUP_DISPLAY_NAME;
5083
+ return (0, import_react12.isValidElement)(child) && getComponentDisplayName(child.type) === TABLE_COLUMN_GROUP_DISPLAY_NAME;
4616
5084
  }
4617
5085
  function isTablePaginationElement(child) {
4618
- return (0, import_react11.isValidElement)(child) && getComponentDisplayName(child.type) === TABLE_PAGINATION_DISPLAY_NAME;
5086
+ return (0, import_react12.isValidElement)(child) && getComponentDisplayName(child.type) === TABLE_PAGINATION_DISPLAY_NAME;
4619
5087
  }
4620
5088
 
4621
5089
  // src/components/ui/table/components/Table/parseTableChildren.ts
@@ -4625,7 +5093,7 @@ function parseTableChildren(children) {
4625
5093
  body: null,
4626
5094
  pagination: null
4627
5095
  };
4628
- for (const child of import_react12.Children.toArray(children)) {
5096
+ for (const child of import_react13.Children.toArray(children)) {
4629
5097
  if (isTableHeaderElement(child)) {
4630
5098
  slots.header = child;
4631
5099
  continue;
@@ -4642,7 +5110,7 @@ function parseTableChildren(children) {
4642
5110
  }
4643
5111
  function walkColumnTreeNodes(children) {
4644
5112
  const result = [];
4645
- for (const child of import_react12.Children.toArray(children)) {
5113
+ for (const child of import_react13.Children.toArray(children)) {
4646
5114
  if (isTableColumnElement(child)) {
4647
5115
  result.push({
4648
5116
  type: "leaf",
@@ -4659,7 +5127,7 @@ function walkColumnTreeNodes(children) {
4659
5127
  });
4660
5128
  continue;
4661
5129
  }
4662
- if ((0, import_react12.isValidElement)(child)) {
5130
+ if ((0, import_react13.isValidElement)(child)) {
4663
5131
  const nested = child.props.children;
4664
5132
  if (nested != null) {
4665
5133
  result.push(...walkColumnTreeNodes(nested));
@@ -4785,12 +5253,12 @@ function TableRoot({
4785
5253
  filteredCount,
4786
5254
  ...dataTableProps
4787
5255
  }) {
4788
- const { header, pagination: paginationElement } = (0, import_react13.useMemo)(
5256
+ const { header, pagination: paginationElement } = (0, import_react14.useMemo)(
4789
5257
  () => parseTableChildren(children),
4790
5258
  [children]
4791
5259
  );
4792
- const [sort, setSort] = (0, import_react13.useState)(null);
4793
- const handleSort = (0, import_react13.useCallback)((field) => {
5260
+ const [sort, setSort] = (0, import_react14.useState)(null);
5261
+ const handleSort = (0, import_react14.useCallback)((field) => {
4794
5262
  setSort((previous) => {
4795
5263
  if (previous?.field !== field) {
4796
5264
  return { field, direction: "asc" };
@@ -4801,8 +5269,8 @@ function TableRoot({
4801
5269
  return null;
4802
5270
  });
4803
5271
  }, []);
4804
- const columnTree = (0, import_react13.useMemo)(() => extractColumnTree(header), [header]);
4805
- const columns = (0, import_react13.useMemo)(
5272
+ const columnTree = (0, import_react14.useMemo)(() => extractColumnTree(header), [header]);
5273
+ const columns = (0, import_react14.useMemo)(
4806
5274
  () => buildColumnDefsFromTree(columnTree, sort, handleSort),
4807
5275
  [columnTree, sort, handleSort]
4808
5276
  );
@@ -4810,7 +5278,7 @@ function TableRoot({
4810
5278
  const pageSize = paginationProps?.pageSize ?? 10;
4811
5279
  const page = paginationProps?.page ?? 1;
4812
5280
  const resolvedTotalCount = paginationProps?.totalCount ?? totalCount ?? data.length;
4813
- const tableData = (0, import_react13.useMemo)(() => {
5281
+ const tableData = (0, import_react14.useMemo)(() => {
4814
5282
  const sortedData = sortTableData(data, sort);
4815
5283
  if (!paginationProps) return sortedData;
4816
5284
  return paginateTableData(sortedData, page, pageSize);