@sustaina/shared-ui 1.69.0 → 1.70.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/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import React__default, { forwardRef, memo, isValidElement, useMemo, useRef, useEffect, useCallback, useLayoutEffect, useState, createElement } from 'react';
2
+ import React__default, { forwardRef, memo, createElement, isValidElement, useMemo, useRef, useEffect, useCallback, useLayoutEffect, useState } from 'react';
3
3
  import { useRouter } from '@tanstack/react-router';
4
4
  import { create } from 'zustand';
5
5
  import clsx2, { clsx } from 'clsx';
@@ -23,7 +23,7 @@ import { useVirtualizer } from '@tanstack/react-virtual';
23
23
  import * as TooltipPrimitive from '@radix-ui/react-tooltip';
24
24
  import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
25
25
  import * as CollapsiblePrimitive from '@radix-ui/react-collapsible';
26
- import { reSplitAlphaNumeric, useReactTable, getCoreRowModel, getGroupedRowModel, getExpandedRowModel, getSortedRowModel, getFilteredRowModel, flexRender } from '@tanstack/react-table';
26
+ import { flexRender, reSplitAlphaNumeric, useReactTable, getCoreRowModel, getGroupedRowModel, getExpandedRowModel, getSortedRowModel, getFilteredRowModel } from '@tanstack/react-table';
27
27
  import { initReactI18next, useTranslation, I18nextProvider } from 'react-i18next';
28
28
  import i18n from 'i18next';
29
29
  import StarterKit from '@tiptap/starter-kit';
@@ -8977,7 +8977,7 @@ var HeaderCell = ({
8977
8977
  {
8978
8978
  ref,
8979
8979
  className: cn(
8980
- "flex items-center justify-between gap-2",
8980
+ "flex items-center justify-between gap-2 h-full",
8981
8981
  {
8982
8982
  "cursor-pointer": context?.column?.getCanSort()
8983
8983
  },
@@ -9005,13 +9005,17 @@ var HeaderCell = ({
9005
9005
  showSorter && /* @__PURE__ */ jsxs(
9006
9006
  "div",
9007
9007
  {
9008
- className: "flex flex-col -space-y-2",
9008
+ className: cn(
9009
+ "flex flex-col -space-y-2 transition-opacity duration-150",
9010
+ sorterProps?.rootClassName
9011
+ ),
9012
+ style: { opacity: hovering || !!context.column.getIsSorted() ? 1 : 0.35 },
9009
9013
  title: context.column.getCanSort() ? context.column.getNextSortingOrder() === "asc" ? "Sort ascending" : context.column.getNextSortingOrder() === "desc" ? "Sort descending" : "Clear sort" : void 0,
9010
9014
  children: [
9011
9015
  /* @__PURE__ */ jsx(
9012
9016
  ChevronUp,
9013
9017
  {
9014
- className: cn("stroke-[#BBBBBB]", {
9018
+ className: cn("stroke-[#BBBBBB] transition-colors duration-200", {
9015
9019
  "stroke-sus-gray-5": context?.column?.getIsSorted() === "asc",
9016
9020
  "stroke-sus-gray-5/45": context?.column?.getNextSortingOrder() === "asc" && hovering
9017
9021
  }),
@@ -9022,7 +9026,7 @@ var HeaderCell = ({
9022
9026
  /* @__PURE__ */ jsx(
9023
9027
  ChevronDown,
9024
9028
  {
9025
- className: cn("stroke-[#BBBBBB]", {
9029
+ className: cn("stroke-[#BBBBBB] transition-colors duration-200", {
9026
9030
  "stroke-sus-gray-5": context?.column?.getIsSorted() === "desc",
9027
9031
  "stroke-sus-gray-5/45": context?.column?.getNextSortingOrder() === "desc" && hovering
9028
9032
  }),
@@ -9098,7 +9102,7 @@ function TableHead({ className, ...props }) {
9098
9102
  {
9099
9103
  "data-slot": "table-head",
9100
9104
  className: cn(
9101
- "text-foreground h-9 px-2 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 *:[[role=checkbox]]:translate-y-0.5 hover:bg-gray-200 bg-[#F0F0F0] truncate",
9105
+ "text-foreground h-9 px-2 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 *:[[role=checkbox]]:translate-y-0.5 hover:bg-gray-200 bg-[#F0F0F0] truncate transition-colors duration-150",
9102
9106
  className
9103
9107
  ),
9104
9108
  ...props
@@ -9457,8 +9461,13 @@ var useScrollFetch = ({ scrollFetch, containerRef }) => {
9457
9461
  }, [fetchMoreOnScrollReached, containerRef]);
9458
9462
  return fetchMoreOnScrollReached;
9459
9463
  };
9464
+
9465
+ // src/components/data-table/constants.ts
9460
9466
  var DEFAULT_ROW_HEIGHT = 40;
9461
9467
  var DEFAULT_OVER_SCAN = 10;
9468
+ var DEFAULT_COLUMN_OVERSCAN = 1;
9469
+
9470
+ // src/components/data-table/hooks/useTableVirtualizer.ts
9462
9471
  var useTableVirtualizer = ({
9463
9472
  enabled,
9464
9473
  table,
@@ -9466,23 +9475,50 @@ var useTableVirtualizer = ({
9466
9475
  virtual
9467
9476
  }) => {
9468
9477
  const rowModel = table.getRowModel().rows;
9478
+ const columnsEnabled = virtual?.columns?.enabled ?? false;
9479
+ const centerColumns = table.getCenterVisibleLeafColumns();
9480
+ const getRowVirtualItemKey = useCallback((index) => rowModel[index]?.id ?? index, [rowModel]);
9481
+ const getColumnVirtualItemKey = useCallback(
9482
+ (index) => centerColumns[index]?.id ?? index,
9483
+ [centerColumns]
9484
+ );
9469
9485
  const virtualizer = useVirtualizer({
9470
9486
  count: enabled ? rowModel.length : 0,
9471
9487
  useFlushSync: false,
9472
9488
  getScrollElement: () => containerRef.current,
9473
9489
  estimateSize: () => DEFAULT_ROW_HEIGHT,
9490
+ getItemKey: getRowVirtualItemKey,
9474
9491
  measureElement: typeof window !== "undefined" && navigator.userAgent.indexOf("Firefox") === -1 ? (element) => element?.getBoundingClientRect().height : void 0,
9475
9492
  overscan: virtual?.overscan ?? DEFAULT_OVER_SCAN
9476
9493
  });
9494
+ const columnVirtualizer = useVirtualizer({
9495
+ count: columnsEnabled ? centerColumns.length : 0,
9496
+ estimateSize: (index) => centerColumns[index]?.getSize() ?? 0,
9497
+ getScrollElement: () => containerRef.current,
9498
+ horizontal: true,
9499
+ getItemKey: getColumnVirtualItemKey,
9500
+ overscan: virtual?.columns?.overscan ?? DEFAULT_COLUMN_OVERSCAN
9501
+ });
9477
9502
  const virtualItems = enabled ? virtualizer.getVirtualItems() : [];
9478
9503
  const paddingTop = enabled && virtualItems.length > 0 ? virtualItems[0].start : 0;
9479
9504
  const paddingBottom = enabled && virtualItems.length > 0 ? virtualizer.getTotalSize() - virtualItems[virtualItems.length - 1].end : 0;
9505
+ let columnVirtual;
9506
+ if (!columnsEnabled) {
9507
+ columnVirtual = { enabled: false };
9508
+ } else {
9509
+ const virtualColumns = columnVirtualizer.getVirtualItems();
9510
+ const virtualPaddingLeft = virtualColumns[0]?.start ?? 0;
9511
+ const virtualPaddingRight = columnVirtualizer.getTotalSize() - (virtualColumns[virtualColumns.length - 1]?.end ?? 0);
9512
+ columnVirtual = { enabled: true, virtualColumns, virtualPaddingLeft, virtualPaddingRight };
9513
+ }
9480
9514
  return {
9481
9515
  virtualizer,
9516
+ columnVirtualizer,
9482
9517
  virtualItems,
9483
9518
  paddingTop,
9484
9519
  paddingBottom,
9485
- rowModel
9520
+ rowModel,
9521
+ columnVirtual
9486
9522
  };
9487
9523
  };
9488
9524
  function useComputedTableState({
@@ -9585,6 +9621,7 @@ var ColumnSeparator = ({ show, className, ...props }) => {
9585
9621
  var ColumnSeparator_default = React__default.memo(ColumnSeparator);
9586
9622
 
9587
9623
  // src/components/data-table/helpers.ts
9624
+ var toCSSId = (id) => id.replace(/[^a-zA-Z0-9_-]/g, "-");
9588
9625
  function getColumnPinningInfo(column) {
9589
9626
  const isPinned = column.getIsPinned();
9590
9627
  const isLastLeftPinnedColumn = isPinned === "left" && column.getIsLastColumn("left");
@@ -9595,8 +9632,8 @@ function getColumnPinningStyles(column) {
9595
9632
  const { isPinned, isFirstRightPinnedColumn, isLastLeftPinnedColumn } = getColumnPinningInfo(column);
9596
9633
  const classes = cn(isPinned ? "sticky" : "relative");
9597
9634
  const style = {
9598
- left: isPinned === "left" ? column.getStart("left") : void 0,
9599
- right: isPinned === "right" ? column.getAfter("right") : void 0,
9635
+ left: isPinned === "left" ? `calc(var(--col-${toCSSId(column.id)}-pin-start, ${column.getStart("left")}) * 1px)` : void 0,
9636
+ right: isPinned === "right" ? `calc(var(--col-${toCSSId(column.id)}-pin-after, ${column.getAfter("right")}) * 1px)` : void 0,
9600
9637
  zIndex: isPinned ? 1 : 0,
9601
9638
  boxShadow: isLastLeftPinnedColumn ? "inset -1px 0 0 0 black" : isFirstRightPinnedColumn ? "inset 1px 0 0 0 black" : void 0
9602
9639
  };
@@ -9615,102 +9652,223 @@ function getRowClickHandlers(handler, { rowData, row, table }) {
9615
9652
  onClick: handleClick
9616
9653
  };
9617
9654
  }
9655
+ function renderHeaderCell(header, headerGroup, {
9656
+ columnResizing,
9657
+ virtual,
9658
+ components,
9659
+ table
9660
+ }, rowSpan) {
9661
+ const { classes, style } = getColumnPinningStyles(header.column);
9662
+ const useColumnSizing = header.column.columnDef?.meta?.useColumnSizing ?? columnResizing?.enabled ?? virtual?.enabled ?? false;
9663
+ const tableHeadCellProps = typeof components?.tableHeadCellProps === "function" ? components?.tableHeadCellProps({ header, table }) : components?.tableHeadCellProps;
9664
+ const nextHeader = headerGroup.headers?.[header.index + 1] || header;
9665
+ const { isLastLeftPinnedColumn } = getColumnPinningInfo(header.column);
9666
+ const { isFirstRightPinnedColumn } = getColumnPinningInfo(nextHeader.column);
9667
+ const headerGroupLength = headerGroup.headers.length;
9668
+ const showSeparator = header.index !== headerGroupLength - 1 && !isLastLeftPinnedColumn && !isFirstRightPinnedColumn && (!header.isPlaceholder || !nextHeader.isPlaceholder);
9669
+ return /* @__PURE__ */ jsxs(
9670
+ TableHead,
9671
+ {
9672
+ "data-testid": `table-head-${header.id}`,
9673
+ colSpan: header.colSpan,
9674
+ rowSpan,
9675
+ ...tableHeadCellProps,
9676
+ ...header.column.columnDef?.meta?.headerProps,
9677
+ className: cn(
9678
+ classes,
9679
+ tableHeadCellProps?.className,
9680
+ header.column.columnDef?.meta?.headerProps?.className
9681
+ ),
9682
+ style: {
9683
+ ...style,
9684
+ width: useColumnSizing ? `calc(var(--header-${toCSSId(header.id)}-size, ${header.getSize()}) * 1px)` : void 0,
9685
+ minWidth: useColumnSizing ? header.column.columnDef.minSize : void 0,
9686
+ maxWidth: useColumnSizing ? header.column.columnDef.maxSize : void 0,
9687
+ ...tableHeadCellProps?.style,
9688
+ ...header.column.columnDef?.meta?.headerProps?.style
9689
+ },
9690
+ children: [
9691
+ !header.isPlaceholder || rowSpan ? flexRender(header.column.columnDef.header, header.getContext()) : null,
9692
+ /* @__PURE__ */ jsx(
9693
+ ColumnSeparator_default,
9694
+ {
9695
+ ...components?.columnSeparatorProps?.headerCell,
9696
+ ...header.column.columnDef?.meta?.columnSeparatorProps,
9697
+ show: header.column.columnDef?.meta?.columnSeparatorProps?.show ?? components?.columnSeparatorProps?.headerCell?.show ?? showSeparator
9698
+ }
9699
+ ),
9700
+ /* @__PURE__ */ jsx(ColumnResizer_default, { header, ...components?.columnResizerProps })
9701
+ ]
9702
+ },
9703
+ header.id
9704
+ );
9705
+ }
9618
9706
  var TableHeaderRows = ({
9619
9707
  table,
9620
9708
  columnResizing,
9621
9709
  virtual,
9710
+ columnVirtual,
9622
9711
  components
9623
9712
  }) => {
9624
- return /* @__PURE__ */ jsx(Fragment, { children: table.getHeaderGroups().map((headerGroup) => {
9625
- return /* @__PURE__ */ jsx(TableRow, { children: headerGroup.headers.map((header) => {
9626
- const { classes, style } = getColumnPinningStyles(header.column);
9627
- const useColumnSizing = header.column.columnDef?.meta?.useColumnSizing ?? columnResizing?.enabled ?? virtual?.enabled ?? false;
9628
- const tableHeadCellProps = typeof components?.tableHeadCellProps === "function" ? components?.tableHeadCellProps({ header, table }) : components?.tableHeadCellProps;
9629
- const nextHeader = headerGroup.headers?.[header.index + 1] || header;
9630
- const { isLastLeftPinnedColumn } = getColumnPinningInfo(header.column);
9631
- const { isFirstRightPinnedColumn } = getColumnPinningInfo(nextHeader.column);
9632
- const headerGroupLength = header.headerGroup.headers.length;
9633
- const showSeparator = header.index !== headerGroupLength - 1 && !isLastLeftPinnedColumn && !isFirstRightPinnedColumn && (!header.isPlaceholder || !nextHeader.isPlaceholder);
9634
- return /* @__PURE__ */ jsxs(
9635
- TableHead,
9636
- {
9637
- "data-testid": `table-head-${header.id}`,
9638
- colSpan: header.colSpan,
9639
- ...tableHeadCellProps,
9640
- ...header.column.columnDef?.meta?.headerProps,
9641
- className: cn(
9642
- classes,
9643
- tableHeadCellProps?.className,
9644
- header.column.columnDef?.meta?.headerProps?.className
9645
- ),
9646
- style: {
9647
- ...style,
9648
- width: useColumnSizing ? header.getSize() : void 0,
9649
- minWidth: useColumnSizing ? header.column.columnDef.minSize : void 0,
9650
- maxWidth: useColumnSizing ? header.column.columnDef.maxSize : void 0,
9651
- ...tableHeadCellProps?.style,
9652
- ...header.column.columnDef?.meta?.headerProps?.style
9653
- },
9654
- children: [
9655
- header.isPlaceholder ? null : flexRender(header.column.columnDef.header, header.getContext()),
9656
- /* @__PURE__ */ jsx(
9657
- ColumnSeparator_default,
9658
- {
9659
- ...components?.columnSeparatorProps?.headerCell,
9660
- ...header.column.columnDef?.meta?.columnSeparatorProps,
9661
- show: header.column.columnDef?.meta?.columnSeparatorProps?.show ?? components?.columnSeparatorProps?.headerCell?.show ?? showSeparator
9662
- }
9713
+ const cellProps = { columnResizing, virtual, components, table };
9714
+ const centerLeafCols = columnVirtual.enabled ? table.getCenterVisibleLeafColumns() : [];
9715
+ const totalGroups = table.getHeaderGroups().length;
9716
+ const spannedIds = /* @__PURE__ */ new Set();
9717
+ const resolveHeaderCell = (header, headerGroup, groupIndex) => {
9718
+ if (spannedIds.has(header.column.id)) return null;
9719
+ const remainingRows = totalGroups - groupIndex;
9720
+ if (header.isPlaceholder && header.column.columnDef.meta?.spanRows && remainingRows > 1) {
9721
+ spannedIds.add(header.column.id);
9722
+ return renderHeaderCell(header, headerGroup, cellProps, remainingRows);
9723
+ }
9724
+ return renderHeaderCell(header, headerGroup, cellProps);
9725
+ };
9726
+ return /* @__PURE__ */ jsx(Fragment, { children: table.getHeaderGroups().map((headerGroup, groupIndex) => {
9727
+ if (!columnVirtual.enabled) {
9728
+ return /* @__PURE__ */ jsx(TableRow, { children: headerGroup.headers.map((header) => resolveHeaderCell(header, headerGroup, groupIndex)) }, headerGroup.id);
9729
+ }
9730
+ const leftHeaders = table.getLeftHeaderGroups()[groupIndex]?.headers ?? [];
9731
+ const centerHeaders = table.getCenterHeaderGroups()[groupIndex]?.headers ?? [];
9732
+ const rightHeaders = table.getRightHeaderGroups()[groupIndex]?.headers ?? [];
9733
+ const isLeafLevel = !centerHeaders[0] || centerHeaders[0].subHeaders.length === 0;
9734
+ if (isLeafLevel) {
9735
+ return /* @__PURE__ */ jsxs(TableRow, { children: [
9736
+ leftHeaders.map((header) => resolveHeaderCell(header, headerGroup, groupIndex)),
9737
+ columnVirtual.virtualPaddingLeft > 0 && /* @__PURE__ */ jsx("th", { "aria-hidden": "true", style: { width: columnVirtual.virtualPaddingLeft } }),
9738
+ columnVirtual.virtualColumns.map((vc) => {
9739
+ const header = centerHeaders[vc.index];
9740
+ if (!header) return null;
9741
+ return renderHeaderCell(header, headerGroup, cellProps);
9742
+ }),
9743
+ columnVirtual.virtualPaddingRight > 0 && /* @__PURE__ */ jsx("th", { "aria-hidden": "true", style: { width: columnVirtual.virtualPaddingRight } }),
9744
+ rightHeaders.map((header) => resolveHeaderCell(header, headerGroup, groupIndex))
9745
+ ] }, headerGroup.id);
9746
+ }
9747
+ const leafToGroupIdx = [];
9748
+ let leafRunning = 0;
9749
+ for (let gi = 0; gi < centerHeaders.length; gi++) {
9750
+ for (let i = 0; i < centerHeaders[gi].colSpan; i++) {
9751
+ leafToGroupIdx[leafRunning + i] = gi;
9752
+ }
9753
+ leafRunning += centerHeaders[gi].colSpan;
9754
+ }
9755
+ const virtualCols = columnVirtual.virtualColumns;
9756
+ const useColumnSizing = columnResizing?.enabled ?? virtual?.enabled ?? false;
9757
+ return /* @__PURE__ */ jsxs(TableRow, { children: [
9758
+ leftHeaders.map((header) => resolveHeaderCell(header, headerGroup, groupIndex)),
9759
+ columnVirtual.virtualPaddingLeft > 0 && /* @__PURE__ */ jsx("th", { "aria-hidden": "true", style: { width: columnVirtual.virtualPaddingLeft } }),
9760
+ virtualCols.map((vc, vcIdx) => {
9761
+ const gi = leafToGroupIdx[vc.index];
9762
+ if (gi === void 0) return null;
9763
+ const groupHeader = centerHeaders[gi];
9764
+ const leafCol = centerLeafCols[vc.index];
9765
+ const isFirst = vcIdx === 0 || leafToGroupIdx[virtualCols[vcIdx - 1].index] !== gi;
9766
+ const isLast = vcIdx === virtualCols.length - 1 || leafToGroupIdx[virtualCols[vcIdx + 1].index] !== gi;
9767
+ const { classes, style } = getColumnPinningStyles(groupHeader.column);
9768
+ const tableHeadCellProps = typeof components?.tableHeadCellProps === "function" ? components.tableHeadCellProps({ header: groupHeader, table }) : components?.tableHeadCellProps;
9769
+ return /* @__PURE__ */ jsxs(
9770
+ TableHead,
9771
+ {
9772
+ colSpan: 1,
9773
+ ...tableHeadCellProps,
9774
+ ...groupHeader.column.columnDef?.meta?.headerProps,
9775
+ className: cn(
9776
+ classes,
9777
+ tableHeadCellProps?.className,
9778
+ groupHeader.column.columnDef?.meta?.headerProps?.className
9663
9779
  ),
9664
- /* @__PURE__ */ jsx(ColumnResizer_default, { header, ...components?.columnResizerProps })
9665
- ]
9666
- },
9667
- header.id
9668
- );
9669
- }) }, headerGroup.id);
9780
+ style: {
9781
+ ...style,
9782
+ width: useColumnSizing ? `calc(var(--col-${toCSSId(leafCol.id)}-size, ${leafCol.getSize()}) * 1px)` : void 0,
9783
+ ...tableHeadCellProps?.style,
9784
+ ...groupHeader.column.columnDef?.meta?.headerProps?.style
9785
+ },
9786
+ children: [
9787
+ isFirst && !groupHeader.isPlaceholder ? flexRender(groupHeader.column.columnDef.header, groupHeader.getContext()) : null,
9788
+ /* @__PURE__ */ jsx(ColumnSeparator_default, { ...components?.columnSeparatorProps?.headerCell, show: isLast })
9789
+ ]
9790
+ },
9791
+ `${groupHeader.id}-${leafCol.id}`
9792
+ );
9793
+ }),
9794
+ columnVirtual.virtualPaddingRight > 0 && /* @__PURE__ */ jsx("th", { "aria-hidden": "true", style: { width: columnVirtual.virtualPaddingRight } }),
9795
+ rightHeaders.map((header) => resolveHeaderCell(header, headerGroup, groupIndex))
9796
+ ] }, headerGroup.id);
9670
9797
  }) });
9671
9798
  };
9799
+ var MemoizedTableHeaderRows = React__default.memo(
9800
+ TableHeaderRows,
9801
+ (_, next) => next.isResizing === true
9802
+ );
9803
+ function renderFilterCell(column, {
9804
+ columnResizing,
9805
+ virtual,
9806
+ components,
9807
+ table
9808
+ }) {
9809
+ const { classes, style } = getColumnPinningStyles(column);
9810
+ const useColumnSizing = column.columnDef.meta?.useColumnSizing ?? columnResizing?.enabled ?? virtual?.enabled ?? false;
9811
+ const tableFilterCellProps = typeof components?.tableFilterCellProps === "function" ? components?.tableFilterCellProps({ column, table }) : components?.tableFilterCellProps;
9812
+ return /* @__PURE__ */ jsx(
9813
+ TableCell,
9814
+ {
9815
+ "data-testid": `table-filter-cell-${column.id}`,
9816
+ ...tableFilterCellProps,
9817
+ ...column.columnDef?.meta?.filterCellProps,
9818
+ className: cn(
9819
+ "bg-white border-b",
9820
+ classes,
9821
+ tableFilterCellProps?.className,
9822
+ column.columnDef?.meta?.filterCellProps?.className
9823
+ ),
9824
+ style: {
9825
+ ...style,
9826
+ width: useColumnSizing ? `calc(var(--col-${toCSSId(column.id)}-size, ${column.getSize()}) * 1px)` : void 0,
9827
+ minWidth: useColumnSizing ? column.columnDef.minSize : void 0,
9828
+ maxWidth: useColumnSizing ? column.columnDef.maxSize : void 0,
9829
+ ...tableFilterCellProps?.style,
9830
+ ...column.columnDef?.meta?.filterCellProps?.style
9831
+ },
9832
+ children: column.getCanFilter() && column.columnDef.meta?.renderColumnFilter?.({
9833
+ column,
9834
+ table
9835
+ })
9836
+ },
9837
+ column.id
9838
+ );
9839
+ }
9672
9840
  var TableFilterRow = ({
9673
9841
  table,
9674
9842
  filterableColumns,
9675
9843
  isSomeColumnsFilterable,
9676
9844
  columnResizing,
9677
9845
  virtual,
9846
+ columnVirtual,
9678
9847
  components
9679
9848
  }) => {
9680
9849
  if (!isSomeColumnsFilterable) return null;
9681
- return /* @__PURE__ */ jsx(TableRow, { "data-testid": "table-filter-row", children: filterableColumns.map((column) => {
9682
- const { classes, style } = getColumnPinningStyles(column);
9683
- const useColumnSizing = column.columnDef.meta?.useColumnSizing ?? columnResizing?.enabled ?? virtual?.enabled ?? false;
9684
- const tableFilterCellProps = typeof components?.tableFilterCellProps === "function" ? components?.tableFilterCellProps({ column, table }) : components?.tableFilterCellProps;
9685
- return /* @__PURE__ */ jsx(
9686
- TableCell,
9687
- {
9688
- "data-testid": `table-filter-cell-${column.id}`,
9689
- ...tableFilterCellProps,
9690
- ...column.columnDef?.meta?.filterCellProps,
9691
- className: cn(
9692
- "bg-white border-b",
9693
- classes,
9694
- tableFilterCellProps?.className,
9695
- column.columnDef?.meta?.filterCellProps?.className
9696
- ),
9697
- style: {
9698
- ...style,
9699
- width: useColumnSizing ? column.getSize() : void 0,
9700
- minWidth: useColumnSizing ? column.columnDef.minSize : void 0,
9701
- maxWidth: useColumnSizing ? column.columnDef.maxSize : void 0,
9702
- ...tableFilterCellProps?.style,
9703
- ...column.columnDef?.meta?.filterCellProps?.style
9704
- },
9705
- children: column.getCanFilter() && column.columnDef.meta?.renderColumnFilter?.({
9706
- column,
9707
- table
9708
- })
9709
- },
9710
- column.id
9711
- );
9712
- }) });
9850
+ const cellProps = { columnResizing, virtual, components, table };
9851
+ if (!columnVirtual.enabled) {
9852
+ return /* @__PURE__ */ jsx(TableRow, { "data-testid": "table-filter-row", children: filterableColumns.map((column) => renderFilterCell(column, cellProps)) });
9853
+ }
9854
+ const centerColumns = table.getCenterVisibleLeafColumns();
9855
+ const leftColumns = filterableColumns.filter((col) => col.getIsPinned() === "left");
9856
+ const centerFilterColumns = filterableColumns.filter((col) => !col.getIsPinned());
9857
+ const rightColumns = filterableColumns.filter((col) => col.getIsPinned() === "right");
9858
+ const centerColumnIndexMap = new Map(centerColumns.map((col, i) => [col.id, i]));
9859
+ const virtualIndexSet = new Set(columnVirtual.virtualColumns.map((vc) => vc.index));
9860
+ return /* @__PURE__ */ jsxs(TableRow, { "data-testid": "table-filter-row", children: [
9861
+ leftColumns.map((column) => renderFilterCell(column, cellProps)),
9862
+ columnVirtual.virtualPaddingLeft > 0 && /* @__PURE__ */ jsx("td", { "aria-hidden": "true", style: { width: columnVirtual.virtualPaddingLeft } }),
9863
+ centerFilterColumns.filter((col) => virtualIndexSet.has(centerColumnIndexMap.get(col.id) ?? -1)).map((column) => renderFilterCell(column, cellProps)),
9864
+ columnVirtual.virtualPaddingRight > 0 && /* @__PURE__ */ jsx("td", { "aria-hidden": "true", style: { width: columnVirtual.virtualPaddingRight } }),
9865
+ rightColumns.map((column) => renderFilterCell(column, cellProps))
9866
+ ] });
9713
9867
  };
9868
+ var MemoizedTableFilterRow = React__default.memo(
9869
+ TableFilterRow,
9870
+ (_, next) => next.isResizing === true
9871
+ );
9714
9872
  var TableDataRows = ({
9715
9873
  table,
9716
9874
  rowModel,
@@ -9722,6 +9880,7 @@ var TableDataRows = ({
9722
9880
  visibleColumnCount,
9723
9881
  columnResizing,
9724
9882
  virtual,
9883
+ columnVirtual,
9725
9884
  onRowClick,
9726
9885
  components
9727
9886
  }) => {
@@ -9740,6 +9899,56 @@ var TableDataRows = ({
9740
9899
  if (!row) return null;
9741
9900
  const virtualIndex = config.isVirtualize ? item.index : void 0;
9742
9901
  const tableDataRowProps = typeof components?.tableDataRowProps === "function" ? components.tableDataRowProps({ row, table }) || {} : components?.tableDataRowProps || {};
9902
+ const renderCell = (cell) => {
9903
+ const { classes, style } = getColumnPinningStyles(cell.column);
9904
+ const useColumnSizing = cell.column.columnDef.meta?.useColumnSizing ?? columnResizing?.enabled ?? virtual?.enabled ?? false;
9905
+ const tableDataCellProps = typeof components?.tableDataCellProps === "function" ? components?.tableDataCellProps({ row, cell, table }) : components?.tableDataCellProps;
9906
+ return /* @__PURE__ */ jsx(
9907
+ TableCell,
9908
+ {
9909
+ "data-testid": `table-data-cell-${cell.id}`,
9910
+ "data-row-id": row.id,
9911
+ "data-column-id": cell.column.id,
9912
+ ...tableDataCellProps,
9913
+ ...cell.column.columnDef?.meta?.cellProps,
9914
+ className: cn(
9915
+ {
9916
+ "bg-[#dfeae3]": row.getIsSelected(),
9917
+ "bg-white group-hover:bg-sus-primary-3-hover transition-colors duration-150": !row.getIsSelected()
9918
+ },
9919
+ classes,
9920
+ tableDataCellProps?.className,
9921
+ cell.column.columnDef?.meta?.cellProps?.className
9922
+ ),
9923
+ style: {
9924
+ ...style,
9925
+ width: useColumnSizing ? `calc(var(--col-${toCSSId(cell.column.id)}-size, ${cell.column.getSize()}) * 1px)` : void 0,
9926
+ minWidth: useColumnSizing ? cell.column.columnDef.minSize : void 0,
9927
+ maxWidth: useColumnSizing ? cell.column.columnDef.maxSize : void 0,
9928
+ ...tableDataCellProps?.style,
9929
+ ...cell.column.columnDef?.meta?.cellProps?.style
9930
+ },
9931
+ children: flexRender(cell.column.columnDef.cell, cell.getContext())
9932
+ },
9933
+ cell.id
9934
+ );
9935
+ };
9936
+ const rowContent = columnVirtual.enabled ? (() => {
9937
+ const leftCells = row.getLeftVisibleCells();
9938
+ const centerCells = row.getCenterVisibleCells();
9939
+ const rightCells = row.getRightVisibleCells();
9940
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
9941
+ leftCells.map(renderCell),
9942
+ columnVirtual.virtualPaddingLeft > 0 && /* @__PURE__ */ jsx("td", { "aria-hidden": "true", style: { width: columnVirtual.virtualPaddingLeft } }),
9943
+ columnVirtual.virtualColumns.map((vc) => {
9944
+ const cell = centerCells[vc.index];
9945
+ if (!cell) return null;
9946
+ return renderCell(cell);
9947
+ }),
9948
+ columnVirtual.virtualPaddingRight > 0 && /* @__PURE__ */ jsx("td", { "aria-hidden": "true", style: { width: columnVirtual.virtualPaddingRight } }),
9949
+ rightCells.map(renderCell)
9950
+ ] });
9951
+ })() : row.getVisibleCells().map(renderCell);
9743
9952
  return /* @__PURE__ */ createElement(
9744
9953
  TableRow,
9745
9954
  {
@@ -9757,40 +9966,7 @@ var TableDataRows = ({
9757
9966
  table
9758
9967
  })
9759
9968
  },
9760
- row.getVisibleCells().map((cell) => {
9761
- const { classes, style } = getColumnPinningStyles(cell.column);
9762
- const useColumnSizing = cell.column.columnDef.meta?.useColumnSizing ?? columnResizing?.enabled ?? virtual?.enabled ?? false;
9763
- const tableDataCellProps = typeof components?.tableDataCellProps === "function" ? components?.tableDataCellProps({ row, cell, table }) : components?.tableDataCellProps;
9764
- return /* @__PURE__ */ jsx(
9765
- TableCell,
9766
- {
9767
- "data-testid": `table-data-cell-${cell.id}`,
9768
- "data-row-id": row.id,
9769
- "data-column-id": cell.column.id,
9770
- ...tableDataCellProps,
9771
- ...cell.column.columnDef?.meta?.cellProps,
9772
- className: cn(
9773
- {
9774
- "bg-[#dfeae3]": row.getIsSelected(),
9775
- "bg-white group-hover:bg-sus-primary-3-hover": !row.getIsSelected()
9776
- },
9777
- classes,
9778
- tableDataCellProps?.className,
9779
- cell.column.columnDef?.meta?.cellProps?.className
9780
- ),
9781
- style: {
9782
- ...style,
9783
- width: useColumnSizing ? cell.column.getSize() : void 0,
9784
- minWidth: useColumnSizing ? cell.column.columnDef.minSize : void 0,
9785
- maxWidth: useColumnSizing ? cell.column.columnDef.maxSize : void 0,
9786
- ...tableDataCellProps?.style,
9787
- ...cell.column.columnDef?.meta?.cellProps?.style
9788
- },
9789
- children: flexRender(cell.column.columnDef.cell, cell.getContext())
9790
- },
9791
- cell.id
9792
- );
9793
- })
9969
+ rowContent
9794
9970
  );
9795
9971
  }),
9796
9972
  virtualEnabled && paddingBottom > 0 && /* @__PURE__ */ jsx(TableRow, { "aria-hidden": "true", "data-testid": "table-virtual-padding-bottom", children: /* @__PURE__ */ jsx(
@@ -9803,66 +9979,163 @@ var TableDataRows = ({
9803
9979
  ) })
9804
9980
  ] });
9805
9981
  };
9982
+ var MemoizedTableDataRows = React__default.memo(
9983
+ TableDataRows,
9984
+ (_, next) => next.isResizing === true
9985
+ );
9986
+ function renderFooterCell(footer, footerGroup, {
9987
+ columnResizing,
9988
+ virtual,
9989
+ components,
9990
+ table
9991
+ }, rowSpan) {
9992
+ const { classes, style } = getColumnPinningStyles(footer.column);
9993
+ const useColumnSizing = footer.column.columnDef?.meta?.useColumnSizing ?? columnResizing?.enabled ?? virtual?.enabled ?? false;
9994
+ const tableFooterCellProps = typeof components?.tableFooterCellProps === "function" ? components.tableFooterCellProps({ footer, table }) : components?.tableFooterCellProps;
9995
+ const nextFooter = footerGroup.headers[footer.index + 1] ?? footer;
9996
+ const { isLastLeftPinnedColumn } = getColumnPinningInfo(footer.column);
9997
+ const { isFirstRightPinnedColumn } = getColumnPinningInfo(nextFooter.column);
9998
+ const footerGroupLength = footerGroup.headers.length;
9999
+ const showSeparator = footer.index !== footerGroupLength - 1 && !isLastLeftPinnedColumn && !isFirstRightPinnedColumn && (!footer.isPlaceholder || !nextFooter.isPlaceholder);
10000
+ return /* @__PURE__ */ jsxs(
10001
+ TableHead,
10002
+ {
10003
+ "data-testid": `footer-cell-${footer.id}`,
10004
+ colSpan: footer.colSpan,
10005
+ rowSpan,
10006
+ ...tableFooterCellProps,
10007
+ ...footer.column.columnDef?.meta?.footerProps,
10008
+ className: cn(
10009
+ classes,
10010
+ tableFooterCellProps?.className,
10011
+ footer.column.columnDef?.meta?.footerProps?.className
10012
+ ),
10013
+ style: {
10014
+ ...style,
10015
+ width: useColumnSizing ? `calc(var(--col-${toCSSId(footer.column.id)}-size, ${footer.column.getSize()}) * 1px)` : void 0,
10016
+ minWidth: useColumnSizing ? footer.column.columnDef.minSize : void 0,
10017
+ maxWidth: useColumnSizing ? footer.column.columnDef.maxSize : void 0,
10018
+ ...tableFooterCellProps?.style,
10019
+ ...footer.column.columnDef?.meta?.footerProps?.style
10020
+ },
10021
+ children: [
10022
+ footer.isPlaceholder ? null : flexRender(footer.column.columnDef.footer, footer.getContext()),
10023
+ /* @__PURE__ */ jsx(
10024
+ ColumnSeparator_default,
10025
+ {
10026
+ ...components?.columnSeparatorProps?.headerCell,
10027
+ ...footer.column.columnDef?.meta?.columnSeparatorProps,
10028
+ show: footer.column.columnDef?.meta?.columnSeparatorProps?.show ?? components?.columnSeparatorProps?.headerCell?.show ?? showSeparator
10029
+ }
10030
+ ),
10031
+ !footer.isPlaceholder && /* @__PURE__ */ jsx(ColumnResizer_default, { header: footer, ...components?.columnResizerProps })
10032
+ ]
10033
+ },
10034
+ footer.id
10035
+ );
10036
+ }
9806
10037
  var TableFooterRows = ({
9807
10038
  table,
9808
10039
  columnResizing,
9809
- components,
9810
- virtual
10040
+ virtual,
10041
+ columnVirtual,
10042
+ components
9811
10043
  }) => {
9812
- const hasAnyFooter = table.getAllColumns().some((col) => col.columnDef.footer != null);
9813
- if (!hasAnyFooter) return null;
9814
- return /* @__PURE__ */ jsx(Fragment, { children: table.getFooterGroups().map((footerGroup) => {
10044
+ const cellProps = { columnResizing, virtual, components, table };
10045
+ const centerLeafCols = columnVirtual.enabled ? table.getCenterVisibleLeafColumns() : [];
10046
+ const totalFooterGroups = table.getFooterGroups().length;
10047
+ const spannedIds = /* @__PURE__ */ new Set();
10048
+ const resolveFooterCell = (footer, footerGroup, groupIndex) => {
10049
+ if (spannedIds.has(footer.column.id)) return null;
10050
+ const remainingRows = totalFooterGroups - groupIndex;
10051
+ if (!footer.isPlaceholder && footer.column.columnDef.meta?.spanRows && remainingRows > 1) {
10052
+ spannedIds.add(footer.column.id);
10053
+ return renderFooterCell(footer, footerGroup, cellProps, remainingRows);
10054
+ }
10055
+ return renderFooterCell(footer, footerGroup, cellProps);
10056
+ };
10057
+ return /* @__PURE__ */ jsx(Fragment, { children: table.getFooterGroups().map((footerGroup, groupIndex) => {
9815
10058
  const tableFooterRowProps = typeof components?.tableFooterRowProps === "function" ? components.tableFooterRowProps({ footerGroup, table }) : components?.tableFooterRowProps;
9816
- return /* @__PURE__ */ jsx(TableRow, { ...tableFooterRowProps, children: footerGroup.headers.map((footer) => {
9817
- const { classes, style } = getColumnPinningStyles(footer.column);
9818
- const useColumnSizing = footer.column.columnDef?.meta?.useColumnSizing ?? columnResizing?.enabled ?? virtual?.enabled ?? false;
9819
- const tableFooterCellProps = typeof components?.tableFooterCellProps === "function" ? components.tableFooterCellProps({ footer, table }) : components?.tableFooterCellProps;
9820
- const nextFooter = footerGroup.headers[footer.index + 1] ?? footer;
9821
- const { isLastLeftPinnedColumn } = getColumnPinningInfo(footer.column);
9822
- const { isFirstRightPinnedColumn } = getColumnPinningInfo(nextFooter.column);
9823
- const footerGroupLength = footer.headerGroup.headers.length;
9824
- const showSeparator = footer.index !== footerGroupLength - 1 && !isLastLeftPinnedColumn && !isFirstRightPinnedColumn && (!footer.isPlaceholder || !nextFooter.isPlaceholder);
9825
- return /* @__PURE__ */ jsxs(
9826
- TableHead,
9827
- {
9828
- "data-testid": `footer-cell-${footer.id}`,
9829
- colSpan: footer.colSpan,
9830
- ...tableFooterCellProps,
9831
- ...footer.column.columnDef?.meta?.footerProps,
9832
- className: cn(
9833
- classes,
9834
- tableFooterCellProps?.className,
9835
- footer.column.columnDef?.meta?.footerProps?.className
9836
- ),
9837
- style: {
9838
- ...style,
9839
- width: useColumnSizing ? `calc(var(--col-${footer.column.id}-size, ${footer.column.getSize()}) * 1px)` : void 0,
9840
- minWidth: useColumnSizing ? footer.column.columnDef.minSize : void 0,
9841
- maxWidth: useColumnSizing ? footer.column.columnDef.maxSize : void 0,
9842
- ...tableFooterCellProps?.style,
9843
- ...footer.column.columnDef?.meta?.footerProps?.style
9844
- },
9845
- children: [
9846
- footer.isPlaceholder ? null : flexRender(footer.column.columnDef.footer, footer.getContext()),
9847
- /* @__PURE__ */ jsx(
9848
- ColumnSeparator_default,
9849
- {
9850
- ...components?.columnSeparatorProps?.headerCell,
9851
- ...footer.column.columnDef?.meta?.columnSeparatorProps,
9852
- show: footer.column.columnDef?.meta?.columnSeparatorProps?.show ?? components?.columnSeparatorProps?.headerCell?.show ?? showSeparator
9853
- }
10059
+ if (!columnVirtual.enabled) {
10060
+ return /* @__PURE__ */ jsx(TableRow, { ...tableFooterRowProps, children: footerGroup.headers.map((footer) => resolveFooterCell(footer, footerGroup, groupIndex)) }, footerGroup.id);
10061
+ }
10062
+ const leftFooters = table.getLeftFooterGroups()[groupIndex]?.headers ?? [];
10063
+ const centerFooters = table.getCenterFooterGroups()[groupIndex]?.headers ?? [];
10064
+ const rightFooters = table.getRightFooterGroups()[groupIndex]?.headers ?? [];
10065
+ const isLeafLevel = !centerFooters[0] || centerFooters[0].subHeaders.length === 0;
10066
+ if (isLeafLevel) {
10067
+ return /* @__PURE__ */ jsxs(TableRow, { ...tableFooterRowProps, children: [
10068
+ leftFooters.map((footer) => resolveFooterCell(footer, footerGroup, groupIndex)),
10069
+ columnVirtual.virtualPaddingLeft > 0 && /* @__PURE__ */ jsx("th", { "aria-hidden": "true", style: { width: columnVirtual.virtualPaddingLeft } }),
10070
+ columnVirtual.virtualColumns.map((vc) => {
10071
+ const footer = centerFooters[vc.index];
10072
+ if (!footer) return null;
10073
+ return renderFooterCell(footer, footerGroup, cellProps);
10074
+ }),
10075
+ columnVirtual.virtualPaddingRight > 0 && /* @__PURE__ */ jsx("th", { "aria-hidden": "true", style: { width: columnVirtual.virtualPaddingRight } }),
10076
+ rightFooters.map((footer) => resolveFooterCell(footer, footerGroup, groupIndex))
10077
+ ] }, footerGroup.id);
10078
+ }
10079
+ const leafToGroupIdx = [];
10080
+ let leafRunning = 0;
10081
+ for (let gi = 0; gi < centerFooters.length; gi++) {
10082
+ for (let i = 0; i < centerFooters[gi].colSpan; i++) {
10083
+ leafToGroupIdx[leafRunning + i] = gi;
10084
+ }
10085
+ leafRunning += centerFooters[gi].colSpan;
10086
+ }
10087
+ const virtualCols = columnVirtual.virtualColumns;
10088
+ const useColumnSizing = columnResizing?.enabled ?? virtual?.enabled ?? false;
10089
+ return /* @__PURE__ */ jsxs(TableRow, { ...tableFooterRowProps, children: [
10090
+ leftFooters.map((footer) => resolveFooterCell(footer, footerGroup, groupIndex)),
10091
+ columnVirtual.virtualPaddingLeft > 0 && /* @__PURE__ */ jsx("th", { "aria-hidden": "true", style: { width: columnVirtual.virtualPaddingLeft } }),
10092
+ virtualCols.map((vc, vcIdx) => {
10093
+ const gi = leafToGroupIdx[vc.index];
10094
+ if (gi === void 0) return null;
10095
+ const groupFooter = centerFooters[gi];
10096
+ const leafCol = centerLeafCols[vc.index];
10097
+ const isFirst = vcIdx === 0 || leafToGroupIdx[virtualCols[vcIdx - 1].index] !== gi;
10098
+ const isLast = vcIdx === virtualCols.length - 1 || leafToGroupIdx[virtualCols[vcIdx + 1].index] !== gi;
10099
+ const { classes, style } = getColumnPinningStyles(groupFooter.column);
10100
+ const tableFooterCellProps = typeof components?.tableFooterCellProps === "function" ? components.tableFooterCellProps({ footer: groupFooter, table }) : components?.tableFooterCellProps;
10101
+ return /* @__PURE__ */ jsxs(
10102
+ TableHead,
10103
+ {
10104
+ colSpan: 1,
10105
+ ...tableFooterCellProps,
10106
+ ...groupFooter.column.columnDef?.meta?.footerProps,
10107
+ className: cn(
10108
+ classes,
10109
+ tableFooterCellProps?.className,
10110
+ groupFooter.column.columnDef?.meta?.footerProps?.className
9854
10111
  ),
9855
- !footer.isPlaceholder && /* @__PURE__ */ jsx(ColumnResizer_default, { header: footer, ...components?.columnResizerProps })
9856
- ]
9857
- },
9858
- footer.id
9859
- );
9860
- }) }, footerGroup.id);
10112
+ style: {
10113
+ ...style,
10114
+ width: useColumnSizing ? `calc(var(--col-${toCSSId(leafCol.id)}-size, ${leafCol.getSize()}) * 1px)` : void 0,
10115
+ ...tableFooterCellProps?.style,
10116
+ ...groupFooter.column.columnDef?.meta?.footerProps?.style
10117
+ },
10118
+ children: [
10119
+ isFirst && !groupFooter.isPlaceholder ? flexRender(groupFooter.column.columnDef.footer, groupFooter.getContext()) : null,
10120
+ /* @__PURE__ */ jsx(ColumnSeparator_default, { ...components?.columnSeparatorProps?.headerCell, show: isLast })
10121
+ ]
10122
+ },
10123
+ `${groupFooter.id}-${leafCol.id}`
10124
+ );
10125
+ }),
10126
+ columnVirtual.virtualPaddingRight > 0 && /* @__PURE__ */ jsx("th", { "aria-hidden": "true", style: { width: columnVirtual.virtualPaddingRight } }),
10127
+ rightFooters.map((footer) => resolveFooterCell(footer, footerGroup, groupIndex))
10128
+ ] }, footerGroup.id);
9861
10129
  }) });
9862
10130
  };
10131
+ var MemoizedTableFooterRows = React__default.memo(
10132
+ TableFooterRows,
10133
+ (_, next) => next.isResizing === true
10134
+ );
9863
10135
  var DataTable = ({
9864
10136
  tableRef,
9865
10137
  virtualizerRef,
10138
+ columnVirtualizerRef,
9866
10139
  isInitialLoading,
9867
10140
  columns,
9868
10141
  data,
@@ -9902,7 +10175,15 @@ var DataTable = ({
9902
10175
  rowIdKey,
9903
10176
  childrenKey
9904
10177
  });
9905
- const { virtualizer, virtualItems, paddingTop, paddingBottom, rowModel } = useTableVirtualizer({
10178
+ const {
10179
+ virtualizer,
10180
+ columnVirtualizer,
10181
+ virtualItems,
10182
+ paddingTop,
10183
+ paddingBottom,
10184
+ rowModel,
10185
+ columnVirtual
10186
+ } = useTableVirtualizer({
9906
10187
  enabled: virtualEnabled,
9907
10188
  table,
9908
10189
  containerRef: tableContainerRef,
@@ -9916,8 +10197,28 @@ var DataTable = ({
9916
10197
  activeStatusContent
9917
10198
  });
9918
10199
  const fetchMoreOnScrollReached = useScrollFetch({ scrollFetch, containerRef: tableContainerRef });
10200
+ const columnResizingEnabled = columnResizing?.enabled;
10201
+ const { columnSizing, columnSizingInfo } = table.getState();
10202
+ const columnSizeVars = useMemo(() => {
10203
+ if (!columnResizingEnabled && !virtualEnabled) return {};
10204
+ const headers = table.getFlatHeaders();
10205
+ const colSizes = {};
10206
+ for (const header of headers) {
10207
+ colSizes[`--header-${toCSSId(header.id)}-size`] = header.getSize();
10208
+ colSizes[`--col-${toCSSId(header.column.id)}-size`] = header.column.getSize();
10209
+ if (header.column.getIsPinned() === "left") {
10210
+ colSizes[`--col-${toCSSId(header.column.id)}-pin-start`] = header.column.getStart("left");
10211
+ } else if (header.column.getIsPinned() === "right") {
10212
+ colSizes[`--col-${toCSSId(header.column.id)}-pin-after`] = header.column.getAfter("right");
10213
+ }
10214
+ }
10215
+ return colSizes;
10216
+ }, [columnSizing, columnSizingInfo, columnResizingEnabled, virtualEnabled]);
10217
+ const isResizing = !columnVirtual.enabled && (columnResizingEnabled ?? false) && !!columnSizingInfo.isResizingColumn;
10218
+ const hasAnyFooter = table.getAllColumns().some((col) => col.columnDef.footer != null);
9919
10219
  useBindRef_default({ ref: tableRef, value: table });
9920
10220
  useBindRef_default({ ref: virtualizerRef, value: virtualizer });
10221
+ useBindRef_default({ ref: columnVirtualizerRef, value: columnVirtualizer });
9921
10222
  return /* @__PURE__ */ jsxs(
9922
10223
  TableContainer,
9923
10224
  {
@@ -9953,44 +10254,53 @@ var DataTable = ({
9953
10254
  },
9954
10255
  defaultIcon: /* @__PURE__ */ jsx(SuiEmptyDataIcon, { size: 128 })
9955
10256
  }
9956
- ) : /* @__PURE__ */ jsxs(Fragment, { children: [
9957
- /* @__PURE__ */ jsxs(
9958
- Table,
9959
- {
9960
- ...components?.tableProps,
9961
- style: { tableLayout: virtualEnabled ? "fixed" : "auto", ...components?.tableProps?.style },
9962
- children: [
9963
- /* @__PURE__ */ jsxs(
9964
- TableHeader,
9965
- {
9966
- className: cn("sticky top-0 z-10 bg-white", components?.tableHeaderProps?.className),
9967
- ...components?.tableHeaderProps,
9968
- children: [
9969
- /* @__PURE__ */ jsx(
9970
- TableHeaderRows,
9971
- {
9972
- table,
9973
- columnResizing,
9974
- virtual,
9975
- components
9976
- }
9977
- ),
9978
- /* @__PURE__ */ jsx(
9979
- TableFilterRow,
9980
- {
9981
- table,
9982
- filterableColumns,
9983
- isSomeColumnsFilterable,
9984
- columnResizing,
9985
- virtual,
9986
- components
9987
- }
9988
- )
9989
- ]
9990
- }
9991
- ),
9992
- /* @__PURE__ */ jsx(TableBody, { ...components?.tableBodyProps, children: /* @__PURE__ */ jsx(
9993
- TableDataRows,
10257
+ ) : /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
10258
+ Table,
10259
+ {
10260
+ ...components?.tableProps,
10261
+ style: {
10262
+ tableLayout: virtualEnabled ? "fixed" : "auto",
10263
+ minWidth: columnVirtual.enabled ? `${table.getTotalSize()}px` : void 0,
10264
+ ...components?.tableProps?.style,
10265
+ ...columnSizeVars
10266
+ },
10267
+ children: [
10268
+ /* @__PURE__ */ jsxs(
10269
+ TableHeader,
10270
+ {
10271
+ className: cn("sticky top-0 z-10 bg-white", components?.tableHeaderProps?.className),
10272
+ ...components?.tableHeaderProps,
10273
+ children: [
10274
+ /* @__PURE__ */ jsx(
10275
+ MemoizedTableHeaderRows,
10276
+ {
10277
+ table,
10278
+ columnResizing,
10279
+ virtual,
10280
+ columnVirtual,
10281
+ components,
10282
+ isResizing
10283
+ }
10284
+ ),
10285
+ /* @__PURE__ */ jsx(
10286
+ MemoizedTableFilterRow,
10287
+ {
10288
+ table,
10289
+ filterableColumns,
10290
+ isSomeColumnsFilterable,
10291
+ columnResizing,
10292
+ virtual,
10293
+ columnVirtual,
10294
+ components,
10295
+ isResizing
10296
+ }
10297
+ )
10298
+ ]
10299
+ }
10300
+ ),
10301
+ /* @__PURE__ */ jsxs(TableBody, { ...components?.tableBodyProps, children: [
10302
+ /* @__PURE__ */ jsx(
10303
+ MemoizedTableDataRows,
9994
10304
  {
9995
10305
  table,
9996
10306
  rowModel,
@@ -10002,66 +10312,70 @@ var DataTable = ({
10002
10312
  visibleColumnCount,
10003
10313
  columnResizing,
10004
10314
  virtual,
10315
+ columnVirtual,
10005
10316
  onRowClick,
10006
- components
10317
+ components,
10318
+ isResizing
10007
10319
  }
10008
- ) }),
10009
- /* @__PURE__ */ jsx(
10010
- TableFooter,
10320
+ ),
10321
+ activeStatusContentComputed === "emptyFilteredData" && /* @__PURE__ */ jsx(TableRow, { "data-testid": "status-row-empty-filtered-data", children: /* @__PURE__ */ jsx(TableCell, { colSpan: visibleColumnCount, className: "border-b-0 p-0", children: /* @__PURE__ */ jsx(
10322
+ StatusContentSlot_default,
10011
10323
  {
10012
- ...components?.tableFooterProps,
10013
- className: cn("sticky bottom-0 z-10 bg-white", components?.tableFooterProps?.className),
10014
- children: /* @__PURE__ */ jsx(
10015
- TableFooterRows,
10016
- {
10017
- table,
10018
- columnResizing,
10019
- virtual,
10020
- components
10021
- }
10022
- )
10324
+ content: statusContent?.emptyFilteredData?.content ?? "No records found. Please try a different search.",
10325
+ icon: statusContent?.emptyFilteredData?.icon,
10326
+ wrapperProps: statusContent?.emptyFilteredData?.wrapperProps,
10327
+ defaultWrapperProps: {
10328
+ className: "flex flex-col items-center justify-center text-sm py-4 gap-2",
10329
+ ["data-testid"]: "status-content-empty-filtered-data"
10330
+ },
10331
+ defaultIcon: /* @__PURE__ */ jsx(SuiEmptyDataIcon, { size: 128 })
10023
10332
  }
10024
- )
10025
- ]
10026
- }
10027
- ),
10028
- activeStatusContentComputed === "emptyFilteredData" && /* @__PURE__ */ jsx(
10029
- StatusContentSlot_default,
10030
- {
10031
- content: statusContent?.emptyFilteredData?.content ?? "No records found. Please try a different search.",
10032
- icon: statusContent?.emptyFilteredData?.icon,
10033
- wrapperProps: statusContent?.emptyFilteredData?.wrapperProps,
10034
- defaultWrapperProps: {
10035
- className: "flex flex-col h-[calc(100%-76px)] items-center justify-center text-sm py-4 gap-2",
10036
- ["data-testid"]: "status-content-empty-filtered-data"
10037
- },
10038
- defaultIcon: /* @__PURE__ */ jsx(SuiEmptyDataIcon, { size: 128 })
10039
- }
10040
- ),
10041
- activeStatusContentComputed === "fetchingMore" && /* @__PURE__ */ jsx(
10042
- StatusContentSlot_default,
10043
- {
10044
- content: statusContent?.fetchingMore?.content ?? "Loading more...",
10045
- wrapperProps: statusContent?.fetchingMore?.wrapperProps,
10046
- defaultWrapperProps: {
10047
- className: "flex flex-col items-center justify-center text-sm py-4 gap-2",
10048
- ["data-testid"]: "status-content-fetching-more"
10049
- }
10050
- }
10051
- ),
10052
- activeStatusContentComputed === "noMoreData" && /* @__PURE__ */ jsx(
10053
- StatusContentSlot_default,
10054
- {
10055
- content: statusContent?.noMoreData?.content,
10056
- icon: statusContent?.noMoreData?.icon,
10057
- wrapperProps: statusContent?.noMoreData?.wrapperProps,
10058
- defaultWrapperProps: {
10059
- className: "flex flex-col items-center justify-center text-sm py-4 gap-2",
10060
- ["data-testid"]: "status-content-no-more-data"
10061
- }
10062
- }
10063
- )
10064
- ] }),
10333
+ ) }) }),
10334
+ activeStatusContentComputed === "fetchingMore" && /* @__PURE__ */ jsx(TableRow, { "data-testid": "status-row-fetching-more", children: /* @__PURE__ */ jsx(TableCell, { colSpan: visibleColumnCount, className: "border-b-0 p-0", children: /* @__PURE__ */ jsx(
10335
+ StatusContentSlot_default,
10336
+ {
10337
+ content: statusContent?.fetchingMore?.content ?? "Loading more...",
10338
+ wrapperProps: statusContent?.fetchingMore?.wrapperProps,
10339
+ defaultWrapperProps: {
10340
+ className: "flex flex-col items-center justify-center text-sm py-4 gap-2",
10341
+ ["data-testid"]: "status-content-fetching-more"
10342
+ }
10343
+ }
10344
+ ) }) }),
10345
+ activeStatusContentComputed === "noMoreData" && /* @__PURE__ */ jsx(TableRow, { "data-testid": "status-row-no-more-data", children: /* @__PURE__ */ jsx(TableCell, { colSpan: visibleColumnCount, className: "border-b-0 p-0", children: /* @__PURE__ */ jsx(
10346
+ StatusContentSlot_default,
10347
+ {
10348
+ content: statusContent?.noMoreData?.content,
10349
+ icon: statusContent?.noMoreData?.icon,
10350
+ wrapperProps: statusContent?.noMoreData?.wrapperProps,
10351
+ defaultWrapperProps: {
10352
+ className: "flex flex-col items-center justify-center text-sm py-4 gap-2",
10353
+ ["data-testid"]: "status-content-no-more-data"
10354
+ }
10355
+ }
10356
+ ) }) })
10357
+ ] }),
10358
+ hasAnyFooter && /* @__PURE__ */ jsx(
10359
+ TableFooter,
10360
+ {
10361
+ ...components?.tableFooterProps,
10362
+ className: cn("sticky bottom-0 z-10 bg-white", components?.tableFooterProps?.className),
10363
+ children: /* @__PURE__ */ jsx(
10364
+ MemoizedTableFooterRows,
10365
+ {
10366
+ table,
10367
+ columnResizing,
10368
+ virtual,
10369
+ columnVirtual,
10370
+ components,
10371
+ isResizing
10372
+ }
10373
+ )
10374
+ }
10375
+ )
10376
+ ]
10377
+ }
10378
+ ) }),
10065
10379
  debug && /* @__PURE__ */ jsx(DataTableDevTool_default, { table })
10066
10380
  ]
10067
10381
  }