react-glide-table 1.4.1 → 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,9 +1288,14 @@ 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,
@@ -1108,6 +1305,8 @@ function DataTableRow({
1108
1305
  "data-group-hovered": enableRowSpan && showCellHover && !showCellSelected ? "" : void 0,
1109
1306
  "data-selection-fill": isCellDragSelected ? "" : void 0,
1110
1307
  "data-selection-edges": hasSelectionEdges ? "" : void 0,
1308
+ "data-search-match": isSearchMatch ? "" : void 0,
1309
+ "data-search-active": isSearchActive ? "" : void 0,
1111
1310
  "data-editable": editable ? "" : void 0,
1112
1311
  "data-editing": isEditing ? "" : void 0,
1113
1312
  "data-frozen": freezeOffset?.side,
@@ -1122,7 +1321,8 @@ function DataTableRow({
1122
1321
  event.preventDefault();
1123
1322
  onCellMouseDown(
1124
1323
  resolveCellRowIndex(event.clientY, event.currentTarget),
1125
- cellIndex
1324
+ cellIndex,
1325
+ { shiftKey: event.shiftKey }
1126
1326
  );
1127
1327
  },
1128
1328
  onMouseEnter: (event) => {
@@ -1159,6 +1359,8 @@ function DataTableRow({
1159
1359
  enableRowSpan && showCellHover && !showCellSelected && "is-group-hovered",
1160
1360
  isCellDragSelected && CELL_SELECTION_FILL_CLASS,
1161
1361
  hasSelectionEdges && CELL_SELECTION_EDGES_CLASS,
1362
+ isSearchMatch && "is-search-match",
1363
+ isSearchActive && "is-search-active",
1162
1364
  editable && "is-editable",
1163
1365
  classNames?.cell
1164
1366
  ),
@@ -1293,8 +1495,169 @@ function DataTableRow({
1293
1495
  );
1294
1496
  }
1295
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
+
1296
1659
  // src/components/ui/table/components/DataTable/DataTableToolbar.tsx
1297
- 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";
1298
1661
  function DataTableToolbar({
1299
1662
  filteredCount,
1300
1663
  totalCount,
@@ -1312,20 +1675,20 @@ function DataTableToolbar({
1312
1675
  const selectionContent = selectionLabel?.(selectedCount) ?? null;
1313
1676
  const hasSelectionContent = selectionContent !== null && selectionContent !== false && selectionContent !== void 0 && typeof selectionContent !== "boolean";
1314
1677
  if (!hasLeftContent && !hasToolbar && !hasSelectionContent) return null;
1315
- return /* @__PURE__ */ jsxs3("div", { className: cn("DataTableToolbarJSX", classNames?.toolbar, className), children: [
1316
- /* @__PURE__ */ jsxs3("div", { className: cn("toolbar-left", classNames?.toolbarLeft), children: [
1317
- hasCount && /* @__PURE__ */ jsx4("span", { className: cn("toolbar-count", classNames?.toolbarCount), children: displayFiltered !== void 0 && totalCount !== void 0 ? /* @__PURE__ */ jsxs3(Fragment, { children: [
1318
- /* @__PURE__ */ jsx4("span", { className: "toolbar-count-primary", children: displayFiltered }),
1319
- /* @__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: [
1320
1683
  " / ",
1321
1684
  totalCount
1322
1685
  ] })
1323
- ] }) : /* @__PURE__ */ jsx4("span", { className: "toolbar-count-primary", children: displayFiltered ?? totalCount }) }),
1686
+ ] }) : /* @__PURE__ */ jsx5("span", { className: "toolbar-count-primary", children: displayFiltered ?? totalCount }) }),
1324
1687
  summary
1325
1688
  ] }),
1326
- /* @__PURE__ */ jsxs3("div", { className: cn("toolbar-right", classNames?.toolbarRight), children: [
1327
- hasSelectionContent && (typeof selectionContent === "string" || typeof selectionContent === "number" ? /* @__PURE__ */ jsx4("span", { className: cn("toolbar-selection", classNames?.toolbarSelection), children: selectionContent }) : selectionContent),
1328
- 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 })
1329
1692
  ] })
1330
1693
  ] });
1331
1694
  }
@@ -1339,11 +1702,11 @@ import {
1339
1702
  useVirtualizer
1340
1703
  } from "@tanstack/react-virtual";
1341
1704
  import {
1342
- useCallback as useCallback3,
1343
- useEffect as useEffect5,
1344
- useMemo as useMemo2,
1345
- useRef as useRef5,
1346
- useState as useState3
1705
+ useCallback as useCallback4,
1706
+ useEffect as useEffect6,
1707
+ useMemo as useMemo3,
1708
+ useRef as useRef6,
1709
+ useState as useState4
1347
1710
  } from "react";
1348
1711
 
1349
1712
  // src/components/ui/table/features/cell-edit/useCellEdit.ts
@@ -1672,26 +2035,44 @@ function useCellSelection({
1672
2035
  data,
1673
2036
  rows,
1674
2037
  enabled = true,
2038
+ columnCount = 0,
1675
2039
  enableSubtreeCopy = false,
1676
2040
  enableInsertPaste = true,
1677
2041
  onDataChange,
1678
2042
  onBatchChange,
1679
- onRowsPaste
2043
+ onRowsPaste,
2044
+ onCellNavigate
1680
2045
  }) {
1681
2046
  const [dragState, setDragState] = useState2(INITIAL_DRAG_STATE);
1682
2047
  const pendingPasteModeRef = useRef4(null);
2048
+ const dragStateRef = useRef4(dragState);
2049
+ const onCellNavigateRef = useRef4(onCellNavigate);
2050
+ dragStateRef.current = dragState;
2051
+ onCellNavigateRef.current = onCellNavigate;
1683
2052
  const cellSelectionBounds = getCellSelectionBounds(dragState.start, dragState.end);
1684
2053
  const activeSelectionBounds = enabled ? getActiveSelectionBounds(dragState, cellSelectionBounds) : null;
1685
2054
  const handleCellMouseDown = useCallback2(
1686
- (rowIndex, colIndex) => {
2055
+ (rowIndex, colIndex, options) => {
1687
2056
  if (!enabled) return;
1688
- setDragState({
1689
- isSelecting: true,
1690
- isFillDragging: false,
1691
- start: { row: rowIndex, col: colIndex },
1692
- end: { row: rowIndex, col: colIndex },
1693
- fillAnchor: null,
1694
- 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
+ };
1695
2076
  });
1696
2077
  },
1697
2078
  [enabled]
@@ -1733,6 +2114,53 @@ function useCellSelection({
1733
2114
  setDragState(INITIAL_DRAG_STATE);
1734
2115
  }
1735
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]);
1736
2164
  const copySelection = useCallback2(
1737
2165
  async (options) => {
1738
2166
  if (!enabled || !activeSelectionBounds) return false;
@@ -1890,6 +2318,311 @@ function useCellSelection({
1890
2318
  };
1891
2319
  }
1892
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
+
1893
2626
  // src/components/ui/table/features/row-selection/rowSelection.ts
1894
2627
  function resolveRowSelection(mode, controlledSelection, internalSelection) {
1895
2628
  if (mode === "none") return {};
@@ -1912,7 +2645,12 @@ var DEFAULT_DATA_TABLE_LABELS = {
1912
2645
  selection: (selectedCount) => selectedCount > 0 ? `\u2713 ${selectedCount} selected` : null,
1913
2646
  expandRow: "Expand row",
1914
2647
  collapseRow: "Collapse row",
1915
- 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"
1916
2654
  };
1917
2655
  function resolveDataTableLabels(partial) {
1918
2656
  return {
@@ -1923,6 +2661,7 @@ function resolveDataTableLabels(partial) {
1923
2661
 
1924
2662
  // src/core/useGlideTable.ts
1925
2663
  var EMPTY_COLUMN_FREEZE_OFFSETS = /* @__PURE__ */ new Map();
2664
+ var EMPTY_SEARCH_MATCH_KEYS = /* @__PURE__ */ new Set();
1926
2665
  function useGlideTable(options) {
1927
2666
  const {
1928
2667
  data,
@@ -1963,9 +2702,16 @@ function useGlideTable(options) {
1963
2702
  columnSizing: controlledColumnSizing,
1964
2703
  onColumnSizingChange,
1965
2704
  columnResizeMode = "onChange",
1966
- enableColumnFreeze = false
2705
+ enableColumnFreeze = false,
2706
+ enableInlineSearch = false,
2707
+ showSearch,
2708
+ searchValue,
2709
+ onSearchValueChange,
2710
+ onSearchClose,
2711
+ searchResults,
2712
+ onSearchResultsChanged
1967
2713
  } = options;
1968
- const labels = useMemo2(() => {
2714
+ const labels = useMemo3(() => {
1969
2715
  const resolved = resolveDataTableLabels(labelsProp);
1970
2716
  return {
1971
2717
  ...resolved,
@@ -1976,15 +2722,16 @@ function useGlideTable(options) {
1976
2722
  }, [labelsProp, emptyText, loadingText, selectionLabel]);
1977
2723
  const enableExpand = Boolean(toggleField);
1978
2724
  const resolvedEnableSubtreeCopy = enableSubtreeCopy ?? enableExpand;
1979
- const [internalRowSelection, setInternalRowSelection] = useState3({});
1980
- const [internalColumnSizing, setInternalColumnSizing] = useState3({});
1981
- const [internalExpandedRows, setInternalExpandedRows] = useState3(
2725
+ const [internalRowSelection, setInternalRowSelection] = useState4({});
2726
+ const [internalColumnSizing, setInternalColumnSizing] = useState4({});
2727
+ const [internalExpandedRows, setInternalExpandedRows] = useState4(
1982
2728
  () => /* @__PURE__ */ new Set()
1983
2729
  );
1984
- const [hoveredRowIndex, setHoveredRowIndex] = useState3(null);
1985
- const scrollRef = useRef5(null);
2730
+ const [hoveredRowIndex, setHoveredRowIndex] = useState4(null);
2731
+ const scrollRef = useRef6(null);
2732
+ const rootRef = useRef6(null);
1986
2733
  const shouldVirtualize = enableVirtualization && !enableRowSpan;
1987
- useEffect5(() => {
2734
+ useEffect6(() => {
1988
2735
  if (enableVirtualization && enableRowSpan) {
1989
2736
  console.warn(
1990
2737
  "[useGlideTable] enableRowSpan is on; virtualization is disabled to preserve cell merges."
@@ -1998,7 +2745,7 @@ function useGlideTable(options) {
1998
2745
  );
1999
2746
  const columnSizing = controlledColumnSizing ?? internalColumnSizing;
2000
2747
  const expandedRows = controlledExpandedRows ?? internalExpandedRows;
2001
- const handleExpandedRowsChange = useCallback3(
2748
+ const handleExpandedRowsChange = useCallback4(
2002
2749
  (next) => {
2003
2750
  if (onExpandedRowsChange) {
2004
2751
  onExpandedRowsChange(next);
@@ -2059,13 +2806,13 @@ function useGlideTable(options) {
2059
2806
  getCoreRowModel: getCoreRowModel(),
2060
2807
  getRowId: getRowId ? (originalRow, index) => getRowId(originalRow, index) : (_originalRow, index) => String(index)
2061
2808
  });
2062
- const rowSpanColumnKeys = useMemo2(() => {
2809
+ const rowSpanColumnKeys = useMemo3(() => {
2063
2810
  if (!enableRowSpan) return [];
2064
2811
  return collectRowSpanColumns(columns);
2065
2812
  }, [enableRowSpan, columns]);
2066
2813
  const primaryRowSpanKey = rowSpanColumnKeys[0]?.rowSpanKey;
2067
2814
  const primaryRowSpanColumnId = rowSpanColumnKeys[0]?.columnId;
2068
- const columnRowSpanMap = useMemo2(
2815
+ const columnRowSpanMap = useMemo3(
2069
2816
  () => buildColumnRowSpanMap(tableData, rowSpanColumnKeys),
2070
2817
  [tableData, rowSpanColumnKeys]
2071
2818
  );
@@ -2074,7 +2821,7 @@ function useGlideTable(options) {
2074
2821
  const rows = table.getRowModel().rows;
2075
2822
  const columnCount = table.getAllLeafColumns().length || 1;
2076
2823
  const visibleLeafColumns = table.getVisibleLeafColumns();
2077
- const columnFreezeOffsets = useMemo2(() => {
2824
+ const columnFreezeOffsets = useMemo3(() => {
2078
2825
  if (!enableColumnFreeze) return EMPTY_COLUMN_FREEZE_OFFSETS;
2079
2826
  return buildColumnFreezeOffsets(
2080
2827
  visibleLeafColumns.map((column) => ({
@@ -2094,13 +2841,46 @@ function useGlideTable(options) {
2094
2841
  const totalSize = rowVirtualizer.getTotalSize();
2095
2842
  const paddingTop = virtualRows.length > 0 ? virtualRows[0]?.start ?? 0 : 0;
2096
2843
  const paddingBottom = virtualRows.length > 0 ? totalSize - (virtualRows[virtualRows.length - 1]?.end ?? 0) : 0;
2097
- const selectedRowIndices = useMemo2(() => {
2844
+ const selectedRowIndices = useMemo3(() => {
2098
2845
  const indices = /* @__PURE__ */ new Set();
2099
2846
  for (const selectedRow of selectedRows) {
2100
2847
  indices.add(selectedRow.index);
2101
2848
  }
2102
2849
  return indices;
2103
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
+ );
2104
2884
  const {
2105
2885
  dragState,
2106
2886
  activeSelectionBounds,
@@ -2112,11 +2892,13 @@ function useGlideTable(options) {
2112
2892
  data: tableData,
2113
2893
  rows,
2114
2894
  enabled: enableCellSelection,
2895
+ columnCount: visibleLeafColumns.length,
2115
2896
  enableSubtreeCopy: resolvedEnableSubtreeCopy,
2116
2897
  enableInsertPaste: enableInsertPaste ?? true,
2117
2898
  onDataChange,
2118
2899
  onBatchChange,
2119
- onRowsPaste
2900
+ onRowsPaste,
2901
+ onCellNavigate: handleCellNavigate
2120
2902
  });
2121
2903
  const {
2122
2904
  editingCell,
@@ -2126,23 +2908,193 @@ function useGlideTable(options) {
2126
2908
  commitEdit,
2127
2909
  cancelEdit
2128
2910
  } = useCellEdit({ data: tableData, rows, onDataChange, onCellChange });
2129
- const handleCellMouseDownWithCommit = useCallback3(
2130
- (rowIndex, colIndex) => {
2911
+ const handleCellMouseDownWithCommit = useCallback4(
2912
+ (rowIndex, colIndex, options2) => {
2131
2913
  const isSameEditingCell = editingCell?.rowIndex === rowIndex && editingCell?.colIndex === colIndex;
2132
2914
  if (editingCell && !isSameEditingCell && !commitEdit()) {
2133
2915
  return;
2134
2916
  }
2135
- handleCellMouseDown(rowIndex, colIndex);
2917
+ handleCellMouseDown(rowIndex, colIndex, options2);
2136
2918
  },
2137
2919
  [commitEdit, editingCell, handleCellMouseDown]
2138
2920
  );
2139
- 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(() => {
2140
3092
  setHoveredRowIndex(null);
2141
3093
  }, []);
2142
- const handleRowHover = useCallback3((rowIndex, _rowData) => {
3094
+ const handleRowHover = useCallback4((rowIndex, _rowData) => {
2143
3095
  setHoveredRowIndex(rowIndex);
2144
3096
  }, []);
2145
- const handleToggleSelect = useCallback3(
3097
+ const handleToggleSelect = useCallback4(
2146
3098
  (row) => {
2147
3099
  if (!row.getCanSelect()) return;
2148
3100
  if (preserveRowSelection && row.getIsSelected()) {
@@ -2152,14 +3104,14 @@ function useGlideTable(options) {
2152
3104
  },
2153
3105
  [preserveRowSelection]
2154
3106
  );
2155
- const handleToggleExpand = useCallback3(
3107
+ const handleToggleExpand = useCallback4(
2156
3108
  (rowKey) => {
2157
3109
  if (preventExpand) return;
2158
3110
  handleExpandedRowsChange(toggleExpandedRowId(rowKey, expandedRows));
2159
3111
  },
2160
3112
  [preventExpand, handleExpandedRowsChange, expandedRows]
2161
3113
  );
2162
- const rowContextValue = useMemo2(() => {
3114
+ const rowContextValue = useMemo3(() => {
2163
3115
  return {
2164
3116
  rowSpan: {
2165
3117
  enableRowSpan,
@@ -2207,6 +3159,11 @@ function useGlideTable(options) {
2207
3159
  columnFreeze: {
2208
3160
  enableColumnFreeze,
2209
3161
  offsets: columnFreezeOffsets
3162
+ },
3163
+ inlineSearch: {
3164
+ enabled: enableInlineSearch,
3165
+ matchKeys: visibleSearchMatchKeys,
3166
+ activeMatch: visibleActiveMatch
2210
3167
  }
2211
3168
  };
2212
3169
  }, [
@@ -2242,14 +3199,17 @@ function useGlideTable(options) {
2242
3199
  labels.collapseRow,
2243
3200
  enableColumnResize,
2244
3201
  enableColumnFreeze,
2245
- columnFreezeOffsets
3202
+ columnFreezeOffsets,
3203
+ enableInlineSearch,
3204
+ visibleSearchMatchKeys,
3205
+ visibleActiveMatch
2246
3206
  ]);
2247
- const copySelectionRef = useRef5(copySelection);
2248
- useEffect5(() => {
3207
+ const copySelectionRef = useRef6(copySelection);
3208
+ useEffect6(() => {
2249
3209
  copySelectionRef.current = copySelection;
2250
3210
  }, [copySelection]);
2251
- const stableCopySelection = useCallback3((options2) => copySelectionRef.current(options2), []);
2252
- useEffect5(() => {
3211
+ const stableCopySelection = useCallback4((options2) => copySelectionRef.current(options2), []);
3212
+ useEffect6(() => {
2253
3213
  onCopyActionsReady?.({ copySelection: stableCopySelection });
2254
3214
  }, [onCopyActionsReady, stableCopySelection]);
2255
3215
  return {
@@ -2265,8 +3225,10 @@ function useGlideTable(options) {
2265
3225
  enableCellSelection,
2266
3226
  enableColumnResize,
2267
3227
  enableColumnFreeze,
3228
+ enableInlineSearch,
2268
3229
  shouldVirtualize,
2269
3230
  scrollRef,
3231
+ rootRef,
2270
3232
  rowVirtualizer,
2271
3233
  virtualRows,
2272
3234
  paddingTop,
@@ -2274,25 +3236,39 @@ function useGlideTable(options) {
2274
3236
  rowContextValue,
2275
3237
  handleToggleSelect,
2276
3238
  clearHover,
2277
- 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
+ }
2278
3254
  };
2279
3255
  }
2280
3256
 
2281
3257
  // src/components/ui/table/components/DataTable/DataTable.tsx
2282
- 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";
2283
3259
  function DefaultScroll({
2284
3260
  scrollRef,
2285
3261
  children,
2286
3262
  className
2287
3263
  }) {
2288
- 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 });
2289
3265
  }
2290
3266
  function DefaultPending({
2291
3267
  loadingText,
2292
3268
  className,
2293
3269
  classNames
2294
3270
  }) {
2295
- return /* @__PURE__ */ jsx5(
3271
+ return /* @__PURE__ */ jsx6(
2296
3272
  "div",
2297
3273
  {
2298
3274
  className: cn(
@@ -2302,7 +3278,7 @@ function DefaultPending({
2302
3278
  classNames?.pending,
2303
3279
  className
2304
3280
  ),
2305
- 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 })
2306
3282
  }
2307
3283
  );
2308
3284
  }
@@ -2311,7 +3287,7 @@ function DefaultEmpty({
2311
3287
  columnCount,
2312
3288
  classNames
2313
3289
  }) {
2314
- return /* @__PURE__ */ jsx5("tr", { children: /* @__PURE__ */ jsx5(
3290
+ return /* @__PURE__ */ jsx6("tr", { children: /* @__PURE__ */ jsx6(
2315
3291
  "td",
2316
3292
  {
2317
3293
  colSpan: columnCount,
@@ -2344,15 +3320,18 @@ function DataTable({
2344
3320
  enableCellSelection,
2345
3321
  enableColumnResize,
2346
3322
  enableColumnFreeze,
3323
+ enableInlineSearch,
2347
3324
  shouldVirtualize,
2348
3325
  scrollRef,
3326
+ rootRef,
2349
3327
  rowVirtualizer,
2350
3328
  virtualRows,
2351
3329
  paddingTop,
2352
3330
  paddingBottom,
2353
3331
  rowContextValue,
2354
3332
  handleToggleSelect,
2355
- clearHover
3333
+ clearHover,
3334
+ inlineSearch
2356
3335
  } = useGlideTable(glideOptions);
2357
3336
  const ToolbarSlot = slots?.Toolbar ?? DataTableToolbar;
2358
3337
  const ScrollSlot = slots?.Scroll ?? DefaultScroll;
@@ -2360,12 +3339,12 @@ function DataTable({
2360
3339
  const PendingSlot = slots?.Pending ?? DefaultPending;
2361
3340
  const EmptySlot = slots?.Empty ?? DefaultEmpty;
2362
3341
  const freezeOffsets = rowContextValue.columnFreeze.offsets;
2363
- const contextValue = useMemo3(
3342
+ const contextValue = useMemo4(
2364
3343
  () => ({ ...rowContextValue, classNames }),
2365
3344
  [rowContextValue, classNames]
2366
3345
  );
2367
3346
  if (isPending) {
2368
- return /* @__PURE__ */ jsx5(
3347
+ return /* @__PURE__ */ jsx6(
2369
3348
  PendingSlot,
2370
3349
  {
2371
3350
  loadingText,
@@ -2374,19 +3353,21 @@ function DataTable({
2374
3353
  }
2375
3354
  );
2376
3355
  }
2377
- return /* @__PURE__ */ jsxs4(
3356
+ return /* @__PURE__ */ jsxs5(
2378
3357
  "div",
2379
3358
  {
3359
+ ref: rootRef,
2380
3360
  className: cn(
2381
3361
  "DataTableJSX",
2382
3362
  !enableCellSelection && "DataTableJSX--no-cell-selection",
2383
3363
  enableColumnResize && "DataTableJSX--column-resize",
2384
3364
  enableColumnFreeze && "DataTableJSX--column-freeze",
3365
+ enableInlineSearch && "DataTableJSX--inline-search",
2385
3366
  classNames?.root,
2386
3367
  className
2387
3368
  ),
2388
3369
  children: [
2389
- /* @__PURE__ */ jsx5(
3370
+ /* @__PURE__ */ jsx6(
2390
3371
  ToolbarSlot,
2391
3372
  {
2392
3373
  filteredCount: filteredCount ?? tableData.length,
@@ -2398,14 +3379,36 @@ function DataTable({
2398
3379
  classNames
2399
3380
  }
2400
3381
  ),
2401
- /* @__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(
2402
3405
  "table",
2403
3406
  {
2404
3407
  className: cn("data-table", classNames?.table),
2405
3408
  style: enableColumnResize ? { width: table.getTotalSize() } : void 0,
2406
3409
  onDragStart: enableCellSelection ? (event) => event.preventDefault() : void 0,
2407
3410
  children: [
2408
- /* @__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(
2409
3412
  "tr",
2410
3413
  {
2411
3414
  className: cn("data-table-head-row", classNames?.headRow),
@@ -2425,7 +3428,7 @@ function DataTable({
2425
3428
  ...sizeStyle,
2426
3429
  ...freezeStyle
2427
3430
  };
2428
- return /* @__PURE__ */ jsxs4(
3431
+ return /* @__PURE__ */ jsxs5(
2429
3432
  "th",
2430
3433
  {
2431
3434
  "data-resizing": header.column.getIsResizing() ? "" : void 0,
@@ -2441,7 +3444,7 @@ function DataTable({
2441
3444
  ),
2442
3445
  children: [
2443
3446
  header.isPlaceholder ? null : flexRender2(header.column.columnDef.header, header.getContext()),
2444
- canResize ? /* @__PURE__ */ jsx5(
3447
+ canResize ? /* @__PURE__ */ jsx6(
2445
3448
  "div",
2446
3449
  {
2447
3450
  role: "separator",
@@ -2467,20 +3470,20 @@ function DataTable({
2467
3470
  },
2468
3471
  headerGroup.id
2469
3472
  )) }),
2470
- /* @__PURE__ */ jsx5(DataTableContextProvider, { value: contextValue, children: /* @__PURE__ */ jsx5(
3473
+ /* @__PURE__ */ jsx6(DataTableContextProvider, { value: contextValue, children: /* @__PURE__ */ jsx6(
2471
3474
  "tbody",
2472
3475
  {
2473
3476
  onMouseLeave: clearHover,
2474
3477
  className: cn("data-table-body", classNames?.body),
2475
- children: rows.length === 0 ? /* @__PURE__ */ jsx5(
3478
+ children: rows.length === 0 ? /* @__PURE__ */ jsx6(
2476
3479
  EmptySlot,
2477
3480
  {
2478
3481
  emptyText,
2479
3482
  columnCount,
2480
3483
  classNames
2481
3484
  }
2482
- ) : shouldVirtualize ? /* @__PURE__ */ jsxs4(Fragment2, { children: [
2483
- paddingTop > 0 && /* @__PURE__ */ jsx5(
3485
+ ) : shouldVirtualize ? /* @__PURE__ */ jsxs5(Fragment2, { children: [
3486
+ paddingTop > 0 && /* @__PURE__ */ jsx6(
2484
3487
  "tr",
2485
3488
  {
2486
3489
  "aria-hidden": true,
@@ -2488,7 +3491,7 @@ function DataTable({
2488
3491
  "data-table-virtual-spacer",
2489
3492
  classNames?.virtualSpacer
2490
3493
  ),
2491
- children: /* @__PURE__ */ jsx5(
3494
+ children: /* @__PURE__ */ jsx6(
2492
3495
  "td",
2493
3496
  {
2494
3497
  colSpan: columnCount,
@@ -2504,7 +3507,7 @@ function DataTable({
2504
3507
  virtualRows.map((virtualRow) => {
2505
3508
  const row = rows[virtualRow.index];
2506
3509
  if (!row) return null;
2507
- return /* @__PURE__ */ jsx5(
3510
+ return /* @__PURE__ */ jsx6(
2508
3511
  RowSlot,
2509
3512
  {
2510
3513
  row,
@@ -2515,7 +3518,7 @@ function DataTable({
2515
3518
  row.id
2516
3519
  );
2517
3520
  }),
2518
- paddingBottom > 0 && /* @__PURE__ */ jsx5(
3521
+ paddingBottom > 0 && /* @__PURE__ */ jsx6(
2519
3522
  "tr",
2520
3523
  {
2521
3524
  "aria-hidden": true,
@@ -2523,7 +3526,7 @@ function DataTable({
2523
3526
  "data-table-virtual-spacer",
2524
3527
  classNames?.virtualSpacer
2525
3528
  ),
2526
- children: /* @__PURE__ */ jsx5(
3529
+ children: /* @__PURE__ */ jsx6(
2527
3530
  "td",
2528
3531
  {
2529
3532
  colSpan: columnCount,
@@ -2536,7 +3539,7 @@ function DataTable({
2536
3539
  )
2537
3540
  }
2538
3541
  )
2539
- ] }) : rows.map((row) => /* @__PURE__ */ jsx5(
3542
+ ] }) : rows.map((row) => /* @__PURE__ */ jsx6(
2540
3543
  RowSlot,
2541
3544
  {
2542
3545
  row,
@@ -2555,10 +3558,10 @@ function DataTable({
2555
3558
  }
2556
3559
 
2557
3560
  // src/components/ui/table/components/Table/Table.tsx
2558
- 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";
2559
3562
 
2560
3563
  // src/components/ui/table/components/Table/buildColumnDef.tsx
2561
- import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
3564
+ import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
2562
3565
  function SortableHeader({
2563
3566
  label,
2564
3567
  field,
@@ -2567,15 +3570,15 @@ function SortableHeader({
2567
3570
  }) {
2568
3571
  const isActive = sort?.field === field;
2569
3572
  const Icon = isActive ? sort.direction === "asc" ? ArrowUp : ArrowDown : ArrowUpDown;
2570
- return /* @__PURE__ */ jsxs5(
3573
+ return /* @__PURE__ */ jsxs6(
2571
3574
  "button",
2572
3575
  {
2573
3576
  type: "button",
2574
3577
  className: cn("SortableHeaderJSX", isActive ? "is-active" : "is-inactive"),
2575
3578
  onClick: () => onSort(field),
2576
3579
  children: [
2577
- /* @__PURE__ */ jsx6("span", { children: label }),
2578
- /* @__PURE__ */ jsx6(Icon, { className: "sortable-header-icon" })
3580
+ /* @__PURE__ */ jsx7("span", { children: label }),
3581
+ /* @__PURE__ */ jsx7(Icon, { className: "sortable-header-icon" })
2579
3582
  ]
2580
3583
  }
2581
3584
  );
@@ -2608,7 +3611,7 @@ function buildColumnDef(props, sort, onSort) {
2608
3611
  ...minWidth != null ? { minSize: minWidth } : {},
2609
3612
  ...maxWidth != null ? { maxSize: maxWidth } : {},
2610
3613
  ...resizable === false ? { enableResizing: false } : {},
2611
- header: sortable ? () => /* @__PURE__ */ jsx6(SortableHeader, { label: children, field, sort, onSort }) : (
3614
+ header: sortable ? () => /* @__PURE__ */ jsx7(SortableHeader, { label: children, field, sort, onSort }) : (
2612
3615
  // eslint-disable-next-line @typescript-eslint/promise-function-async
2613
3616
  () => children
2614
3617
  ),
@@ -2756,7 +3759,7 @@ function TableHeader(props) {
2756
3759
  TableHeader.displayName = TABLE_HEADER_DISPLAY_NAME;
2757
3760
 
2758
3761
  // src/components/ui/table/components/Table/TablePagination.tsx
2759
- import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
3762
+ import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
2760
3763
  function TablePagination({
2761
3764
  page,
2762
3765
  pageSize = 10,
@@ -2768,8 +3771,8 @@ function TablePagination({
2768
3771
  const safePage = Math.min(Math.max(1, page), totalPages);
2769
3772
  const canGoPrev = safePage > 1;
2770
3773
  const canGoNext = safePage < totalPages;
2771
- return /* @__PURE__ */ jsxs6("div", { className: cn("TablePaginationJSX", className), children: [
2772
- /* @__PURE__ */ jsx7(
3774
+ return /* @__PURE__ */ jsxs7("div", { className: cn("TablePaginationJSX", className), children: [
3775
+ /* @__PURE__ */ jsx8(
2773
3776
  "button",
2774
3777
  {
2775
3778
  type: "button",
@@ -2777,15 +3780,15 @@ function TablePagination({
2777
3780
  disabled: !canGoPrev,
2778
3781
  onClick: () => onChange(safePage - 1),
2779
3782
  "aria-label": "Previous page",
2780
- children: /* @__PURE__ */ jsx7(ChevronLeft, { className: "pagination-button-icon" })
3783
+ children: /* @__PURE__ */ jsx8(ChevronLeft, { className: "pagination-button-icon" })
2781
3784
  }
2782
3785
  ),
2783
- /* @__PURE__ */ jsxs6("span", { className: "pagination-label", children: [
3786
+ /* @__PURE__ */ jsxs7("span", { className: "pagination-label", children: [
2784
3787
  safePage,
2785
3788
  " / ",
2786
3789
  totalPages
2787
3790
  ] }),
2788
- /* @__PURE__ */ jsx7(
3791
+ /* @__PURE__ */ jsx8(
2789
3792
  "button",
2790
3793
  {
2791
3794
  type: "button",
@@ -2793,7 +3796,7 @@ function TablePagination({
2793
3796
  disabled: !canGoNext,
2794
3797
  onClick: () => onChange(safePage + 1),
2795
3798
  "aria-label": "Next page",
2796
- children: /* @__PURE__ */ jsx7(ChevronRight, { className: "pagination-button-icon" })
3799
+ children: /* @__PURE__ */ jsx8(ChevronRight, { className: "pagination-button-icon" })
2797
3800
  }
2798
3801
  )
2799
3802
  ] });
@@ -2801,7 +3804,7 @@ function TablePagination({
2801
3804
  TablePagination.displayName = TABLE_PAGINATION_DISPLAY_NAME;
2802
3805
 
2803
3806
  // src/components/ui/table/components/Table/Table.tsx
2804
- import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
3807
+ import { jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
2805
3808
  function TableRoot({
2806
3809
  data,
2807
3810
  children,
@@ -2810,12 +3813,12 @@ function TableRoot({
2810
3813
  filteredCount,
2811
3814
  ...dataTableProps
2812
3815
  }) {
2813
- const { header, pagination: paginationElement } = useMemo4(
3816
+ const { header, pagination: paginationElement } = useMemo5(
2814
3817
  () => parseTableChildren(children),
2815
3818
  [children]
2816
3819
  );
2817
- const [sort, setSort] = useState4(null);
2818
- const handleSort = useCallback4((field) => {
3820
+ const [sort, setSort] = useState5(null);
3821
+ const handleSort = useCallback5((field) => {
2819
3822
  setSort((previous) => {
2820
3823
  if (previous?.field !== field) {
2821
3824
  return { field, direction: "asc" };
@@ -2826,7 +3829,7 @@ function TableRoot({
2826
3829
  return null;
2827
3830
  });
2828
3831
  }, []);
2829
- const columns = useMemo4(() => {
3832
+ const columns = useMemo5(() => {
2830
3833
  return extractColumnElements(header).map(
2831
3834
  (columnElement) => buildColumnDef(columnElement.props, sort, handleSort)
2832
3835
  );
@@ -2835,7 +3838,7 @@ function TableRoot({
2835
3838
  const pageSize = paginationProps?.pageSize ?? 10;
2836
3839
  const page = paginationProps?.page ?? 1;
2837
3840
  const resolvedTotalCount = paginationProps?.totalCount ?? totalCount ?? data.length;
2838
- const tableData = useMemo4(() => {
3841
+ const tableData = useMemo5(() => {
2839
3842
  const sortedData = sortTableData(data, sort);
2840
3843
  if (!paginationProps) return sortedData;
2841
3844
  return paginateTableData(sortedData, page, pageSize);
@@ -2843,8 +3846,8 @@ function TableRoot({
2843
3846
  if (columns.length === 0) {
2844
3847
  console.warn("[Table] Declare at least one Table.Column inside Table.Header.");
2845
3848
  }
2846
- return /* @__PURE__ */ jsxs7("div", { className: "TableJSX", children: [
2847
- /* @__PURE__ */ jsx8(
3849
+ return /* @__PURE__ */ jsxs8("div", { className: "TableJSX", children: [
3850
+ /* @__PURE__ */ jsx9(
2848
3851
  DataTable,
2849
3852
  {
2850
3853
  ...dataTableProps,
@@ -2855,7 +3858,7 @@ function TableRoot({
2855
3858
  className: cn(className, paginationProps && "DataTableJSX--with-pagination")
2856
3859
  }
2857
3860
  ),
2858
- paginationProps && /* @__PURE__ */ jsx8(
3861
+ paginationProps && /* @__PURE__ */ jsx9(
2859
3862
  TablePagination,
2860
3863
  {
2861
3864
  page,
@@ -2875,7 +3878,7 @@ function createTable() {
2875
3878
  Column.displayName = TABLE_COLUMN_DISPLAY_NAME;
2876
3879
  return Object.assign(
2877
3880
  function BoundTable(props) {
2878
- return /* @__PURE__ */ jsx8(TableRoot, { ...props });
3881
+ return /* @__PURE__ */ jsx9(TableRoot, { ...props });
2879
3882
  },
2880
3883
  {
2881
3884
  Header: TableHeader,