react-glide-table 1.4.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/compound.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // src/components/ui/table/components/DataTable/DataTable.tsx
2
2
  import { flexRender as flexRender2 } from "@tanstack/react-table";
3
- import { useMemo as useMemo3 } from "react";
3
+ import { useMemo as useMemo4 } from "react";
4
4
 
5
5
  // src/components/ui/table/components/DataTable/DataTableRow.tsx
6
6
  import { flexRender } from "@tanstack/react-table";
@@ -103,6 +103,36 @@ function getCellSelectionBounds(start, end) {
103
103
  endCol: Math.max(start.col, end.col)
104
104
  };
105
105
  }
106
+ function getCellNavigationDelta(key) {
107
+ switch (key) {
108
+ case "ArrowUp":
109
+ case "w":
110
+ case "W":
111
+ return { row: -1, col: 0 };
112
+ case "ArrowDown":
113
+ case "s":
114
+ case "S":
115
+ return { row: 1, col: 0 };
116
+ case "ArrowLeft":
117
+ case "a":
118
+ case "A":
119
+ return { row: 0, col: -1 };
120
+ case "ArrowRight":
121
+ case "d":
122
+ case "D":
123
+ return { row: 0, col: 1 };
124
+ default:
125
+ return null;
126
+ }
127
+ }
128
+ function clampCellPosition(position, rowCount, columnCount) {
129
+ const maxRow = Math.max(rowCount - 1, 0);
130
+ const maxCol = Math.max(columnCount - 1, 0);
131
+ return {
132
+ row: Math.min(Math.max(position.row, 0), maxRow),
133
+ col: Math.min(Math.max(position.col, 0), maxCol)
134
+ };
135
+ }
106
136
  function measureMergedSpanRowHeights(rowIndex, rowSpan, cellElement) {
107
137
  if (rowSpan <= 1) return void 0;
108
138
  const tbody = cellElement?.closest("tbody") ?? (typeof document !== "undefined" ? document.querySelector("tbody.data-table-body") : null);
@@ -456,6 +486,162 @@ function getColumnSizeStyle(size, options) {
456
486
  };
457
487
  }
458
488
 
489
+ // src/components/ui/table/features/inline-search/inlineSearch.ts
490
+ var INLINE_SEARCH_MAX_RESULTS = 1e3;
491
+ var INLINE_SEARCH_TARGET_TICK_MS = 10;
492
+ var INLINE_SEARCH_INITIAL_STRIDE = 10;
493
+ function escapeSearchRegex(value) {
494
+ return value.replace(/([$()*+.?[\\\]^{|}-])/g, "\\$1");
495
+ }
496
+ function createSearchRegex(query) {
497
+ const trimmed = query.trim();
498
+ if (!trimmed) return null;
499
+ return new RegExp(escapeSearchRegex(trimmed), "i");
500
+ }
501
+ function cellValueToSearchText(value) {
502
+ if (value == null) return void 0;
503
+ if (typeof value === "string") return value;
504
+ if (typeof value === "number" || typeof value === "boolean") {
505
+ return String(value);
506
+ }
507
+ if (Array.isArray(value)) {
508
+ return value.map((item) => cellValueToSearchText(item) ?? "").join(" ");
509
+ }
510
+ if (typeof value === "object") {
511
+ try {
512
+ return JSON.stringify(value);
513
+ } catch {
514
+ return String(value);
515
+ }
516
+ }
517
+ return String(value);
518
+ }
519
+ function formatSearchResultLabel(status) {
520
+ const countLabel = status.results >= INLINE_SEARCH_MAX_RESULTS ? `over ${INLINE_SEARCH_MAX_RESULTS}` : `${status.results} result${status.results !== 1 ? "s" : ""}`;
521
+ if (status.selectedIndex >= 0 && status.results > 0) {
522
+ return `${status.selectedIndex + 1} of ${countLabel}`;
523
+ }
524
+ return countLabel;
525
+ }
526
+ function nextSearchIndex(selectedIndex, results) {
527
+ if (results <= 0) return -1;
528
+ if (selectedIndex < 0) return 0;
529
+ return (selectedIndex + 1) % results;
530
+ }
531
+ function previousSearchIndex(selectedIndex, results) {
532
+ if (results <= 0) return -1;
533
+ if (selectedIndex < 0) return results - 1;
534
+ let next = (selectedIndex - 1) % results;
535
+ if (next < 0) next += results;
536
+ return next;
537
+ }
538
+ function buildSearchMatchKey(colIndex, rowIndex) {
539
+ return `${colIndex}:${rowIndex}`;
540
+ }
541
+ function buildSearchMatchKeys(results) {
542
+ const keys = /* @__PURE__ */ new Set();
543
+ for (const [colIndex, rowIndex] of results) {
544
+ keys.add(buildSearchMatchKey(colIndex, rowIndex));
545
+ }
546
+ return keys;
547
+ }
548
+ function collectSearchMatchesInRange(options) {
549
+ const {
550
+ query,
551
+ startRow,
552
+ rowCount,
553
+ columnCount,
554
+ getCellValue,
555
+ maxResults = INLINE_SEARCH_MAX_RESULTS
556
+ } = options;
557
+ const regex = createSearchRegex(query);
558
+ if (!regex || rowCount <= 0 || columnCount <= 0) return [];
559
+ const matches = [];
560
+ for (let rowOffset = 0; rowOffset < rowCount; rowOffset += 1) {
561
+ const rowIndex = startRow + rowOffset;
562
+ for (let colIndex = 0; colIndex < columnCount; colIndex += 1) {
563
+ const text = cellValueToSearchText(getCellValue(rowIndex, colIndex));
564
+ if (text !== void 0 && regex.test(text)) {
565
+ matches.push([colIndex, rowIndex]);
566
+ if (matches.length >= maxResults) {
567
+ return matches;
568
+ }
569
+ }
570
+ }
571
+ }
572
+ return matches;
573
+ }
574
+ function nextSearchStride(currentStride, elapsedMs, targetMs = INLINE_SEARCH_TARGET_TICK_MS) {
575
+ const rounded = Math.max(elapsedMs, 1);
576
+ const scalar = targetMs / rounded;
577
+ return Math.max(1, Math.ceil(currentStride * scalar));
578
+ }
579
+ function buildFlatSearchCorpus(rows, getRowId) {
580
+ return rows.map((data, index) => ({
581
+ id: getRowId(data, index),
582
+ data,
583
+ ancestorToggleKeys: []
584
+ }));
585
+ }
586
+ function buildTreeSearchCorpus(visibleRows, options) {
587
+ const { toggleField, getRowId } = options;
588
+ const corpus = [];
589
+ const seen = /* @__PURE__ */ new Set();
590
+ const walk = (node, ancestorToggleKeys) => {
591
+ const id = getRowId(node, corpus.length);
592
+ if (seen.has(id)) return;
593
+ seen.add(id);
594
+ corpus.push({
595
+ id,
596
+ data: node,
597
+ ancestorToggleKeys
598
+ });
599
+ const children = node.children;
600
+ if (!Array.isArray(children) || children.length === 0) return;
601
+ const toggleValue = node[toggleField];
602
+ const childAncestors = typeof toggleValue === "string" && toggleValue.length > 0 ? [...ancestorToggleKeys, toggleValue] : ancestorToggleKeys;
603
+ for (const child of children) {
604
+ if (child && typeof child === "object") {
605
+ walk(child, childAncestors);
606
+ }
607
+ }
608
+ };
609
+ for (const row of visibleRows) {
610
+ const level = row.level;
611
+ if (level === 0 || level === void 0) {
612
+ walk(row, []);
613
+ }
614
+ }
615
+ for (const row of visibleRows) {
616
+ const id = getRowId(row, corpus.length);
617
+ if (seen.has(id)) continue;
618
+ walk(row, []);
619
+ }
620
+ return corpus;
621
+ }
622
+ function mapSearchResultsToVisibleKeys(results, corpus, visibleRowIndexById) {
623
+ const keys = /* @__PURE__ */ new Set();
624
+ for (const [colIndex, corpusRowIndex] of results) {
625
+ const corpusRow = corpus[corpusRowIndex];
626
+ if (!corpusRow) continue;
627
+ const visibleRowIndex = visibleRowIndexById.get(corpusRow.id);
628
+ if (visibleRowIndex === void 0) continue;
629
+ keys.add(buildSearchMatchKey(colIndex, visibleRowIndex));
630
+ }
631
+ return keys;
632
+ }
633
+ function mapSearchResultToVisibleItem(item, corpus, visibleRowIndexById) {
634
+ const [colIndex, corpusRowIndex] = item;
635
+ const corpusRow = corpus[corpusRowIndex];
636
+ if (!corpusRow) return null;
637
+ const visibleRowIndex = visibleRowIndexById.get(corpusRow.id);
638
+ if (visibleRowIndex === void 0) return null;
639
+ return [colIndex, visibleRowIndex];
640
+ }
641
+ function collectAncestorKeysToExpand(corpusRow, expandedRows) {
642
+ return corpusRow.ancestorToggleKeys.filter((key) => !expandedRows.has(key));
643
+ }
644
+
459
645
  // src/components/ui/table/features/row-expand/row-expand.ts
460
646
  import { useEffect, useMemo, useRef } from "react";
461
647
 
@@ -901,10 +1087,16 @@ function DataTableRow({
901
1087
  cellEdit,
902
1088
  expand,
903
1089
  columnResize,
904
- columnFreeze
1090
+ columnFreeze,
1091
+ inlineSearch
905
1092
  } = useDataTableRowContext();
906
1093
  const { enableColumnResize } = columnResize;
907
1094
  const { enableColumnFreeze, offsets: freezeOffsets } = columnFreeze;
1095
+ const {
1096
+ enabled: enableInlineSearch,
1097
+ matchKeys: searchMatchKeys,
1098
+ activeMatch
1099
+ } = inlineSearch;
908
1100
  const {
909
1101
  enableRowSpan,
910
1102
  primaryRowSpanColumnId,
@@ -1096,17 +1288,25 @@ function DataTableRow({
1096
1288
  ...freezeStyle,
1097
1289
  ...selectionEdgeStyle
1098
1290
  };
1291
+ const searchMatchKey = buildSearchMatchKey(cellIndex, rowIndex);
1292
+ const isSearchMatch = enableInlineSearch && searchMatchKeys.has(searchMatchKey);
1293
+ const isSearchActive = isSearchMatch && activeMatch !== null && activeMatch[0] === cellIndex && activeMatch[1] === rowIndex;
1099
1294
  return /* @__PURE__ */ jsxs2(
1100
1295
  "td",
1101
1296
  {
1297
+ "data-row-index": rowIndex,
1298
+ "data-col-index": cellIndex,
1102
1299
  rowSpan: rowSpanInfo && rowSpanInfo.rowSpan > 1 ? rowSpanInfo.rowSpan : void 0,
1103
1300
  "data-merged": isMerged && cellIndex > 0 ? "" : void 0,
1104
1301
  "data-merged-edge-right": showMergedRightEdge ? "" : void 0,
1105
1302
  "data-merged-row-first": isMerged && cellIndex === 0 && showMergedRightEdge ? "" : void 0,
1303
+ "data-selected": !enableRowSpan && showCellSelected ? "" : void 0,
1106
1304
  "data-group-selected": enableRowSpan && showCellSelected ? "" : void 0,
1107
1305
  "data-group-hovered": enableRowSpan && showCellHover && !showCellSelected ? "" : void 0,
1108
1306
  "data-selection-fill": isCellDragSelected ? "" : void 0,
1109
1307
  "data-selection-edges": hasSelectionEdges ? "" : void 0,
1308
+ "data-search-match": isSearchMatch ? "" : void 0,
1309
+ "data-search-active": isSearchActive ? "" : void 0,
1110
1310
  "data-editable": editable ? "" : void 0,
1111
1311
  "data-editing": isEditing ? "" : void 0,
1112
1312
  "data-frozen": freezeOffset?.side,
@@ -1121,7 +1321,8 @@ function DataTableRow({
1121
1321
  event.preventDefault();
1122
1322
  onCellMouseDown(
1123
1323
  resolveCellRowIndex(event.clientY, event.currentTarget),
1124
- cellIndex
1324
+ cellIndex,
1325
+ { shiftKey: event.shiftKey }
1125
1326
  );
1126
1327
  },
1127
1328
  onMouseEnter: (event) => {
@@ -1158,6 +1359,8 @@ function DataTableRow({
1158
1359
  enableRowSpan && showCellHover && !showCellSelected && "is-group-hovered",
1159
1360
  isCellDragSelected && CELL_SELECTION_FILL_CLASS,
1160
1361
  hasSelectionEdges && CELL_SELECTION_EDGES_CLASS,
1362
+ isSearchMatch && "is-search-match",
1363
+ isSearchActive && "is-search-active",
1161
1364
  editable && "is-editable",
1162
1365
  classNames?.cell
1163
1366
  ),
@@ -1292,8 +1495,169 @@ function DataTableRow({
1292
1495
  );
1293
1496
  }
1294
1497
 
1498
+ // src/components/ui/table/components/DataTable/DataTableSearch.tsx
1499
+ import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
1500
+ function SearchCloseIcon({ className }) {
1501
+ return /* @__PURE__ */ jsxs3(
1502
+ "svg",
1503
+ {
1504
+ className,
1505
+ "aria-hidden": true,
1506
+ width: "16",
1507
+ height: "16",
1508
+ viewBox: "0 0 24 24",
1509
+ fill: "none",
1510
+ stroke: "currentColor",
1511
+ strokeWidth: "2",
1512
+ strokeLinecap: "round",
1513
+ strokeLinejoin: "round",
1514
+ children: [
1515
+ /* @__PURE__ */ jsx4("path", { d: "M18 6 6 18" }),
1516
+ /* @__PURE__ */ jsx4("path", { d: "m6 6 12 12" })
1517
+ ]
1518
+ }
1519
+ );
1520
+ }
1521
+ function DataTableSearch({
1522
+ showSearch,
1523
+ searchValue,
1524
+ searchStatus,
1525
+ searchInputId,
1526
+ searchInputRef,
1527
+ canClose,
1528
+ placeholder,
1529
+ resultHint,
1530
+ previousLabel,
1531
+ nextLabel,
1532
+ closeLabel,
1533
+ rowsTotal,
1534
+ classNames,
1535
+ onSearchValueChange,
1536
+ onClose,
1537
+ onNext,
1538
+ onPrevious
1539
+ }) {
1540
+ if (!showSearch) return null;
1541
+ const resultString = searchStatus ? formatSearchResultLabel(searchStatus) : resultHint;
1542
+ const progress = rowsTotal > 0 ? Math.floor((searchStatus?.rowsSearched ?? 0) / rowsTotal * 100) : 0;
1543
+ const handleKeyDown = (event) => {
1544
+ if ((event.ctrlKey || event.metaKey) && event.code === "KeyF" || event.key === "Escape") {
1545
+ event.preventDefault();
1546
+ event.stopPropagation();
1547
+ if (canClose) {
1548
+ onClose();
1549
+ }
1550
+ return;
1551
+ }
1552
+ if (event.key === "ArrowDown" || event.key === "Enter" && !event.shiftKey) {
1553
+ event.preventDefault();
1554
+ onNext();
1555
+ return;
1556
+ }
1557
+ if (event.key === "ArrowUp" || event.key === "Enter" && event.shiftKey) {
1558
+ event.preventDefault();
1559
+ onPrevious();
1560
+ }
1561
+ };
1562
+ return /* @__PURE__ */ jsxs3(
1563
+ "div",
1564
+ {
1565
+ className: cn("data-table-search", classNames?.search),
1566
+ role: "search",
1567
+ onMouseDown: (event) => event.stopPropagation(),
1568
+ children: [
1569
+ /* @__PURE__ */ jsxs3("div", { className: "data-table-search-row", children: [
1570
+ /* @__PURE__ */ jsx4(
1571
+ "input",
1572
+ {
1573
+ ref: searchInputRef,
1574
+ id: searchInputId,
1575
+ type: "search",
1576
+ value: searchValue,
1577
+ placeholder,
1578
+ autoComplete: "off",
1579
+ spellCheck: false,
1580
+ "aria-label": placeholder,
1581
+ className: cn("data-table-search-input", classNames?.searchInput),
1582
+ onChange: (event) => onSearchValueChange(event.target.value),
1583
+ onKeyDown: handleKeyDown
1584
+ }
1585
+ ),
1586
+ /* @__PURE__ */ jsx4(
1587
+ "button",
1588
+ {
1589
+ type: "button",
1590
+ "aria-label": previousLabel,
1591
+ className: cn("data-table-search-button", classNames?.searchButton),
1592
+ onClick: (event) => {
1593
+ event.stopPropagation();
1594
+ onPrevious();
1595
+ },
1596
+ children: /* @__PURE__ */ jsx4(ChevronUp, { className: "data-table-search-icon" })
1597
+ }
1598
+ ),
1599
+ /* @__PURE__ */ jsx4(
1600
+ "button",
1601
+ {
1602
+ type: "button",
1603
+ "aria-label": nextLabel,
1604
+ className: cn("data-table-search-button", classNames?.searchButton),
1605
+ onClick: (event) => {
1606
+ event.stopPropagation();
1607
+ onNext();
1608
+ },
1609
+ children: /* @__PURE__ */ jsx4(ChevronDown, { className: "data-table-search-icon" })
1610
+ }
1611
+ ),
1612
+ canClose ? /* @__PURE__ */ jsx4(
1613
+ "button",
1614
+ {
1615
+ type: "button",
1616
+ "aria-label": closeLabel,
1617
+ className: cn("data-table-search-button", classNames?.searchButton),
1618
+ onClick: (event) => {
1619
+ event.stopPropagation();
1620
+ onClose();
1621
+ },
1622
+ children: /* @__PURE__ */ jsx4(SearchCloseIcon, { className: "data-table-search-icon" })
1623
+ }
1624
+ ) : null
1625
+ ] }),
1626
+ /* @__PURE__ */ jsx4(
1627
+ "div",
1628
+ {
1629
+ className: cn("data-table-search-status", classNames?.searchStatus),
1630
+ "aria-live": "polite",
1631
+ children: resultString
1632
+ }
1633
+ ),
1634
+ searchStatus !== void 0 ? /* @__PURE__ */ jsx4(
1635
+ "div",
1636
+ {
1637
+ className: cn(
1638
+ "data-table-search-progress",
1639
+ classNames?.searchProgress
1640
+ ),
1641
+ role: "progressbar",
1642
+ "aria-valuemin": 0,
1643
+ "aria-valuemax": 100,
1644
+ "aria-valuenow": progress,
1645
+ children: /* @__PURE__ */ jsx4(
1646
+ "div",
1647
+ {
1648
+ className: "data-table-search-progress-bar",
1649
+ style: { width: `${progress}%` }
1650
+ }
1651
+ )
1652
+ }
1653
+ ) : null
1654
+ ]
1655
+ }
1656
+ );
1657
+ }
1658
+
1295
1659
  // src/components/ui/table/components/DataTable/DataTableToolbar.tsx
1296
- import { Fragment, jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
1660
+ import { Fragment, jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
1297
1661
  function DataTableToolbar({
1298
1662
  filteredCount,
1299
1663
  totalCount,
@@ -1311,20 +1675,20 @@ function DataTableToolbar({
1311
1675
  const selectionContent = selectionLabel?.(selectedCount) ?? null;
1312
1676
  const hasSelectionContent = selectionContent !== null && selectionContent !== false && selectionContent !== void 0 && typeof selectionContent !== "boolean";
1313
1677
  if (!hasLeftContent && !hasToolbar && !hasSelectionContent) return null;
1314
- return /* @__PURE__ */ jsxs3("div", { className: cn("DataTableToolbarJSX", classNames?.toolbar, className), children: [
1315
- /* @__PURE__ */ jsxs3("div", { className: cn("toolbar-left", classNames?.toolbarLeft), children: [
1316
- hasCount && /* @__PURE__ */ jsx4("span", { className: cn("toolbar-count", classNames?.toolbarCount), children: displayFiltered !== void 0 && totalCount !== void 0 ? /* @__PURE__ */ jsxs3(Fragment, { children: [
1317
- /* @__PURE__ */ jsx4("span", { className: "toolbar-count-primary", children: displayFiltered }),
1318
- /* @__PURE__ */ jsxs3("span", { className: "toolbar-count-placeholder", children: [
1678
+ return /* @__PURE__ */ jsxs4("div", { className: cn("DataTableToolbarJSX", classNames?.toolbar, className), children: [
1679
+ /* @__PURE__ */ jsxs4("div", { className: cn("toolbar-left", classNames?.toolbarLeft), children: [
1680
+ hasCount && /* @__PURE__ */ jsx5("span", { className: cn("toolbar-count", classNames?.toolbarCount), children: displayFiltered !== void 0 && totalCount !== void 0 ? /* @__PURE__ */ jsxs4(Fragment, { children: [
1681
+ /* @__PURE__ */ jsx5("span", { className: "toolbar-count-primary", children: displayFiltered }),
1682
+ /* @__PURE__ */ jsxs4("span", { className: "toolbar-count-placeholder", children: [
1319
1683
  " / ",
1320
1684
  totalCount
1321
1685
  ] })
1322
- ] }) : /* @__PURE__ */ jsx4("span", { className: "toolbar-count-primary", children: displayFiltered ?? totalCount }) }),
1686
+ ] }) : /* @__PURE__ */ jsx5("span", { className: "toolbar-count-primary", children: displayFiltered ?? totalCount }) }),
1323
1687
  summary
1324
1688
  ] }),
1325
- /* @__PURE__ */ jsxs3("div", { className: cn("toolbar-right", classNames?.toolbarRight), children: [
1326
- hasSelectionContent && (typeof selectionContent === "string" || typeof selectionContent === "number" ? /* @__PURE__ */ jsx4("span", { className: cn("toolbar-selection", classNames?.toolbarSelection), children: selectionContent }) : selectionContent),
1327
- hasToolbar && /* @__PURE__ */ jsx4("div", { className: cn("toolbar-actions", classNames?.toolbarActions), children: toolbar })
1689
+ /* @__PURE__ */ jsxs4("div", { className: cn("toolbar-right", classNames?.toolbarRight), children: [
1690
+ hasSelectionContent && (typeof selectionContent === "string" || typeof selectionContent === "number" ? /* @__PURE__ */ jsx5("span", { className: cn("toolbar-selection", classNames?.toolbarSelection), children: selectionContent }) : selectionContent),
1691
+ hasToolbar && /* @__PURE__ */ jsx5("div", { className: cn("toolbar-actions", classNames?.toolbarActions), children: toolbar })
1328
1692
  ] })
1329
1693
  ] });
1330
1694
  }
@@ -1338,11 +1702,11 @@ import {
1338
1702
  useVirtualizer
1339
1703
  } from "@tanstack/react-virtual";
1340
1704
  import {
1341
- useCallback as useCallback3,
1342
- useEffect as useEffect5,
1343
- useMemo as useMemo2,
1344
- useRef as useRef5,
1345
- useState as useState3
1705
+ useCallback as useCallback4,
1706
+ useEffect as useEffect6,
1707
+ useMemo as useMemo3,
1708
+ useRef as useRef6,
1709
+ useState as useState4
1346
1710
  } from "react";
1347
1711
 
1348
1712
  // src/components/ui/table/features/cell-edit/useCellEdit.ts
@@ -1671,26 +2035,44 @@ function useCellSelection({
1671
2035
  data,
1672
2036
  rows,
1673
2037
  enabled = true,
2038
+ columnCount = 0,
1674
2039
  enableSubtreeCopy = false,
1675
2040
  enableInsertPaste = true,
1676
2041
  onDataChange,
1677
2042
  onBatchChange,
1678
- onRowsPaste
2043
+ onRowsPaste,
2044
+ onCellNavigate
1679
2045
  }) {
1680
2046
  const [dragState, setDragState] = useState2(INITIAL_DRAG_STATE);
1681
2047
  const pendingPasteModeRef = useRef4(null);
2048
+ const dragStateRef = useRef4(dragState);
2049
+ const onCellNavigateRef = useRef4(onCellNavigate);
2050
+ dragStateRef.current = dragState;
2051
+ onCellNavigateRef.current = onCellNavigate;
1682
2052
  const cellSelectionBounds = getCellSelectionBounds(dragState.start, dragState.end);
1683
2053
  const activeSelectionBounds = enabled ? getActiveSelectionBounds(dragState, cellSelectionBounds) : null;
1684
2054
  const handleCellMouseDown = useCallback2(
1685
- (rowIndex, colIndex) => {
2055
+ (rowIndex, colIndex, options) => {
1686
2056
  if (!enabled) return;
1687
- setDragState({
1688
- isSelecting: true,
1689
- isFillDragging: false,
1690
- start: { row: rowIndex, col: colIndex },
1691
- end: { row: rowIndex, col: colIndex },
1692
- fillAnchor: null,
1693
- fillEnd: null
2057
+ setDragState((prev) => {
2058
+ if (options?.shiftKey && prev.start) {
2059
+ return {
2060
+ ...prev,
2061
+ isSelecting: true,
2062
+ isFillDragging: false,
2063
+ end: { row: rowIndex, col: colIndex },
2064
+ fillAnchor: null,
2065
+ fillEnd: null
2066
+ };
2067
+ }
2068
+ return {
2069
+ isSelecting: true,
2070
+ isFillDragging: false,
2071
+ start: { row: rowIndex, col: colIndex },
2072
+ end: { row: rowIndex, col: colIndex },
2073
+ fillAnchor: null,
2074
+ fillEnd: null
2075
+ };
1694
2076
  });
1695
2077
  },
1696
2078
  [enabled]
@@ -1732,6 +2114,53 @@ function useCellSelection({
1732
2114
  setDragState(INITIAL_DRAG_STATE);
1733
2115
  }
1734
2116
  }, [enabled]);
2117
+ useEffect4(() => {
2118
+ if (!enabled) return;
2119
+ const handleKeyDown = (e) => {
2120
+ if (e.ctrlKey || e.metaKey || e.altKey) return;
2121
+ if (isEditablePasteTarget(e.target) || isEditablePasteTarget(document.activeElement)) {
2122
+ return;
2123
+ }
2124
+ const delta = getCellNavigationDelta(e.key);
2125
+ if (!delta) return;
2126
+ const prev = dragStateRef.current;
2127
+ if (!prev.start || !prev.end) return;
2128
+ if (prev.isSelecting || prev.isFillDragging) return;
2129
+ const rowCount = rows.length;
2130
+ const resolvedColumnCount = columnCount > 0 ? columnCount : rows[0]?.getVisibleCells().length ?? 0;
2131
+ if (rowCount <= 0 || resolvedColumnCount <= 0) return;
2132
+ const nextEnd = clampCellPosition(
2133
+ {
2134
+ row: prev.end.row + delta.row,
2135
+ col: prev.end.col + delta.col
2136
+ },
2137
+ rowCount,
2138
+ resolvedColumnCount
2139
+ );
2140
+ if (nextEnd.row === prev.end.row && nextEnd.col === prev.end.col) return;
2141
+ e.preventDefault();
2142
+ const nextState = e.shiftKey ? {
2143
+ ...prev,
2144
+ isSelecting: false,
2145
+ isFillDragging: false,
2146
+ end: nextEnd,
2147
+ fillAnchor: null,
2148
+ fillEnd: null
2149
+ } : {
2150
+ isSelecting: false,
2151
+ isFillDragging: false,
2152
+ start: nextEnd,
2153
+ end: nextEnd,
2154
+ fillAnchor: null,
2155
+ fillEnd: null
2156
+ };
2157
+ dragStateRef.current = nextState;
2158
+ setDragState(nextState);
2159
+ onCellNavigateRef.current?.(nextEnd);
2160
+ };
2161
+ window.addEventListener("keydown", handleKeyDown);
2162
+ return () => window.removeEventListener("keydown", handleKeyDown);
2163
+ }, [columnCount, enabled, rows]);
1735
2164
  const copySelection = useCallback2(
1736
2165
  async (options) => {
1737
2166
  if (!enabled || !activeSelectionBounds) return false;
@@ -1889,6 +2318,311 @@ function useCellSelection({
1889
2318
  };
1890
2319
  }
1891
2320
 
2321
+ // src/components/ui/table/features/inline-search/useInlineSearch.ts
2322
+ import {
2323
+ useCallback as useCallback3,
2324
+ useEffect as useEffect5,
2325
+ useId,
2326
+ useMemo as useMemo2,
2327
+ useRef as useRef5,
2328
+ useState as useState3
2329
+ } from "react";
2330
+ var EMPTY_MATCH_KEYS = /* @__PURE__ */ new Set();
2331
+ function useInlineSearch({
2332
+ enabled = false,
2333
+ rowCount,
2334
+ columnCount,
2335
+ getCellValue,
2336
+ initialStartRow = 0,
2337
+ showSearch: controlledShowSearch,
2338
+ searchValue: controlledSearchValue,
2339
+ searchResults: controlledSearchResults,
2340
+ onSearchValueChange,
2341
+ onSearchClose,
2342
+ onSearchResultsChanged,
2343
+ onNavigateToResult,
2344
+ rootRef
2345
+ }) {
2346
+ const searchInputId = useId();
2347
+ const searchInputRef = useRef5(null);
2348
+ const [internalShowSearch, setInternalShowSearch] = useState3(false);
2349
+ const [internalSearchValue, setInternalSearchValue] = useState3("");
2350
+ const [internalResults, setInternalResults] = useState3(
2351
+ []
2352
+ );
2353
+ const [searchStatus, setSearchStatus] = useState3();
2354
+ const searchStatusRef = useRef5(searchStatus);
2355
+ searchStatusRef.current = searchStatus;
2356
+ const abortControllerRef = useRef5(null);
2357
+ const searchHandleRef = useRef5(void 0);
2358
+ const initialStartRowRef = useRef5(initialStartRow);
2359
+ initialStartRowRef.current = initialStartRow;
2360
+ const getCellValueRef = useRef5(getCellValue);
2361
+ getCellValueRef.current = getCellValue;
2362
+ const showSearch = controlledShowSearch ?? internalShowSearch;
2363
+ const searchValue = controlledSearchValue ?? internalSearchValue;
2364
+ const searchResults = controlledSearchResults ?? internalResults;
2365
+ const setSearchValue = useCallback3(
2366
+ (value) => {
2367
+ setInternalSearchValue(value);
2368
+ onSearchValueChange?.(value);
2369
+ },
2370
+ [onSearchValueChange]
2371
+ );
2372
+ const cancelSearch = useCallback3(() => {
2373
+ if (searchHandleRef.current !== void 0) {
2374
+ window.cancelAnimationFrame(searchHandleRef.current);
2375
+ searchHandleRef.current = void 0;
2376
+ }
2377
+ abortControllerRef.current?.abort();
2378
+ }, []);
2379
+ const emitResultsChanged = useCallback3(
2380
+ (results, navIndex) => {
2381
+ onSearchResultsChanged?.(results, navIndex);
2382
+ },
2383
+ [onSearchResultsChanged]
2384
+ );
2385
+ const navigateToIndex = useCallback3(
2386
+ (results, navIndex) => {
2387
+ if (onSearchResultsChanged) return;
2388
+ if (navIndex < 0 || navIndex >= results.length) return;
2389
+ const item = results[navIndex];
2390
+ if (!item) return;
2391
+ onNavigateToResult?.(item);
2392
+ },
2393
+ [onNavigateToResult, onSearchResultsChanged]
2394
+ );
2395
+ const beginSearch = useCallback3(
2396
+ (query) => {
2397
+ if (controlledSearchResults !== void 0) return;
2398
+ const totalRows = rowCount;
2399
+ if (totalRows === 0 || columnCount === 0) {
2400
+ setSearchStatus(void 0);
2401
+ setInternalResults([]);
2402
+ emitResultsChanged([], -1);
2403
+ return;
2404
+ }
2405
+ let startY = Math.min(
2406
+ Math.max(0, initialStartRowRef.current),
2407
+ totalRows - 1
2408
+ );
2409
+ let searchStride = Math.min(INLINE_SEARCH_INITIAL_STRIDE, totalRows);
2410
+ let rowsSearched = 0;
2411
+ const runningResult = [];
2412
+ setSearchStatus(void 0);
2413
+ setInternalResults([]);
2414
+ const tick = () => {
2415
+ if (abortControllerRef.current?.signal.aborted) return;
2416
+ const tStart = performance.now();
2417
+ const rowsLeft = totalRows - rowsSearched;
2418
+ const height = Math.min(searchStride, rowsLeft, totalRows - startY);
2419
+ if (height <= 0) {
2420
+ return;
2421
+ }
2422
+ const chunk = collectSearchMatchesInRange({
2423
+ query,
2424
+ startRow: startY,
2425
+ rowCount: height,
2426
+ columnCount,
2427
+ getCellValue: (rowIndex, colIndex) => getCellValueRef.current(rowIndex, colIndex),
2428
+ maxResults: INLINE_SEARCH_MAX_RESULTS - runningResult.length
2429
+ });
2430
+ if (chunk.length > 0) {
2431
+ runningResult.push(...chunk);
2432
+ setInternalResults([...runningResult]);
2433
+ }
2434
+ rowsSearched += height;
2435
+ const selectedIndex = searchStatusRef.current?.selectedIndex ?? -1;
2436
+ setSearchStatus({
2437
+ results: runningResult.length,
2438
+ rowsSearched,
2439
+ selectedIndex
2440
+ });
2441
+ emitResultsChanged(runningResult, selectedIndex);
2442
+ if (startY + height >= totalRows) {
2443
+ startY = 0;
2444
+ } else {
2445
+ startY += height;
2446
+ }
2447
+ searchStride = nextSearchStride(
2448
+ searchStride,
2449
+ performance.now() - tStart
2450
+ );
2451
+ if (rowsSearched < totalRows && runningResult.length < INLINE_SEARCH_MAX_RESULTS) {
2452
+ searchHandleRef.current = window.requestAnimationFrame(tick);
2453
+ }
2454
+ };
2455
+ cancelSearch();
2456
+ abortControllerRef.current = new AbortController();
2457
+ searchHandleRef.current = window.requestAnimationFrame(tick);
2458
+ },
2459
+ [
2460
+ cancelSearch,
2461
+ columnCount,
2462
+ controlledSearchResults,
2463
+ emitResultsChanged,
2464
+ rowCount
2465
+ ]
2466
+ );
2467
+ const openSearch = useCallback3(() => {
2468
+ if (controlledShowSearch === void 0) {
2469
+ setInternalShowSearch(true);
2470
+ }
2471
+ }, [controlledShowSearch]);
2472
+ const closeSearch = useCallback3(() => {
2473
+ if (controlledShowSearch === void 0) {
2474
+ setInternalShowSearch(false);
2475
+ }
2476
+ onSearchClose?.();
2477
+ setSearchStatus(void 0);
2478
+ setInternalResults([]);
2479
+ emitResultsChanged([], -1);
2480
+ cancelSearch();
2481
+ }, [
2482
+ cancelSearch,
2483
+ controlledShowSearch,
2484
+ emitResultsChanged,
2485
+ onSearchClose
2486
+ ]);
2487
+ const goToNext = useCallback3(() => {
2488
+ if (!searchStatus || searchStatus.results === 0) return;
2489
+ const newIndex = nextSearchIndex(
2490
+ searchStatus.selectedIndex,
2491
+ searchStatus.results
2492
+ );
2493
+ setSearchStatus({ ...searchStatus, selectedIndex: newIndex });
2494
+ emitResultsChanged(searchResults, newIndex);
2495
+ navigateToIndex(searchResults, newIndex);
2496
+ }, [emitResultsChanged, navigateToIndex, searchResults, searchStatus]);
2497
+ const goToPrevious = useCallback3(() => {
2498
+ if (!searchStatus || searchStatus.results === 0) return;
2499
+ const newIndex = previousSearchIndex(
2500
+ searchStatus.selectedIndex,
2501
+ searchStatus.results
2502
+ );
2503
+ setSearchStatus({ ...searchStatus, selectedIndex: newIndex });
2504
+ emitResultsChanged(searchResults, newIndex);
2505
+ navigateToIndex(searchResults, newIndex);
2506
+ }, [emitResultsChanged, navigateToIndex, searchResults, searchStatus]);
2507
+ useEffect5(() => {
2508
+ if (controlledSearchResults === void 0) return;
2509
+ if (controlledSearchResults.length > 0) {
2510
+ setSearchStatus((current) => ({
2511
+ rowsSearched: rowCount,
2512
+ results: controlledSearchResults.length,
2513
+ selectedIndex: current?.selectedIndex ?? -1
2514
+ }));
2515
+ } else {
2516
+ setSearchStatus(void 0);
2517
+ }
2518
+ }, [controlledSearchResults, rowCount]);
2519
+ useEffect5(() => {
2520
+ if (!enabled) return;
2521
+ setSearchStatus(void 0);
2522
+ setInternalResults([]);
2523
+ emitResultsChanged([], -1);
2524
+ if (showSearch) {
2525
+ queueMicrotask(() => {
2526
+ searchInputRef.current?.focus({ preventScroll: true });
2527
+ });
2528
+ } else {
2529
+ cancelSearch();
2530
+ }
2531
+ }, [enabled, showSearch]);
2532
+ useEffect5(() => {
2533
+ if (!enabled || !showSearch) return;
2534
+ if (controlledSearchResults !== void 0) return;
2535
+ if (searchValue.trim() === "") {
2536
+ setSearchStatus(void 0);
2537
+ setInternalResults([]);
2538
+ cancelSearch();
2539
+ emitResultsChanged([], -1);
2540
+ return;
2541
+ }
2542
+ beginSearch(searchValue);
2543
+ }, [
2544
+ beginSearch,
2545
+ cancelSearch,
2546
+ controlledSearchResults,
2547
+ emitResultsChanged,
2548
+ enabled,
2549
+ searchValue,
2550
+ showSearch
2551
+ ]);
2552
+ useEffect5(() => {
2553
+ if (!enabled) return;
2554
+ const handleKeyDown = (event) => {
2555
+ if (!(event.ctrlKey || event.metaKey)) return;
2556
+ if (event.key.toLowerCase() !== "f") return;
2557
+ const root = rootRef?.current;
2558
+ if (root) {
2559
+ const active = document.activeElement;
2560
+ const focusInside = active === root || active instanceof Node && root.contains(active);
2561
+ if (!focusInside && active !== document.body) {
2562
+ return;
2563
+ }
2564
+ }
2565
+ event.preventDefault();
2566
+ event.stopPropagation();
2567
+ if (showSearch) {
2568
+ searchInputRef.current?.focus({ preventScroll: true });
2569
+ searchInputRef.current?.select();
2570
+ return;
2571
+ }
2572
+ if (controlledShowSearch === void 0) {
2573
+ setInternalShowSearch(true);
2574
+ }
2575
+ };
2576
+ window.addEventListener("keydown", handleKeyDown, true);
2577
+ return () => window.removeEventListener("keydown", handleKeyDown, true);
2578
+ }, [controlledShowSearch, enabled, rootRef, showSearch]);
2579
+ useEffect5(() => () => cancelSearch(), [cancelSearch]);
2580
+ const searchMatchKeys = useMemo2(
2581
+ () => buildSearchMatchKeys(searchResults),
2582
+ [searchResults]
2583
+ );
2584
+ const activeMatch = useMemo2(() => {
2585
+ if (!searchStatus || searchStatus.selectedIndex < 0) return null;
2586
+ return searchResults[searchStatus.selectedIndex] ?? null;
2587
+ }, [searchResults, searchStatus]);
2588
+ if (!enabled) {
2589
+ return {
2590
+ enabled: false,
2591
+ showSearch: false,
2592
+ searchValue: "",
2593
+ searchResults: [],
2594
+ searchStatus: void 0,
2595
+ searchMatchKeys: EMPTY_MATCH_KEYS,
2596
+ activeMatch: null,
2597
+ searchInputRef,
2598
+ searchInputId,
2599
+ canClose: false,
2600
+ openSearch,
2601
+ closeSearch,
2602
+ setSearchValue,
2603
+ goToNext,
2604
+ goToPrevious
2605
+ };
2606
+ }
2607
+ return {
2608
+ enabled: true,
2609
+ showSearch,
2610
+ searchValue,
2611
+ searchResults,
2612
+ searchStatus,
2613
+ searchMatchKeys,
2614
+ activeMatch,
2615
+ searchInputRef,
2616
+ searchInputId,
2617
+ canClose: controlledShowSearch === void 0 || onSearchClose !== void 0,
2618
+ openSearch,
2619
+ closeSearch,
2620
+ setSearchValue,
2621
+ goToNext,
2622
+ goToPrevious
2623
+ };
2624
+ }
2625
+
1892
2626
  // src/components/ui/table/features/row-selection/rowSelection.ts
1893
2627
  function resolveRowSelection(mode, controlledSelection, internalSelection) {
1894
2628
  if (mode === "none") return {};
@@ -1911,7 +2645,12 @@ var DEFAULT_DATA_TABLE_LABELS = {
1911
2645
  selection: (selectedCount) => selectedCount > 0 ? `\u2713 ${selectedCount} selected` : null,
1912
2646
  expandRow: "Expand row",
1913
2647
  collapseRow: "Collapse row",
1914
- resizeColumn: "Resize column"
2648
+ resizeColumn: "Resize column",
2649
+ searchPlaceholder: "Search\u2026",
2650
+ searchResultHint: "Type to search",
2651
+ searchPrevious: "Previous result",
2652
+ searchNext: "Next result",
2653
+ searchClose: "Close search"
1915
2654
  };
1916
2655
  function resolveDataTableLabels(partial) {
1917
2656
  return {
@@ -1922,6 +2661,7 @@ function resolveDataTableLabels(partial) {
1922
2661
 
1923
2662
  // src/core/useGlideTable.ts
1924
2663
  var EMPTY_COLUMN_FREEZE_OFFSETS = /* @__PURE__ */ new Map();
2664
+ var EMPTY_SEARCH_MATCH_KEYS = /* @__PURE__ */ new Set();
1925
2665
  function useGlideTable(options) {
1926
2666
  const {
1927
2667
  data,
@@ -1962,9 +2702,16 @@ function useGlideTable(options) {
1962
2702
  columnSizing: controlledColumnSizing,
1963
2703
  onColumnSizingChange,
1964
2704
  columnResizeMode = "onChange",
1965
- enableColumnFreeze = false
2705
+ enableColumnFreeze = false,
2706
+ enableInlineSearch = false,
2707
+ showSearch,
2708
+ searchValue,
2709
+ onSearchValueChange,
2710
+ onSearchClose,
2711
+ searchResults,
2712
+ onSearchResultsChanged
1966
2713
  } = options;
1967
- const labels = useMemo2(() => {
2714
+ const labels = useMemo3(() => {
1968
2715
  const resolved = resolveDataTableLabels(labelsProp);
1969
2716
  return {
1970
2717
  ...resolved,
@@ -1975,15 +2722,16 @@ function useGlideTable(options) {
1975
2722
  }, [labelsProp, emptyText, loadingText, selectionLabel]);
1976
2723
  const enableExpand = Boolean(toggleField);
1977
2724
  const resolvedEnableSubtreeCopy = enableSubtreeCopy ?? enableExpand;
1978
- const [internalRowSelection, setInternalRowSelection] = useState3({});
1979
- const [internalColumnSizing, setInternalColumnSizing] = useState3({});
1980
- const [internalExpandedRows, setInternalExpandedRows] = useState3(
2725
+ const [internalRowSelection, setInternalRowSelection] = useState4({});
2726
+ const [internalColumnSizing, setInternalColumnSizing] = useState4({});
2727
+ const [internalExpandedRows, setInternalExpandedRows] = useState4(
1981
2728
  () => /* @__PURE__ */ new Set()
1982
2729
  );
1983
- const [hoveredRowIndex, setHoveredRowIndex] = useState3(null);
1984
- const scrollRef = useRef5(null);
2730
+ const [hoveredRowIndex, setHoveredRowIndex] = useState4(null);
2731
+ const scrollRef = useRef6(null);
2732
+ const rootRef = useRef6(null);
1985
2733
  const shouldVirtualize = enableVirtualization && !enableRowSpan;
1986
- useEffect5(() => {
2734
+ useEffect6(() => {
1987
2735
  if (enableVirtualization && enableRowSpan) {
1988
2736
  console.warn(
1989
2737
  "[useGlideTable] enableRowSpan is on; virtualization is disabled to preserve cell merges."
@@ -1997,7 +2745,7 @@ function useGlideTable(options) {
1997
2745
  );
1998
2746
  const columnSizing = controlledColumnSizing ?? internalColumnSizing;
1999
2747
  const expandedRows = controlledExpandedRows ?? internalExpandedRows;
2000
- const handleExpandedRowsChange = useCallback3(
2748
+ const handleExpandedRowsChange = useCallback4(
2001
2749
  (next) => {
2002
2750
  if (onExpandedRowsChange) {
2003
2751
  onExpandedRowsChange(next);
@@ -2058,13 +2806,13 @@ function useGlideTable(options) {
2058
2806
  getCoreRowModel: getCoreRowModel(),
2059
2807
  getRowId: getRowId ? (originalRow, index) => getRowId(originalRow, index) : (_originalRow, index) => String(index)
2060
2808
  });
2061
- const rowSpanColumnKeys = useMemo2(() => {
2809
+ const rowSpanColumnKeys = useMemo3(() => {
2062
2810
  if (!enableRowSpan) return [];
2063
2811
  return collectRowSpanColumns(columns);
2064
2812
  }, [enableRowSpan, columns]);
2065
2813
  const primaryRowSpanKey = rowSpanColumnKeys[0]?.rowSpanKey;
2066
2814
  const primaryRowSpanColumnId = rowSpanColumnKeys[0]?.columnId;
2067
- const columnRowSpanMap = useMemo2(
2815
+ const columnRowSpanMap = useMemo3(
2068
2816
  () => buildColumnRowSpanMap(tableData, rowSpanColumnKeys),
2069
2817
  [tableData, rowSpanColumnKeys]
2070
2818
  );
@@ -2073,7 +2821,7 @@ function useGlideTable(options) {
2073
2821
  const rows = table.getRowModel().rows;
2074
2822
  const columnCount = table.getAllLeafColumns().length || 1;
2075
2823
  const visibleLeafColumns = table.getVisibleLeafColumns();
2076
- const columnFreezeOffsets = useMemo2(() => {
2824
+ const columnFreezeOffsets = useMemo3(() => {
2077
2825
  if (!enableColumnFreeze) return EMPTY_COLUMN_FREEZE_OFFSETS;
2078
2826
  return buildColumnFreezeOffsets(
2079
2827
  visibleLeafColumns.map((column) => ({
@@ -2093,13 +2841,46 @@ function useGlideTable(options) {
2093
2841
  const totalSize = rowVirtualizer.getTotalSize();
2094
2842
  const paddingTop = virtualRows.length > 0 ? virtualRows[0]?.start ?? 0 : 0;
2095
2843
  const paddingBottom = virtualRows.length > 0 ? totalSize - (virtualRows[virtualRows.length - 1]?.end ?? 0) : 0;
2096
- const selectedRowIndices = useMemo2(() => {
2844
+ const selectedRowIndices = useMemo3(() => {
2097
2845
  const indices = /* @__PURE__ */ new Set();
2098
2846
  for (const selectedRow of selectedRows) {
2099
2847
  indices.add(selectedRow.index);
2100
2848
  }
2101
2849
  return indices;
2102
2850
  }, [selectedRows]);
2851
+ const scrollCellIntoView = useCallback4(
2852
+ (rowIndex, colIndex, options2) => {
2853
+ const align = options2?.align ?? "nearest";
2854
+ const blockAlign = align === "center" ? "center" : "nearest";
2855
+ if (shouldVirtualize) {
2856
+ rowVirtualizer.scrollToIndex(rowIndex, {
2857
+ align: align === "nearest" ? "auto" : align
2858
+ });
2859
+ }
2860
+ const scrollElement = scrollRef.current;
2861
+ if (!scrollElement) return;
2862
+ const scrollToMatchedCell = () => {
2863
+ const cell = scrollElement.querySelector(
2864
+ `[data-row-index="${rowIndex}"][data-col-index="${colIndex}"]`
2865
+ );
2866
+ if (cell instanceof HTMLElement) {
2867
+ cell.scrollIntoView({ block: blockAlign, inline: "nearest" });
2868
+ }
2869
+ };
2870
+ if (shouldVirtualize) {
2871
+ requestAnimationFrame(scrollToMatchedCell);
2872
+ return;
2873
+ }
2874
+ scrollToMatchedCell();
2875
+ },
2876
+ [rowVirtualizer, shouldVirtualize]
2877
+ );
2878
+ const handleCellNavigate = useCallback4(
2879
+ (position) => {
2880
+ scrollCellIntoView(position.row, position.col, { align: "nearest" });
2881
+ },
2882
+ [scrollCellIntoView]
2883
+ );
2103
2884
  const {
2104
2885
  dragState,
2105
2886
  activeSelectionBounds,
@@ -2111,11 +2892,13 @@ function useGlideTable(options) {
2111
2892
  data: tableData,
2112
2893
  rows,
2113
2894
  enabled: enableCellSelection,
2895
+ columnCount: visibleLeafColumns.length,
2114
2896
  enableSubtreeCopy: resolvedEnableSubtreeCopy,
2115
2897
  enableInsertPaste: enableInsertPaste ?? true,
2116
2898
  onDataChange,
2117
2899
  onBatchChange,
2118
- onRowsPaste
2900
+ onRowsPaste,
2901
+ onCellNavigate: handleCellNavigate
2119
2902
  });
2120
2903
  const {
2121
2904
  editingCell,
@@ -2125,23 +2908,193 @@ function useGlideTable(options) {
2125
2908
  commitEdit,
2126
2909
  cancelEdit
2127
2910
  } = useCellEdit({ data: tableData, rows, onDataChange, onCellChange });
2128
- const handleCellMouseDownWithCommit = useCallback3(
2129
- (rowIndex, colIndex) => {
2911
+ const handleCellMouseDownWithCommit = useCallback4(
2912
+ (rowIndex, colIndex, options2) => {
2130
2913
  const isSameEditingCell = editingCell?.rowIndex === rowIndex && editingCell?.colIndex === colIndex;
2131
2914
  if (editingCell && !isSameEditingCell && !commitEdit()) {
2132
2915
  return;
2133
2916
  }
2134
- handleCellMouseDown(rowIndex, colIndex);
2917
+ handleCellMouseDown(rowIndex, colIndex, options2);
2135
2918
  },
2136
2919
  [commitEdit, editingCell, handleCellMouseDown]
2137
2920
  );
2138
- const clearHover = useCallback3(() => {
2921
+ const navigateToSearchResult = useCallback4(
2922
+ (item) => {
2923
+ const [colIndex, rowIndex] = item;
2924
+ handleCellMouseDownWithCommit(rowIndex, colIndex);
2925
+ scrollCellIntoView(rowIndex, colIndex, { align: "center" });
2926
+ },
2927
+ [handleCellMouseDownWithCommit, scrollCellIntoView]
2928
+ );
2929
+ const resolveSearchRowId = useCallback4(
2930
+ (row, index) => {
2931
+ if (getRowId) return getRowId(row, index);
2932
+ if (enableExpand) {
2933
+ const record = row;
2934
+ const idValue = record.id;
2935
+ if (idValue != null && String(idValue).length > 0) {
2936
+ return String(idValue);
2937
+ }
2938
+ const uniqueId = record.uniqueId;
2939
+ if (uniqueId != null && String(uniqueId).length > 0) {
2940
+ return String(uniqueId);
2941
+ }
2942
+ if (toggleField) {
2943
+ const toggleValue = record[toggleField];
2944
+ if (toggleValue != null && String(toggleValue).length > 0) {
2945
+ return String(toggleValue);
2946
+ }
2947
+ }
2948
+ }
2949
+ return String(index);
2950
+ },
2951
+ [enableExpand, getRowId, toggleField]
2952
+ );
2953
+ const searchCorpus = useMemo3(() => {
2954
+ if (!enableInlineSearch) return [];
2955
+ if (enableExpand && toggleField) {
2956
+ return buildTreeSearchCorpus(tableData, {
2957
+ toggleField,
2958
+ getRowId: resolveSearchRowId
2959
+ });
2960
+ }
2961
+ return buildFlatSearchCorpus(tableData, resolveSearchRowId);
2962
+ }, [
2963
+ enableExpand,
2964
+ enableInlineSearch,
2965
+ resolveSearchRowId,
2966
+ tableData,
2967
+ toggleField
2968
+ ]);
2969
+ const searchCorpusRef = useRef6(searchCorpus);
2970
+ searchCorpusRef.current = searchCorpus;
2971
+ const visibleRowIndexById = useMemo3(() => {
2972
+ const map = /* @__PURE__ */ new Map();
2973
+ for (const row of rows) {
2974
+ map.set(resolveSearchRowId(row.original, row.index), row.index);
2975
+ }
2976
+ return map;
2977
+ }, [resolveSearchRowId, rows]);
2978
+ const getSearchCellValue = useCallback4(
2979
+ (rowIndex, colIndex) => {
2980
+ const corpusRow = searchCorpusRef.current[rowIndex];
2981
+ const column = visibleLeafColumns[colIndex];
2982
+ if (!corpusRow || !column) return void 0;
2983
+ const visibleIndex = visibleRowIndexById.get(corpusRow.id);
2984
+ if (visibleIndex !== void 0) {
2985
+ const visibleRow = rows[visibleIndex];
2986
+ if (visibleRow) {
2987
+ return visibleRow.getValue(column.id);
2988
+ }
2989
+ }
2990
+ const columnDef = column.columnDef;
2991
+ if ("accessorFn" in columnDef && typeof columnDef.accessorFn === "function") {
2992
+ return columnDef.accessorFn(corpusRow.data, rowIndex);
2993
+ }
2994
+ if ("accessorKey" in columnDef && columnDef.accessorKey != null && columnDef.accessorKey !== "") {
2995
+ return corpusRow.data[String(columnDef.accessorKey)];
2996
+ }
2997
+ return corpusRow.data[column.id];
2998
+ },
2999
+ [rows, visibleLeafColumns, visibleRowIndexById]
3000
+ );
3001
+ const pendingSearchNavRef = useRef6(null);
3002
+ const focusSearchResult = useCallback4(
3003
+ (colIndex, visibleRowIndex) => {
3004
+ navigateToSearchResult([colIndex, visibleRowIndex]);
3005
+ },
3006
+ [navigateToSearchResult]
3007
+ );
3008
+ const navigateToCorpusSearchResult = useCallback4(
3009
+ (item) => {
3010
+ const [colIndex, corpusRowIndex] = item;
3011
+ const corpusRow = searchCorpusRef.current[corpusRowIndex];
3012
+ if (!corpusRow) return;
3013
+ const missingKeys = collectAncestorKeysToExpand(corpusRow, expandedRows);
3014
+ if (missingKeys.length > 0) {
3015
+ pendingSearchNavRef.current = {
3016
+ colIndex,
3017
+ rowId: corpusRow.id
3018
+ };
3019
+ const next = new Set(expandedRows);
3020
+ for (const key of corpusRow.ancestorToggleKeys) {
3021
+ next.add(key);
3022
+ }
3023
+ handleExpandedRowsChange(next);
3024
+ return;
3025
+ }
3026
+ const visibleItem = mapSearchResultToVisibleItem(
3027
+ item,
3028
+ searchCorpusRef.current,
3029
+ visibleRowIndexById
3030
+ );
3031
+ if (!visibleItem) return;
3032
+ focusSearchResult(visibleItem[0], visibleItem[1]);
3033
+ },
3034
+ [
3035
+ expandedRows,
3036
+ focusSearchResult,
3037
+ handleExpandedRowsChange,
3038
+ visibleRowIndexById
3039
+ ]
3040
+ );
3041
+ useEffect6(() => {
3042
+ const pending = pendingSearchNavRef.current;
3043
+ if (!pending) return;
3044
+ const visibleRowIndex = visibleRowIndexById.get(pending.rowId);
3045
+ if (visibleRowIndex === void 0) return;
3046
+ pendingSearchNavRef.current = null;
3047
+ focusSearchResult(pending.colIndex, visibleRowIndex);
3048
+ }, [focusSearchResult, rows, visibleRowIndexById]);
3049
+ const initialSearchStartRow = virtualRows[0]?.index ?? 0;
3050
+ const inlineSearch = useInlineSearch({
3051
+ enabled: enableInlineSearch,
3052
+ rowCount: searchCorpus.length,
3053
+ columnCount: visibleLeafColumns.length,
3054
+ getCellValue: getSearchCellValue,
3055
+ initialStartRow: initialSearchStartRow,
3056
+ showSearch,
3057
+ searchValue,
3058
+ searchResults,
3059
+ onSearchValueChange,
3060
+ onSearchClose,
3061
+ onSearchResultsChanged,
3062
+ onNavigateToResult: navigateToCorpusSearchResult,
3063
+ rootRef
3064
+ });
3065
+ const visibleSearchMatchKeys = useMemo3(() => {
3066
+ if (!enableInlineSearch) return EMPTY_SEARCH_MATCH_KEYS;
3067
+ return mapSearchResultsToVisibleKeys(
3068
+ inlineSearch.searchResults,
3069
+ searchCorpus,
3070
+ visibleRowIndexById
3071
+ );
3072
+ }, [
3073
+ enableInlineSearch,
3074
+ inlineSearch.searchResults,
3075
+ searchCorpus,
3076
+ visibleRowIndexById
3077
+ ]);
3078
+ const visibleActiveMatch = useMemo3(() => {
3079
+ if (!enableInlineSearch || !inlineSearch.activeMatch) return null;
3080
+ return mapSearchResultToVisibleItem(
3081
+ inlineSearch.activeMatch,
3082
+ searchCorpus,
3083
+ visibleRowIndexById
3084
+ );
3085
+ }, [
3086
+ enableInlineSearch,
3087
+ inlineSearch.activeMatch,
3088
+ searchCorpus,
3089
+ visibleRowIndexById
3090
+ ]);
3091
+ const clearHover = useCallback4(() => {
2139
3092
  setHoveredRowIndex(null);
2140
3093
  }, []);
2141
- const handleRowHover = useCallback3((rowIndex, _rowData) => {
3094
+ const handleRowHover = useCallback4((rowIndex, _rowData) => {
2142
3095
  setHoveredRowIndex(rowIndex);
2143
3096
  }, []);
2144
- const handleToggleSelect = useCallback3(
3097
+ const handleToggleSelect = useCallback4(
2145
3098
  (row) => {
2146
3099
  if (!row.getCanSelect()) return;
2147
3100
  if (preserveRowSelection && row.getIsSelected()) {
@@ -2151,14 +3104,14 @@ function useGlideTable(options) {
2151
3104
  },
2152
3105
  [preserveRowSelection]
2153
3106
  );
2154
- const handleToggleExpand = useCallback3(
3107
+ const handleToggleExpand = useCallback4(
2155
3108
  (rowKey) => {
2156
3109
  if (preventExpand) return;
2157
3110
  handleExpandedRowsChange(toggleExpandedRowId(rowKey, expandedRows));
2158
3111
  },
2159
3112
  [preventExpand, handleExpandedRowsChange, expandedRows]
2160
3113
  );
2161
- const rowContextValue = useMemo2(() => {
3114
+ const rowContextValue = useMemo3(() => {
2162
3115
  return {
2163
3116
  rowSpan: {
2164
3117
  enableRowSpan,
@@ -2206,6 +3159,11 @@ function useGlideTable(options) {
2206
3159
  columnFreeze: {
2207
3160
  enableColumnFreeze,
2208
3161
  offsets: columnFreezeOffsets
3162
+ },
3163
+ inlineSearch: {
3164
+ enabled: enableInlineSearch,
3165
+ matchKeys: visibleSearchMatchKeys,
3166
+ activeMatch: visibleActiveMatch
2209
3167
  }
2210
3168
  };
2211
3169
  }, [
@@ -2241,14 +3199,17 @@ function useGlideTable(options) {
2241
3199
  labels.collapseRow,
2242
3200
  enableColumnResize,
2243
3201
  enableColumnFreeze,
2244
- columnFreezeOffsets
3202
+ columnFreezeOffsets,
3203
+ enableInlineSearch,
3204
+ visibleSearchMatchKeys,
3205
+ visibleActiveMatch
2245
3206
  ]);
2246
- const copySelectionRef = useRef5(copySelection);
2247
- useEffect5(() => {
3207
+ const copySelectionRef = useRef6(copySelection);
3208
+ useEffect6(() => {
2248
3209
  copySelectionRef.current = copySelection;
2249
3210
  }, [copySelection]);
2250
- const stableCopySelection = useCallback3((options2) => copySelectionRef.current(options2), []);
2251
- useEffect5(() => {
3211
+ const stableCopySelection = useCallback4((options2) => copySelectionRef.current(options2), []);
3212
+ useEffect6(() => {
2252
3213
  onCopyActionsReady?.({ copySelection: stableCopySelection });
2253
3214
  }, [onCopyActionsReady, stableCopySelection]);
2254
3215
  return {
@@ -2264,8 +3225,10 @@ function useGlideTable(options) {
2264
3225
  enableCellSelection,
2265
3226
  enableColumnResize,
2266
3227
  enableColumnFreeze,
3228
+ enableInlineSearch,
2267
3229
  shouldVirtualize,
2268
3230
  scrollRef,
3231
+ rootRef,
2269
3232
  rowVirtualizer,
2270
3233
  virtualRows,
2271
3234
  paddingTop,
@@ -2273,25 +3236,39 @@ function useGlideTable(options) {
2273
3236
  rowContextValue,
2274
3237
  handleToggleSelect,
2275
3238
  clearHover,
2276
- copySelection: stableCopySelection
3239
+ copySelection: stableCopySelection,
3240
+ inlineSearch: {
3241
+ showSearch: inlineSearch.showSearch,
3242
+ searchValue: inlineSearch.searchValue,
3243
+ searchStatus: inlineSearch.searchStatus,
3244
+ searchInputRef: inlineSearch.searchInputRef,
3245
+ searchInputId: inlineSearch.searchInputId,
3246
+ canClose: inlineSearch.canClose,
3247
+ searchRowCount: searchCorpus.length,
3248
+ setSearchValue: inlineSearch.setSearchValue,
3249
+ closeSearch: inlineSearch.closeSearch,
3250
+ goToNext: inlineSearch.goToNext,
3251
+ goToPrevious: inlineSearch.goToPrevious,
3252
+ openSearch: inlineSearch.openSearch
3253
+ }
2277
3254
  };
2278
3255
  }
2279
3256
 
2280
3257
  // src/components/ui/table/components/DataTable/DataTable.tsx
2281
- import { Fragment as Fragment2, jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
3258
+ import { Fragment as Fragment2, jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
2282
3259
  function DefaultScroll({
2283
3260
  scrollRef,
2284
3261
  children,
2285
3262
  className
2286
3263
  }) {
2287
- return /* @__PURE__ */ jsx5("div", { ref: scrollRef, className: cn("data-table-scroll", className), children });
3264
+ return /* @__PURE__ */ jsx6("div", { ref: scrollRef, className: cn("data-table-scroll", className), children });
2288
3265
  }
2289
3266
  function DefaultPending({
2290
3267
  loadingText,
2291
3268
  className,
2292
3269
  classNames
2293
3270
  }) {
2294
- return /* @__PURE__ */ jsx5(
3271
+ return /* @__PURE__ */ jsx6(
2295
3272
  "div",
2296
3273
  {
2297
3274
  className: cn(
@@ -2301,7 +3278,7 @@ function DefaultPending({
2301
3278
  classNames?.pending,
2302
3279
  className
2303
3280
  ),
2304
- children: /* @__PURE__ */ jsx5("span", { className: cn("data-table-loading-text", classNames?.loadingText), children: loadingText })
3281
+ children: /* @__PURE__ */ jsx6("span", { className: cn("data-table-loading-text", classNames?.loadingText), children: loadingText })
2305
3282
  }
2306
3283
  );
2307
3284
  }
@@ -2310,7 +3287,7 @@ function DefaultEmpty({
2310
3287
  columnCount,
2311
3288
  classNames
2312
3289
  }) {
2313
- return /* @__PURE__ */ jsx5("tr", { children: /* @__PURE__ */ jsx5(
3290
+ return /* @__PURE__ */ jsx6("tr", { children: /* @__PURE__ */ jsx6(
2314
3291
  "td",
2315
3292
  {
2316
3293
  colSpan: columnCount,
@@ -2343,15 +3320,18 @@ function DataTable({
2343
3320
  enableCellSelection,
2344
3321
  enableColumnResize,
2345
3322
  enableColumnFreeze,
3323
+ enableInlineSearch,
2346
3324
  shouldVirtualize,
2347
3325
  scrollRef,
3326
+ rootRef,
2348
3327
  rowVirtualizer,
2349
3328
  virtualRows,
2350
3329
  paddingTop,
2351
3330
  paddingBottom,
2352
3331
  rowContextValue,
2353
3332
  handleToggleSelect,
2354
- clearHover
3333
+ clearHover,
3334
+ inlineSearch
2355
3335
  } = useGlideTable(glideOptions);
2356
3336
  const ToolbarSlot = slots?.Toolbar ?? DataTableToolbar;
2357
3337
  const ScrollSlot = slots?.Scroll ?? DefaultScroll;
@@ -2359,12 +3339,12 @@ function DataTable({
2359
3339
  const PendingSlot = slots?.Pending ?? DefaultPending;
2360
3340
  const EmptySlot = slots?.Empty ?? DefaultEmpty;
2361
3341
  const freezeOffsets = rowContextValue.columnFreeze.offsets;
2362
- const contextValue = useMemo3(
3342
+ const contextValue = useMemo4(
2363
3343
  () => ({ ...rowContextValue, classNames }),
2364
3344
  [rowContextValue, classNames]
2365
3345
  );
2366
3346
  if (isPending) {
2367
- return /* @__PURE__ */ jsx5(
3347
+ return /* @__PURE__ */ jsx6(
2368
3348
  PendingSlot,
2369
3349
  {
2370
3350
  loadingText,
@@ -2373,19 +3353,21 @@ function DataTable({
2373
3353
  }
2374
3354
  );
2375
3355
  }
2376
- return /* @__PURE__ */ jsxs4(
3356
+ return /* @__PURE__ */ jsxs5(
2377
3357
  "div",
2378
3358
  {
3359
+ ref: rootRef,
2379
3360
  className: cn(
2380
3361
  "DataTableJSX",
2381
3362
  !enableCellSelection && "DataTableJSX--no-cell-selection",
2382
3363
  enableColumnResize && "DataTableJSX--column-resize",
2383
3364
  enableColumnFreeze && "DataTableJSX--column-freeze",
3365
+ enableInlineSearch && "DataTableJSX--inline-search",
2384
3366
  classNames?.root,
2385
3367
  className
2386
3368
  ),
2387
3369
  children: [
2388
- /* @__PURE__ */ jsx5(
3370
+ /* @__PURE__ */ jsx6(
2389
3371
  ToolbarSlot,
2390
3372
  {
2391
3373
  filteredCount: filteredCount ?? tableData.length,
@@ -2397,14 +3379,36 @@ function DataTable({
2397
3379
  classNames
2398
3380
  }
2399
3381
  ),
2400
- /* @__PURE__ */ jsx5(ScrollSlot, { scrollRef, className: classNames?.scroll, children: /* @__PURE__ */ jsxs4(
3382
+ enableInlineSearch ? /* @__PURE__ */ jsx6(
3383
+ DataTableSearch,
3384
+ {
3385
+ showSearch: inlineSearch.showSearch,
3386
+ searchValue: inlineSearch.searchValue,
3387
+ searchStatus: inlineSearch.searchStatus,
3388
+ searchInputId: inlineSearch.searchInputId,
3389
+ searchInputRef: inlineSearch.searchInputRef,
3390
+ canClose: inlineSearch.canClose,
3391
+ placeholder: labels.searchPlaceholder,
3392
+ resultHint: labels.searchResultHint,
3393
+ previousLabel: labels.searchPrevious,
3394
+ nextLabel: labels.searchNext,
3395
+ closeLabel: labels.searchClose,
3396
+ rowsTotal: inlineSearch.searchRowCount,
3397
+ classNames,
3398
+ onSearchValueChange: inlineSearch.setSearchValue,
3399
+ onClose: inlineSearch.closeSearch,
3400
+ onNext: inlineSearch.goToNext,
3401
+ onPrevious: inlineSearch.goToPrevious
3402
+ }
3403
+ ) : null,
3404
+ /* @__PURE__ */ jsx6(ScrollSlot, { scrollRef, className: classNames?.scroll, children: /* @__PURE__ */ jsxs5(
2401
3405
  "table",
2402
3406
  {
2403
3407
  className: cn("data-table", classNames?.table),
2404
3408
  style: enableColumnResize ? { width: table.getTotalSize() } : void 0,
2405
3409
  onDragStart: enableCellSelection ? (event) => event.preventDefault() : void 0,
2406
3410
  children: [
2407
- /* @__PURE__ */ jsx5("thead", { className: cn("data-table-head", classNames?.head), children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx5(
3411
+ /* @__PURE__ */ jsx6("thead", { className: cn("data-table-head", classNames?.head), children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx6(
2408
3412
  "tr",
2409
3413
  {
2410
3414
  className: cn("data-table-head-row", classNames?.headRow),
@@ -2424,7 +3428,7 @@ function DataTable({
2424
3428
  ...sizeStyle,
2425
3429
  ...freezeStyle
2426
3430
  };
2427
- return /* @__PURE__ */ jsxs4(
3431
+ return /* @__PURE__ */ jsxs5(
2428
3432
  "th",
2429
3433
  {
2430
3434
  "data-resizing": header.column.getIsResizing() ? "" : void 0,
@@ -2440,7 +3444,7 @@ function DataTable({
2440
3444
  ),
2441
3445
  children: [
2442
3446
  header.isPlaceholder ? null : flexRender2(header.column.columnDef.header, header.getContext()),
2443
- canResize ? /* @__PURE__ */ jsx5(
3447
+ canResize ? /* @__PURE__ */ jsx6(
2444
3448
  "div",
2445
3449
  {
2446
3450
  role: "separator",
@@ -2466,20 +3470,20 @@ function DataTable({
2466
3470
  },
2467
3471
  headerGroup.id
2468
3472
  )) }),
2469
- /* @__PURE__ */ jsx5(DataTableContextProvider, { value: contextValue, children: /* @__PURE__ */ jsx5(
3473
+ /* @__PURE__ */ jsx6(DataTableContextProvider, { value: contextValue, children: /* @__PURE__ */ jsx6(
2470
3474
  "tbody",
2471
3475
  {
2472
3476
  onMouseLeave: clearHover,
2473
3477
  className: cn("data-table-body", classNames?.body),
2474
- children: rows.length === 0 ? /* @__PURE__ */ jsx5(
3478
+ children: rows.length === 0 ? /* @__PURE__ */ jsx6(
2475
3479
  EmptySlot,
2476
3480
  {
2477
3481
  emptyText,
2478
3482
  columnCount,
2479
3483
  classNames
2480
3484
  }
2481
- ) : shouldVirtualize ? /* @__PURE__ */ jsxs4(Fragment2, { children: [
2482
- paddingTop > 0 && /* @__PURE__ */ jsx5(
3485
+ ) : shouldVirtualize ? /* @__PURE__ */ jsxs5(Fragment2, { children: [
3486
+ paddingTop > 0 && /* @__PURE__ */ jsx6(
2483
3487
  "tr",
2484
3488
  {
2485
3489
  "aria-hidden": true,
@@ -2487,7 +3491,7 @@ function DataTable({
2487
3491
  "data-table-virtual-spacer",
2488
3492
  classNames?.virtualSpacer
2489
3493
  ),
2490
- children: /* @__PURE__ */ jsx5(
3494
+ children: /* @__PURE__ */ jsx6(
2491
3495
  "td",
2492
3496
  {
2493
3497
  colSpan: columnCount,
@@ -2503,7 +3507,7 @@ function DataTable({
2503
3507
  virtualRows.map((virtualRow) => {
2504
3508
  const row = rows[virtualRow.index];
2505
3509
  if (!row) return null;
2506
- return /* @__PURE__ */ jsx5(
3510
+ return /* @__PURE__ */ jsx6(
2507
3511
  RowSlot,
2508
3512
  {
2509
3513
  row,
@@ -2514,7 +3518,7 @@ function DataTable({
2514
3518
  row.id
2515
3519
  );
2516
3520
  }),
2517
- paddingBottom > 0 && /* @__PURE__ */ jsx5(
3521
+ paddingBottom > 0 && /* @__PURE__ */ jsx6(
2518
3522
  "tr",
2519
3523
  {
2520
3524
  "aria-hidden": true,
@@ -2522,7 +3526,7 @@ function DataTable({
2522
3526
  "data-table-virtual-spacer",
2523
3527
  classNames?.virtualSpacer
2524
3528
  ),
2525
- children: /* @__PURE__ */ jsx5(
3529
+ children: /* @__PURE__ */ jsx6(
2526
3530
  "td",
2527
3531
  {
2528
3532
  colSpan: columnCount,
@@ -2535,7 +3539,7 @@ function DataTable({
2535
3539
  )
2536
3540
  }
2537
3541
  )
2538
- ] }) : rows.map((row) => /* @__PURE__ */ jsx5(
3542
+ ] }) : rows.map((row) => /* @__PURE__ */ jsx6(
2539
3543
  RowSlot,
2540
3544
  {
2541
3545
  row,
@@ -2554,10 +3558,10 @@ function DataTable({
2554
3558
  }
2555
3559
 
2556
3560
  // src/components/ui/table/components/Table/Table.tsx
2557
- import { useCallback as useCallback4, useMemo as useMemo4, useState as useState4 } from "react";
3561
+ import { useCallback as useCallback5, useMemo as useMemo5, useState as useState5 } from "react";
2558
3562
 
2559
3563
  // src/components/ui/table/components/Table/buildColumnDef.tsx
2560
- import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
3564
+ import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
2561
3565
  function SortableHeader({
2562
3566
  label,
2563
3567
  field,
@@ -2566,15 +3570,15 @@ function SortableHeader({
2566
3570
  }) {
2567
3571
  const isActive = sort?.field === field;
2568
3572
  const Icon = isActive ? sort.direction === "asc" ? ArrowUp : ArrowDown : ArrowUpDown;
2569
- return /* @__PURE__ */ jsxs5(
3573
+ return /* @__PURE__ */ jsxs6(
2570
3574
  "button",
2571
3575
  {
2572
3576
  type: "button",
2573
3577
  className: cn("SortableHeaderJSX", isActive ? "is-active" : "is-inactive"),
2574
3578
  onClick: () => onSort(field),
2575
3579
  children: [
2576
- /* @__PURE__ */ jsx6("span", { children: label }),
2577
- /* @__PURE__ */ jsx6(Icon, { className: "sortable-header-icon" })
3580
+ /* @__PURE__ */ jsx7("span", { children: label }),
3581
+ /* @__PURE__ */ jsx7(Icon, { className: "sortable-header-icon" })
2578
3582
  ]
2579
3583
  }
2580
3584
  );
@@ -2607,7 +3611,7 @@ function buildColumnDef(props, sort, onSort) {
2607
3611
  ...minWidth != null ? { minSize: minWidth } : {},
2608
3612
  ...maxWidth != null ? { maxSize: maxWidth } : {},
2609
3613
  ...resizable === false ? { enableResizing: false } : {},
2610
- header: sortable ? () => /* @__PURE__ */ jsx6(SortableHeader, { label: children, field, sort, onSort }) : (
3614
+ header: sortable ? () => /* @__PURE__ */ jsx7(SortableHeader, { label: children, field, sort, onSort }) : (
2611
3615
  // eslint-disable-next-line @typescript-eslint/promise-function-async
2612
3616
  () => children
2613
3617
  ),
@@ -2755,7 +3759,7 @@ function TableHeader(props) {
2755
3759
  TableHeader.displayName = TABLE_HEADER_DISPLAY_NAME;
2756
3760
 
2757
3761
  // src/components/ui/table/components/Table/TablePagination.tsx
2758
- import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
3762
+ import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
2759
3763
  function TablePagination({
2760
3764
  page,
2761
3765
  pageSize = 10,
@@ -2767,8 +3771,8 @@ function TablePagination({
2767
3771
  const safePage = Math.min(Math.max(1, page), totalPages);
2768
3772
  const canGoPrev = safePage > 1;
2769
3773
  const canGoNext = safePage < totalPages;
2770
- return /* @__PURE__ */ jsxs6("div", { className: cn("TablePaginationJSX", className), children: [
2771
- /* @__PURE__ */ jsx7(
3774
+ return /* @__PURE__ */ jsxs7("div", { className: cn("TablePaginationJSX", className), children: [
3775
+ /* @__PURE__ */ jsx8(
2772
3776
  "button",
2773
3777
  {
2774
3778
  type: "button",
@@ -2776,15 +3780,15 @@ function TablePagination({
2776
3780
  disabled: !canGoPrev,
2777
3781
  onClick: () => onChange(safePage - 1),
2778
3782
  "aria-label": "Previous page",
2779
- children: /* @__PURE__ */ jsx7(ChevronLeft, { className: "pagination-button-icon" })
3783
+ children: /* @__PURE__ */ jsx8(ChevronLeft, { className: "pagination-button-icon" })
2780
3784
  }
2781
3785
  ),
2782
- /* @__PURE__ */ jsxs6("span", { className: "pagination-label", children: [
3786
+ /* @__PURE__ */ jsxs7("span", { className: "pagination-label", children: [
2783
3787
  safePage,
2784
3788
  " / ",
2785
3789
  totalPages
2786
3790
  ] }),
2787
- /* @__PURE__ */ jsx7(
3791
+ /* @__PURE__ */ jsx8(
2788
3792
  "button",
2789
3793
  {
2790
3794
  type: "button",
@@ -2792,7 +3796,7 @@ function TablePagination({
2792
3796
  disabled: !canGoNext,
2793
3797
  onClick: () => onChange(safePage + 1),
2794
3798
  "aria-label": "Next page",
2795
- children: /* @__PURE__ */ jsx7(ChevronRight, { className: "pagination-button-icon" })
3799
+ children: /* @__PURE__ */ jsx8(ChevronRight, { className: "pagination-button-icon" })
2796
3800
  }
2797
3801
  )
2798
3802
  ] });
@@ -2800,7 +3804,7 @@ function TablePagination({
2800
3804
  TablePagination.displayName = TABLE_PAGINATION_DISPLAY_NAME;
2801
3805
 
2802
3806
  // src/components/ui/table/components/Table/Table.tsx
2803
- import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
3807
+ import { jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
2804
3808
  function TableRoot({
2805
3809
  data,
2806
3810
  children,
@@ -2809,12 +3813,12 @@ function TableRoot({
2809
3813
  filteredCount,
2810
3814
  ...dataTableProps
2811
3815
  }) {
2812
- const { header, pagination: paginationElement } = useMemo4(
3816
+ const { header, pagination: paginationElement } = useMemo5(
2813
3817
  () => parseTableChildren(children),
2814
3818
  [children]
2815
3819
  );
2816
- const [sort, setSort] = useState4(null);
2817
- const handleSort = useCallback4((field) => {
3820
+ const [sort, setSort] = useState5(null);
3821
+ const handleSort = useCallback5((field) => {
2818
3822
  setSort((previous) => {
2819
3823
  if (previous?.field !== field) {
2820
3824
  return { field, direction: "asc" };
@@ -2825,7 +3829,7 @@ function TableRoot({
2825
3829
  return null;
2826
3830
  });
2827
3831
  }, []);
2828
- const columns = useMemo4(() => {
3832
+ const columns = useMemo5(() => {
2829
3833
  return extractColumnElements(header).map(
2830
3834
  (columnElement) => buildColumnDef(columnElement.props, sort, handleSort)
2831
3835
  );
@@ -2834,7 +3838,7 @@ function TableRoot({
2834
3838
  const pageSize = paginationProps?.pageSize ?? 10;
2835
3839
  const page = paginationProps?.page ?? 1;
2836
3840
  const resolvedTotalCount = paginationProps?.totalCount ?? totalCount ?? data.length;
2837
- const tableData = useMemo4(() => {
3841
+ const tableData = useMemo5(() => {
2838
3842
  const sortedData = sortTableData(data, sort);
2839
3843
  if (!paginationProps) return sortedData;
2840
3844
  return paginateTableData(sortedData, page, pageSize);
@@ -2842,8 +3846,8 @@ function TableRoot({
2842
3846
  if (columns.length === 0) {
2843
3847
  console.warn("[Table] Declare at least one Table.Column inside Table.Header.");
2844
3848
  }
2845
- return /* @__PURE__ */ jsxs7("div", { className: "TableJSX", children: [
2846
- /* @__PURE__ */ jsx8(
3849
+ return /* @__PURE__ */ jsxs8("div", { className: "TableJSX", children: [
3850
+ /* @__PURE__ */ jsx9(
2847
3851
  DataTable,
2848
3852
  {
2849
3853
  ...dataTableProps,
@@ -2854,7 +3858,7 @@ function TableRoot({
2854
3858
  className: cn(className, paginationProps && "DataTableJSX--with-pagination")
2855
3859
  }
2856
3860
  ),
2857
- paginationProps && /* @__PURE__ */ jsx8(
3861
+ paginationProps && /* @__PURE__ */ jsx9(
2858
3862
  TablePagination,
2859
3863
  {
2860
3864
  page,
@@ -2874,7 +3878,7 @@ function createTable() {
2874
3878
  Column.displayName = TABLE_COLUMN_DISPLAY_NAME;
2875
3879
  return Object.assign(
2876
3880
  function BoundTable(props) {
2877
- return /* @__PURE__ */ jsx8(TableRoot, { ...props });
3881
+ return /* @__PURE__ */ jsx9(TableRoot, { ...props });
2878
3882
  },
2879
3883
  {
2880
3884
  Header: TableHeader,