@trackunit/react-table 1.14.17 → 1.14.18-alpha-ae1ff73fc64.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/index.cjs.js CHANGED
@@ -475,7 +475,7 @@ const ColumnFilter = ({ columns, setColumnOrder, defaultColumnOrder = [], column
475
475
  const resetColumnState = react.useCallback(() => {
476
476
  const sizes = {};
477
477
  columns.forEach(column => {
478
- if (column.columnDef.size) {
478
+ if (column.columnDef.size !== undefined) {
479
479
  sizes[column.id] = column.columnDef.size;
480
480
  }
481
481
  if (column.columnDef.meta?.hiddenByDefault === true && column.getIsVisible()) {
@@ -543,7 +543,7 @@ const ColumnFiltersDragAndDrop = ({ columns, setColumnOrder, onUserEvent, isSort
543
543
  return (jsxRuntime.jsx("div", { className: "flex max-h-full max-w-[400px] flex-col overflow-y-auto overflow-x-hidden whitespace-nowrap", children: localColumns.map((column, index) => {
544
544
  const { columnDef } = column;
545
545
  if (!columnDef.meta?.columnFilterLabel &&
546
- (!columnDef.header || columnDef.header.length === 0 || typeof columnDef.header === "function")) {
546
+ (columnDef.header === undefined || columnDef.header.length === 0 || typeof columnDef.header === "function")) {
547
547
  return null;
548
548
  }
549
549
  const isVisible = column.getIsVisible();
@@ -568,8 +568,10 @@ const ColumnFiltersDragAndDrop = ({ columns, setColumnOrder, onUserEvent, isSort
568
568
  const Sorting = ({ columns, }) => {
569
569
  const [t] = useTranslation();
570
570
  const sortableColumns = columns.filter(column => column.getCanSort());
571
- const currentSortValue = sortableColumns.find(column => column.getIsSorted())?.id;
572
- const currentSortDirection = sortableColumns.find(column => column.getIsSorted())?.getIsSorted() || "desc";
571
+ const sortedColumn = sortableColumns.find(column => column.getIsSorted() !== false);
572
+ const currentSortValue = sortedColumn?.id;
573
+ const sortDirection = sortedColumn?.getIsSorted();
574
+ const currentSortDirection = sortDirection === "asc" || sortDirection === "desc" ? sortDirection : "desc";
573
575
  if (sortableColumns.length === 0) {
574
576
  return null;
575
577
  }
@@ -972,8 +974,8 @@ const ColumnActions = ({ header, visibleColumnsCount, setSorting, getColumn }) =
972
974
  const sortByKey = header.column.columnDef.meta?.sortByKey;
973
975
  const sortByColumn = react.useMemo(() => (sortByKey ? getColumn(sortByKey) : undefined), [sortByKey, getColumn]);
974
976
  const isSortedByKey = sortByKey ? sortByColumn?.getIsSorted() : undefined;
975
- const showSortAscending = canSort && (sortByKey ? isSortedByKey === "desc" || !isSortedByKey : isSorted === "desc" || !isSorted);
976
- const showSortDescending = canSort && (sortByKey ? isSortedByKey === "asc" || !isSortedByKey : isSorted === "asc" || !isSorted);
977
+ const showSortAscending = canSort && (sortByKey ? isSortedByKey !== "asc" : isSorted !== "asc");
978
+ const showSortDescending = canSort && (sortByKey ? isSortedByKey !== "desc" : isSorted !== "desc");
977
979
  const showClearSorting = canSort && (sortByKey ? isSortedByKey : isSorted);
978
980
  const handleSortAscending = react.useCallback(() => {
979
981
  if (sortByKey) {
@@ -999,10 +1001,10 @@ const ColumnActions = ({ header, visibleColumnsCount, setSorting, getColumn }) =
999
1001
  if (!isAnyActionAvailable) {
1000
1002
  return null;
1001
1003
  }
1002
- return (jsxRuntime.jsx(reactComponents.MoreMenu, { customButton: jsxRuntime.jsx(reactComponents.IconButton, { className: "h-8 w-5 p-0", icon: jsxRuntime.jsx(reactComponents.Icon, { name: "EllipsisVertical", size: "small" }), onClick: event => event.stopPropagation(), variant: "ghost-neutral" }), children: close => (jsxRuntime.jsxs(reactComponents.MenuList, { children: [showSortAscending ? (jsxRuntime.jsx(reactComponents.MenuItem, { label: t("table.columnActions.sortAscending"), onClick: handleSortAscending, prefix: jsxRuntime.jsx(reactComponents.Icon, { name: "ArrowUp", size: "medium" }) })) : null, showSortDescending ? (jsxRuntime.jsx(reactComponents.MenuItem, { label: t("table.columnActions.sortDescending"), onClick: handleSortDescending, prefix: jsxRuntime.jsx(reactComponents.Icon, { name: "ArrowDown", size: "medium" }) })) : null, showClearSorting ? (jsxRuntime.jsx(reactComponents.MenuItem, { label: t("table.columnActions.clearSorting"), onClick: handleClearSorting, prefix: jsxRuntime.jsx(reactComponents.Icon, { name: "ArrowsUpDown", size: "medium" }) })) : null, showHideColumn ? (jsxRuntime.jsx(reactComponents.MenuItem, { label: t("table.columnActions.hideColumn"), onClick: () => header.column.toggleVisibility(false), prefix: jsxRuntime.jsx(reactComponents.Icon, { name: "EyeSlash", size: "medium" }) })) : null, canPin ? (jsxRuntime.jsx(reactComponents.MenuItem, { label: t(isPinned ? "table.columnActions.unPinColumn" : "table.columnActions.pinColumn"), onClick: () => {
1003
- header.column.pin(isPinned ? false : "left");
1004
+ return (jsxRuntime.jsx(reactComponents.MoreMenu, { customButton: jsxRuntime.jsx(reactComponents.IconButton, { className: "h-8 w-5 p-0", icon: jsxRuntime.jsx(reactComponents.Icon, { name: "EllipsisVertical", size: "small" }), onClick: event => event.stopPropagation(), variant: "ghost-neutral" }), children: close => (jsxRuntime.jsxs(reactComponents.MenuList, { children: [showSortAscending ? (jsxRuntime.jsx(reactComponents.MenuItem, { label: t("table.columnActions.sortAscending"), onClick: handleSortAscending, prefix: jsxRuntime.jsx(reactComponents.Icon, { name: "ArrowUp", size: "medium" }) })) : null, showSortDescending ? (jsxRuntime.jsx(reactComponents.MenuItem, { label: t("table.columnActions.sortDescending"), onClick: handleSortDescending, prefix: jsxRuntime.jsx(reactComponents.Icon, { name: "ArrowDown", size: "medium" }) })) : null, showClearSorting !== false && showClearSorting !== undefined ? (jsxRuntime.jsx(reactComponents.MenuItem, { label: t("table.columnActions.clearSorting"), onClick: handleClearSorting, prefix: jsxRuntime.jsx(reactComponents.Icon, { name: "ArrowsUpDown", size: "medium" }) })) : null, showHideColumn ? (jsxRuntime.jsx(reactComponents.MenuItem, { label: t("table.columnActions.hideColumn"), onClick: () => header.column.toggleVisibility(false), prefix: jsxRuntime.jsx(reactComponents.Icon, { name: "EyeSlash", size: "medium" }) })) : null, canPin ? (jsxRuntime.jsx(reactComponents.MenuItem, { label: t(isPinned !== false ? "table.columnActions.unPinColumn" : "table.columnActions.pinColumn"), onClick: () => {
1005
+ header.column.pin(isPinned !== false ? false : "left");
1004
1006
  close();
1005
- }, prefix: jsxRuntime.jsx(reactComponents.Icon, { name: isPinned ? "Unpin" : "Pin", size: "medium" }) })) : null] })) }));
1007
+ }, prefix: jsxRuntime.jsx(reactComponents.Icon, { name: isPinned !== false ? "Unpin" : "Pin", size: "medium" }) })) : null] })) }));
1006
1008
  };
1007
1009
 
1008
1010
  /**
@@ -1018,7 +1020,7 @@ const ColumnActions = ({ header, visibleColumnsCount, setSorting, getColumn }) =
1018
1020
  * @returns {ReactElement | null} A React element representing the sorting indicator.
1019
1021
  */
1020
1022
  const ColumnSorting = ({ canSort, sortingState = false }) => {
1021
- if (!canSort || !sortingState) {
1023
+ if (!canSort || sortingState === false) {
1022
1024
  return null;
1023
1025
  }
1024
1026
  return (jsxRuntime.jsx("div", { className: "flex items-center", children: jsxRuntime.jsx(reactComponents.Icon, { className: "text-neutral-800", name: sortingState === "asc" ? "ArrowUp" : "ArrowDown", size: "small" }) }));
@@ -1192,7 +1194,12 @@ const Table = ({ rowHeight = 50, ...props }) => {
1192
1194
  header.column.getToggleSortingHandler()?.(event);
1193
1195
  }
1194
1196
  }, [props]);
1195
- return (jsxRuntime.jsxs(reactComponents.Card, { className: tailwindMerge.twMerge("table-compact flex flex-col overflow-hidden", props.className), "data-testid": props["data-testid"], children: [props.headerLeftActions || props.headerRightActions ? (jsxRuntime.jsxs("div", { className: "z-default flex justify-between gap-2 p-2", children: [jsxRuntime.jsx("div", { className: "flex items-center gap-2", children: props.headerLeftActions }), jsxRuntime.jsx("div", { className: "flex items-center gap-2", children: props.headerRightActions })] })) : null, props.subHeaderActions, jsxRuntime.jsx("div", { className: tailwindMerge.twMerge("h-full overflow-x-auto overflow-y-scroll border-b border-neutral-200", !props.subHeaderActions && (props.headerLeftActions || props.headerRightActions) ? "border-t" : ""), ref: tableScrollElementRef, children: jsxRuntime.jsxs(reactTableBaseComponents.TableRoot, { style: {
1197
+ return (jsxRuntime.jsxs(reactComponents.Card, { className: tailwindMerge.twMerge("table-compact flex flex-col overflow-hidden", props.className), "data-testid": props["data-testid"], children: [(props.headerLeftActions !== undefined && props.headerLeftActions !== null) ||
1198
+ (props.headerRightActions !== undefined && props.headerRightActions !== null) ? (jsxRuntime.jsxs("div", { className: "z-default flex justify-between gap-2 p-2", children: [jsxRuntime.jsx("div", { className: "flex items-center gap-2", children: props.headerLeftActions }), jsxRuntime.jsx("div", { className: "flex items-center gap-2", children: props.headerRightActions })] })) : null, props.subHeaderActions, jsxRuntime.jsx("div", { className: tailwindMerge.twMerge("h-full overflow-x-auto overflow-y-scroll border-b border-neutral-200", (props.subHeaderActions === undefined || props.subHeaderActions === null) &&
1199
+ ((props.headerLeftActions !== undefined && props.headerLeftActions !== null) ||
1200
+ (props.headerRightActions !== undefined && props.headerRightActions !== null))
1201
+ ? "border-t"
1202
+ : ""), ref: tableScrollElementRef, children: jsxRuntime.jsxs(reactTableBaseComponents.TableRoot, { style: {
1196
1203
  height: hasResults ? "auto" : "100%",
1197
1204
  width: "100%",
1198
1205
  position: "relative",
@@ -1216,11 +1223,13 @@ const Table = ({ rowHeight = 50, ...props }) => {
1216
1223
  renderDropIndicator(header.id),
1217
1224
  header.isPlaceholder ? null : (jsxRuntime.jsxs("div", { ...getDragHandleProps(header.id, header.isPlaceholder, pinned), className: tailwindMerge.twMerge(cvaColumnHeaderContainer({
1218
1225
  sortable: canSort,
1219
- })), children: [jsxRuntime.jsxs("div", { className: "flex flex-1 items-center truncate", onClick: event => handleColumnClick(event, header), children: [header.column.columnDef.header || header.column.columnDef.meta?.subHeader ? (jsxRuntime.jsxs("span", { className: "subtle min-w-0 text-xs", children: [jsxRuntime.jsx(TextWithTooltip, { tooltipLabel: tooltipLabel, weight: "bold", children: reactTable.flexRender(header.column.columnDef.header, header.getContext()) }), header.column.columnDef.meta?.subHeader
1226
+ })), children: [jsxRuntime.jsxs("div", { className: "flex flex-1 items-center truncate", onClick: event => handleColumnClick(event, header), children: [header.column.columnDef.header !== undefined ||
1227
+ header.column.columnDef.meta?.subHeader !== undefined ? (jsxRuntime.jsxs("span", { className: "subtle min-w-0 text-xs", children: [jsxRuntime.jsx(TextWithTooltip, { tooltipLabel: tooltipLabel, weight: "bold", children: reactTable.flexRender(header.column.columnDef.header, header.getContext()) }), header.column.columnDef.meta?.subHeader
1220
1228
  ? header.column.columnDef.meta.subHeader
1221
1229
  : null] })) : null, jsxRuntime.jsx(ColumnSorting, { canSort: canSort, sortingState: header.column.columnDef.meta?.sortByKey
1222
1230
  ? props.getColumn(header.column.columnDef.meta.sortByKey)?.getIsSorted()
1223
- : header.column.getIsSorted() })] }), jsxRuntime.jsxs("div", { className: "flex flex-none items-center", children: [props.renderFilterButton && header.column.columnDef.meta?.filterName
1231
+ : header.column.getIsSorted() })] }), jsxRuntime.jsxs("div", { className: "flex flex-none items-center", children: [props.renderFilterButton !== undefined &&
1232
+ header.column.columnDef.meta?.filterName !== undefined
1224
1233
  ? props.renderFilterButton(header.column.columnDef.meta.filterName)
1225
1234
  : null, jsxRuntime.jsx(ColumnActions, { getColumn: props.getColumn, header: header, setSorting: props.setSorting, visibleColumnsCount: visibleColumnsCount })] })] })),
1226
1235
  !header.column.columnDef.meta?.shouldGrow && header.column.getCanResize() ? (jsxRuntime.jsx(reactTableBaseComponents.ResizeHandle, { isResizing: header.column.getIsResizing(), onMouseDown: header.getResizeHandler(), onTouchStart: header.getResizeHandler() })) : null));
@@ -1280,7 +1289,9 @@ const Table = ({ rowHeight = 50, ...props }) => {
1280
1289
  jsxRuntime.jsx("div", { className: "grid h-full items-center p-0", children: reactTable.flexRender(cell.column.columnDef.cell, cell.getContext()) })));
1281
1290
  }) }, `${row.id}-${index}`));
1282
1291
  }
1283
- }) })) : (jsxRuntime.jsx("tbody", { className: cvaTBody({ emptyState: !props.loading && !props.noDataMessage }), children: jsxRuntime.jsx("tr", { children: jsxRuntime.jsx("td", { className: "b-0", children: props.loading ? (jsxRuntime.jsx(reactComponents.Spinner, { centering: "centered", containerClassName: "absolute inset-0", "data-testid": "table-loading-spinner" })) : props.noDataMessage ? (props.noDataMessage) : (jsxRuntime.jsx(reactComponents.EmptyState, { className: "absolute inset-0", description: t("table.noResults"), image: "SEARCH_DOCUMENT", ...props.emptyState })) }) }) }))] }) }), props.hideFooter ? null : (jsxRuntime.jsxs("div", { className: "flex items-center p-2", "data-testid": "table-footer", children: [jsxRuntime.jsx("div", { className: "whitespace-nowrap text-xs font-medium text-neutral-600", children: props.pagination?.pageInfo?.count
1292
+ }) })) : (jsxRuntime.jsx("tbody", { className: cvaTBody({
1293
+ emptyState: !props.loading && (props.noDataMessage === undefined || props.noDataMessage === ""),
1294
+ }), children: jsxRuntime.jsx("tr", { children: jsxRuntime.jsx("td", { className: "b-0", children: props.loading ? (jsxRuntime.jsx(reactComponents.Spinner, { centering: "centered", containerClassName: "absolute inset-0", "data-testid": "table-loading-spinner" })) : props.noDataMessage !== undefined && props.noDataMessage !== "" ? (props.noDataMessage) : (jsxRuntime.jsx(reactComponents.EmptyState, { className: "absolute inset-0", description: t("table.noResults"), image: "SEARCH_DOCUMENT", ...props.emptyState })) }) }) }))] }) }), props.hideFooter ? null : (jsxRuntime.jsxs("div", { className: "flex items-center p-2", "data-testid": "table-footer", children: [jsxRuntime.jsx("div", { className: "whitespace-nowrap text-xs font-medium text-neutral-600", children: props.pagination?.pageInfo?.count !== undefined
1284
1295
  ? t(props.pagination.pageInfo.isCountCapped ? "table.pagination.full.capped" : "table.pagination.full", {
1285
1296
  count: props.getRowModel().rows.length,
1286
1297
  total: props.pagination.pageInfo.count,
@@ -1288,7 +1299,7 @@ const Table = ({ rowHeight = 50, ...props }) => {
1288
1299
  : t(props.pagination?.pageInfo?.hasNextPage ? "table.pagination.full.capped" : "table.pagination.full", {
1289
1300
  count: props.getRowModel().rows.length,
1290
1301
  total: props.getRowModel().rows.length,
1291
- }) }), props.pagination?.isLoading ? (jsxRuntime.jsx("span", { className: "ml-2", children: jsxRuntime.jsx(reactComponents.Spinner, { size: "small" }) })) : null, props.footerRightActions ? jsxRuntime.jsx("div", { className: "flex flex-1 justify-end", children: props.footerRightActions }) : null] }))] }));
1302
+ }) }), props.pagination?.isLoading ? (jsxRuntime.jsx("span", { className: "ml-2", children: jsxRuntime.jsx(reactComponents.Spinner, { size: "small" }) })) : null, props.footerRightActions !== undefined && props.footerRightActions !== null ? (jsxRuntime.jsx("div", { className: "flex flex-1 justify-end", children: props.footerRightActions })) : null] }))] }));
1292
1303
  };
1293
1304
  const cvaTBody = cssClassVarianceUtilities.cvaMerge(["min-h-[40dvh]"], {
1294
1305
  variants: {
@@ -1445,12 +1456,14 @@ const useTable = ({ onTableStateChange, initialState, columns, ...reactTableProp
1445
1456
  }
1446
1457
  }, [initialState, updatedInitialColumnOrder, stableUpdatedInitialColumnPinning, updatedInitialColumnVisibility]);
1447
1458
  react.useEffect(() => {
1448
- const mergedLeft = initialState?.columnPinning?.left?.length
1449
- ? [...initialState.columnPinning.left]
1450
- : [...(stableUpdatedInitialColumnPinning.left || [])];
1451
- const mergedRight = initialState?.columnPinning?.right?.length
1452
- ? [...initialState.columnPinning.right]
1453
- : [...(stableUpdatedInitialColumnPinning.right || [])];
1459
+ const leftPinning = initialState?.columnPinning?.left;
1460
+ const mergedLeft = leftPinning !== undefined && leftPinning.length > 0
1461
+ ? [...leftPinning]
1462
+ : [...(stableUpdatedInitialColumnPinning.left ?? [])];
1463
+ const rightPinning = initialState?.columnPinning?.right;
1464
+ const mergedRight = rightPinning !== undefined && rightPinning.length > 0
1465
+ ? [...rightPinning]
1466
+ : [...(stableUpdatedInitialColumnPinning.right ?? [])];
1454
1467
  const filteredRight = mergedRight.filter(column => !mergedLeft.includes(column));
1455
1468
  const mergedPinningState = {
1456
1469
  left: mergedLeft,
@@ -1583,7 +1596,7 @@ const useTableSelection = ({ data, idKey, defaultSelectedIds, enableRowSelection
1583
1596
  if (!hasRowSelection) {
1584
1597
  return null;
1585
1598
  }
1586
- const isRowSelectionDisabled = !table.options.enableRowSelection || !data.length;
1599
+ const isRowSelectionDisabled = table.options.enableRowSelection === false || table.options.enableRowSelection === undefined || data.length === 0;
1587
1600
  return (jsxRuntime.jsx(reactFormComponents.Checkbox, { className: "flex justify-center",
1588
1601
  checked: table.getIsAllRowsSelected(),
1589
1602
  indeterminate: table.getIsSomeRowsSelected(),
package/index.esm.js CHANGED
@@ -474,7 +474,7 @@ const ColumnFilter = ({ columns, setColumnOrder, defaultColumnOrder = [], column
474
474
  const resetColumnState = useCallback(() => {
475
475
  const sizes = {};
476
476
  columns.forEach(column => {
477
- if (column.columnDef.size) {
477
+ if (column.columnDef.size !== undefined) {
478
478
  sizes[column.id] = column.columnDef.size;
479
479
  }
480
480
  if (column.columnDef.meta?.hiddenByDefault === true && column.getIsVisible()) {
@@ -542,7 +542,7 @@ const ColumnFiltersDragAndDrop = ({ columns, setColumnOrder, onUserEvent, isSort
542
542
  return (jsx("div", { className: "flex max-h-full max-w-[400px] flex-col overflow-y-auto overflow-x-hidden whitespace-nowrap", children: localColumns.map((column, index) => {
543
543
  const { columnDef } = column;
544
544
  if (!columnDef.meta?.columnFilterLabel &&
545
- (!columnDef.header || columnDef.header.length === 0 || typeof columnDef.header === "function")) {
545
+ (columnDef.header === undefined || columnDef.header.length === 0 || typeof columnDef.header === "function")) {
546
546
  return null;
547
547
  }
548
548
  const isVisible = column.getIsVisible();
@@ -567,8 +567,10 @@ const ColumnFiltersDragAndDrop = ({ columns, setColumnOrder, onUserEvent, isSort
567
567
  const Sorting = ({ columns, }) => {
568
568
  const [t] = useTranslation();
569
569
  const sortableColumns = columns.filter(column => column.getCanSort());
570
- const currentSortValue = sortableColumns.find(column => column.getIsSorted())?.id;
571
- const currentSortDirection = sortableColumns.find(column => column.getIsSorted())?.getIsSorted() || "desc";
570
+ const sortedColumn = sortableColumns.find(column => column.getIsSorted() !== false);
571
+ const currentSortValue = sortedColumn?.id;
572
+ const sortDirection = sortedColumn?.getIsSorted();
573
+ const currentSortDirection = sortDirection === "asc" || sortDirection === "desc" ? sortDirection : "desc";
572
574
  if (sortableColumns.length === 0) {
573
575
  return null;
574
576
  }
@@ -971,8 +973,8 @@ const ColumnActions = ({ header, visibleColumnsCount, setSorting, getColumn }) =
971
973
  const sortByKey = header.column.columnDef.meta?.sortByKey;
972
974
  const sortByColumn = useMemo(() => (sortByKey ? getColumn(sortByKey) : undefined), [sortByKey, getColumn]);
973
975
  const isSortedByKey = sortByKey ? sortByColumn?.getIsSorted() : undefined;
974
- const showSortAscending = canSort && (sortByKey ? isSortedByKey === "desc" || !isSortedByKey : isSorted === "desc" || !isSorted);
975
- const showSortDescending = canSort && (sortByKey ? isSortedByKey === "asc" || !isSortedByKey : isSorted === "asc" || !isSorted);
976
+ const showSortAscending = canSort && (sortByKey ? isSortedByKey !== "asc" : isSorted !== "asc");
977
+ const showSortDescending = canSort && (sortByKey ? isSortedByKey !== "desc" : isSorted !== "desc");
976
978
  const showClearSorting = canSort && (sortByKey ? isSortedByKey : isSorted);
977
979
  const handleSortAscending = useCallback(() => {
978
980
  if (sortByKey) {
@@ -998,10 +1000,10 @@ const ColumnActions = ({ header, visibleColumnsCount, setSorting, getColumn }) =
998
1000
  if (!isAnyActionAvailable) {
999
1001
  return null;
1000
1002
  }
1001
- return (jsx(MoreMenu, { customButton: jsx(IconButton, { className: "h-8 w-5 p-0", icon: jsx(Icon, { name: "EllipsisVertical", size: "small" }), onClick: event => event.stopPropagation(), variant: "ghost-neutral" }), children: close => (jsxs(MenuList, { children: [showSortAscending ? (jsx(MenuItem, { label: t("table.columnActions.sortAscending"), onClick: handleSortAscending, prefix: jsx(Icon, { name: "ArrowUp", size: "medium" }) })) : null, showSortDescending ? (jsx(MenuItem, { label: t("table.columnActions.sortDescending"), onClick: handleSortDescending, prefix: jsx(Icon, { name: "ArrowDown", size: "medium" }) })) : null, showClearSorting ? (jsx(MenuItem, { label: t("table.columnActions.clearSorting"), onClick: handleClearSorting, prefix: jsx(Icon, { name: "ArrowsUpDown", size: "medium" }) })) : null, showHideColumn ? (jsx(MenuItem, { label: t("table.columnActions.hideColumn"), onClick: () => header.column.toggleVisibility(false), prefix: jsx(Icon, { name: "EyeSlash", size: "medium" }) })) : null, canPin ? (jsx(MenuItem, { label: t(isPinned ? "table.columnActions.unPinColumn" : "table.columnActions.pinColumn"), onClick: () => {
1002
- header.column.pin(isPinned ? false : "left");
1003
+ return (jsx(MoreMenu, { customButton: jsx(IconButton, { className: "h-8 w-5 p-0", icon: jsx(Icon, { name: "EllipsisVertical", size: "small" }), onClick: event => event.stopPropagation(), variant: "ghost-neutral" }), children: close => (jsxs(MenuList, { children: [showSortAscending ? (jsx(MenuItem, { label: t("table.columnActions.sortAscending"), onClick: handleSortAscending, prefix: jsx(Icon, { name: "ArrowUp", size: "medium" }) })) : null, showSortDescending ? (jsx(MenuItem, { label: t("table.columnActions.sortDescending"), onClick: handleSortDescending, prefix: jsx(Icon, { name: "ArrowDown", size: "medium" }) })) : null, showClearSorting !== false && showClearSorting !== undefined ? (jsx(MenuItem, { label: t("table.columnActions.clearSorting"), onClick: handleClearSorting, prefix: jsx(Icon, { name: "ArrowsUpDown", size: "medium" }) })) : null, showHideColumn ? (jsx(MenuItem, { label: t("table.columnActions.hideColumn"), onClick: () => header.column.toggleVisibility(false), prefix: jsx(Icon, { name: "EyeSlash", size: "medium" }) })) : null, canPin ? (jsx(MenuItem, { label: t(isPinned !== false ? "table.columnActions.unPinColumn" : "table.columnActions.pinColumn"), onClick: () => {
1004
+ header.column.pin(isPinned !== false ? false : "left");
1003
1005
  close();
1004
- }, prefix: jsx(Icon, { name: isPinned ? "Unpin" : "Pin", size: "medium" }) })) : null] })) }));
1006
+ }, prefix: jsx(Icon, { name: isPinned !== false ? "Unpin" : "Pin", size: "medium" }) })) : null] })) }));
1005
1007
  };
1006
1008
 
1007
1009
  /**
@@ -1017,7 +1019,7 @@ const ColumnActions = ({ header, visibleColumnsCount, setSorting, getColumn }) =
1017
1019
  * @returns {ReactElement | null} A React element representing the sorting indicator.
1018
1020
  */
1019
1021
  const ColumnSorting = ({ canSort, sortingState = false }) => {
1020
- if (!canSort || !sortingState) {
1022
+ if (!canSort || sortingState === false) {
1021
1023
  return null;
1022
1024
  }
1023
1025
  return (jsx("div", { className: "flex items-center", children: jsx(Icon, { className: "text-neutral-800", name: sortingState === "asc" ? "ArrowUp" : "ArrowDown", size: "small" }) }));
@@ -1191,7 +1193,12 @@ const Table = ({ rowHeight = 50, ...props }) => {
1191
1193
  header.column.getToggleSortingHandler()?.(event);
1192
1194
  }
1193
1195
  }, [props]);
1194
- return (jsxs(Card, { className: twMerge("table-compact flex flex-col overflow-hidden", props.className), "data-testid": props["data-testid"], children: [props.headerLeftActions || props.headerRightActions ? (jsxs("div", { className: "z-default flex justify-between gap-2 p-2", children: [jsx("div", { className: "flex items-center gap-2", children: props.headerLeftActions }), jsx("div", { className: "flex items-center gap-2", children: props.headerRightActions })] })) : null, props.subHeaderActions, jsx("div", { className: twMerge("h-full overflow-x-auto overflow-y-scroll border-b border-neutral-200", !props.subHeaderActions && (props.headerLeftActions || props.headerRightActions) ? "border-t" : ""), ref: tableScrollElementRef, children: jsxs(TableRoot, { style: {
1196
+ return (jsxs(Card, { className: twMerge("table-compact flex flex-col overflow-hidden", props.className), "data-testid": props["data-testid"], children: [(props.headerLeftActions !== undefined && props.headerLeftActions !== null) ||
1197
+ (props.headerRightActions !== undefined && props.headerRightActions !== null) ? (jsxs("div", { className: "z-default flex justify-between gap-2 p-2", children: [jsx("div", { className: "flex items-center gap-2", children: props.headerLeftActions }), jsx("div", { className: "flex items-center gap-2", children: props.headerRightActions })] })) : null, props.subHeaderActions, jsx("div", { className: twMerge("h-full overflow-x-auto overflow-y-scroll border-b border-neutral-200", (props.subHeaderActions === undefined || props.subHeaderActions === null) &&
1198
+ ((props.headerLeftActions !== undefined && props.headerLeftActions !== null) ||
1199
+ (props.headerRightActions !== undefined && props.headerRightActions !== null))
1200
+ ? "border-t"
1201
+ : ""), ref: tableScrollElementRef, children: jsxs(TableRoot, { style: {
1195
1202
  height: hasResults ? "auto" : "100%",
1196
1203
  width: "100%",
1197
1204
  position: "relative",
@@ -1215,11 +1222,13 @@ const Table = ({ rowHeight = 50, ...props }) => {
1215
1222
  renderDropIndicator(header.id),
1216
1223
  header.isPlaceholder ? null : (jsxs("div", { ...getDragHandleProps(header.id, header.isPlaceholder, pinned), className: twMerge(cvaColumnHeaderContainer({
1217
1224
  sortable: canSort,
1218
- })), children: [jsxs("div", { className: "flex flex-1 items-center truncate", onClick: event => handleColumnClick(event, header), children: [header.column.columnDef.header || header.column.columnDef.meta?.subHeader ? (jsxs("span", { className: "subtle min-w-0 text-xs", children: [jsx(TextWithTooltip, { tooltipLabel: tooltipLabel, weight: "bold", children: flexRender(header.column.columnDef.header, header.getContext()) }), header.column.columnDef.meta?.subHeader
1225
+ })), children: [jsxs("div", { className: "flex flex-1 items-center truncate", onClick: event => handleColumnClick(event, header), children: [header.column.columnDef.header !== undefined ||
1226
+ header.column.columnDef.meta?.subHeader !== undefined ? (jsxs("span", { className: "subtle min-w-0 text-xs", children: [jsx(TextWithTooltip, { tooltipLabel: tooltipLabel, weight: "bold", children: flexRender(header.column.columnDef.header, header.getContext()) }), header.column.columnDef.meta?.subHeader
1219
1227
  ? header.column.columnDef.meta.subHeader
1220
1228
  : null] })) : null, jsx(ColumnSorting, { canSort: canSort, sortingState: header.column.columnDef.meta?.sortByKey
1221
1229
  ? props.getColumn(header.column.columnDef.meta.sortByKey)?.getIsSorted()
1222
- : header.column.getIsSorted() })] }), jsxs("div", { className: "flex flex-none items-center", children: [props.renderFilterButton && header.column.columnDef.meta?.filterName
1230
+ : header.column.getIsSorted() })] }), jsxs("div", { className: "flex flex-none items-center", children: [props.renderFilterButton !== undefined &&
1231
+ header.column.columnDef.meta?.filterName !== undefined
1223
1232
  ? props.renderFilterButton(header.column.columnDef.meta.filterName)
1224
1233
  : null, jsx(ColumnActions, { getColumn: props.getColumn, header: header, setSorting: props.setSorting, visibleColumnsCount: visibleColumnsCount })] })] })),
1225
1234
  !header.column.columnDef.meta?.shouldGrow && header.column.getCanResize() ? (jsx(ResizeHandle, { isResizing: header.column.getIsResizing(), onMouseDown: header.getResizeHandler(), onTouchStart: header.getResizeHandler() })) : null));
@@ -1279,7 +1288,9 @@ const Table = ({ rowHeight = 50, ...props }) => {
1279
1288
  jsx("div", { className: "grid h-full items-center p-0", children: flexRender(cell.column.columnDef.cell, cell.getContext()) })));
1280
1289
  }) }, `${row.id}-${index}`));
1281
1290
  }
1282
- }) })) : (jsx("tbody", { className: cvaTBody({ emptyState: !props.loading && !props.noDataMessage }), children: jsx("tr", { children: jsx("td", { className: "b-0", children: props.loading ? (jsx(Spinner, { centering: "centered", containerClassName: "absolute inset-0", "data-testid": "table-loading-spinner" })) : props.noDataMessage ? (props.noDataMessage) : (jsx(EmptyState, { className: "absolute inset-0", description: t("table.noResults"), image: "SEARCH_DOCUMENT", ...props.emptyState })) }) }) }))] }) }), props.hideFooter ? null : (jsxs("div", { className: "flex items-center p-2", "data-testid": "table-footer", children: [jsx("div", { className: "whitespace-nowrap text-xs font-medium text-neutral-600", children: props.pagination?.pageInfo?.count
1291
+ }) })) : (jsx("tbody", { className: cvaTBody({
1292
+ emptyState: !props.loading && (props.noDataMessage === undefined || props.noDataMessage === ""),
1293
+ }), children: jsx("tr", { children: jsx("td", { className: "b-0", children: props.loading ? (jsx(Spinner, { centering: "centered", containerClassName: "absolute inset-0", "data-testid": "table-loading-spinner" })) : props.noDataMessage !== undefined && props.noDataMessage !== "" ? (props.noDataMessage) : (jsx(EmptyState, { className: "absolute inset-0", description: t("table.noResults"), image: "SEARCH_DOCUMENT", ...props.emptyState })) }) }) }))] }) }), props.hideFooter ? null : (jsxs("div", { className: "flex items-center p-2", "data-testid": "table-footer", children: [jsx("div", { className: "whitespace-nowrap text-xs font-medium text-neutral-600", children: props.pagination?.pageInfo?.count !== undefined
1283
1294
  ? t(props.pagination.pageInfo.isCountCapped ? "table.pagination.full.capped" : "table.pagination.full", {
1284
1295
  count: props.getRowModel().rows.length,
1285
1296
  total: props.pagination.pageInfo.count,
@@ -1287,7 +1298,7 @@ const Table = ({ rowHeight = 50, ...props }) => {
1287
1298
  : t(props.pagination?.pageInfo?.hasNextPage ? "table.pagination.full.capped" : "table.pagination.full", {
1288
1299
  count: props.getRowModel().rows.length,
1289
1300
  total: props.getRowModel().rows.length,
1290
- }) }), props.pagination?.isLoading ? (jsx("span", { className: "ml-2", children: jsx(Spinner, { size: "small" }) })) : null, props.footerRightActions ? jsx("div", { className: "flex flex-1 justify-end", children: props.footerRightActions }) : null] }))] }));
1301
+ }) }), props.pagination?.isLoading ? (jsx("span", { className: "ml-2", children: jsx(Spinner, { size: "small" }) })) : null, props.footerRightActions !== undefined && props.footerRightActions !== null ? (jsx("div", { className: "flex flex-1 justify-end", children: props.footerRightActions })) : null] }))] }));
1291
1302
  };
1292
1303
  const cvaTBody = cvaMerge(["min-h-[40dvh]"], {
1293
1304
  variants: {
@@ -1444,12 +1455,14 @@ const useTable = ({ onTableStateChange, initialState, columns, ...reactTableProp
1444
1455
  }
1445
1456
  }, [initialState, updatedInitialColumnOrder, stableUpdatedInitialColumnPinning, updatedInitialColumnVisibility]);
1446
1457
  useEffect(() => {
1447
- const mergedLeft = initialState?.columnPinning?.left?.length
1448
- ? [...initialState.columnPinning.left]
1449
- : [...(stableUpdatedInitialColumnPinning.left || [])];
1450
- const mergedRight = initialState?.columnPinning?.right?.length
1451
- ? [...initialState.columnPinning.right]
1452
- : [...(stableUpdatedInitialColumnPinning.right || [])];
1458
+ const leftPinning = initialState?.columnPinning?.left;
1459
+ const mergedLeft = leftPinning !== undefined && leftPinning.length > 0
1460
+ ? [...leftPinning]
1461
+ : [...(stableUpdatedInitialColumnPinning.left ?? [])];
1462
+ const rightPinning = initialState?.columnPinning?.right;
1463
+ const mergedRight = rightPinning !== undefined && rightPinning.length > 0
1464
+ ? [...rightPinning]
1465
+ : [...(stableUpdatedInitialColumnPinning.right ?? [])];
1453
1466
  const filteredRight = mergedRight.filter(column => !mergedLeft.includes(column));
1454
1467
  const mergedPinningState = {
1455
1468
  left: mergedLeft,
@@ -1582,7 +1595,7 @@ const useTableSelection = ({ data, idKey, defaultSelectedIds, enableRowSelection
1582
1595
  if (!hasRowSelection) {
1583
1596
  return null;
1584
1597
  }
1585
- const isRowSelectionDisabled = !table.options.enableRowSelection || !data.length;
1598
+ const isRowSelectionDisabled = table.options.enableRowSelection === false || table.options.enableRowSelection === undefined || data.length === 0;
1586
1599
  return (jsx(Checkbox, { className: "flex justify-center",
1587
1600
  checked: table.getIsAllRowsSelected(),
1588
1601
  indeterminate: table.getIsSomeRowsSelected(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-table",
3
- "version": "1.14.17",
3
+ "version": "1.14.18-alpha-ae1ff73fc64.0",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -14,14 +14,14 @@
14
14
  "react-dnd-html5-backend": "16.0.1",
15
15
  "@tanstack/react-router": "1.114.29",
16
16
  "tailwind-merge": "^2.0.0",
17
- "@trackunit/react-components": "1.18.9",
18
- "@trackunit/shared-utils": "1.13.68",
19
- "@trackunit/css-class-variance-utilities": "1.11.68",
20
- "@trackunit/ui-icons": "1.11.66",
21
- "@trackunit/react-table-base-components": "1.14.9",
22
- "@trackunit/react-form-components": "1.15.9",
23
- "@trackunit/i18n-library-translation": "1.12.59",
24
- "@trackunit/iris-app-runtime-core-api": "1.12.51",
17
+ "@trackunit/react-components": "1.18.10-alpha-ae1ff73fc64.0",
18
+ "@trackunit/shared-utils": "1.13.69-alpha-ae1ff73fc64.0",
19
+ "@trackunit/css-class-variance-utilities": "1.11.69-alpha-ae1ff73fc64.0",
20
+ "@trackunit/ui-icons": "1.11.67-alpha-ae1ff73fc64.0",
21
+ "@trackunit/react-table-base-components": "1.14.10-alpha-ae1ff73fc64.0",
22
+ "@trackunit/react-form-components": "1.15.10-alpha-ae1ff73fc64.0",
23
+ "@trackunit/i18n-library-translation": "1.12.60-alpha-ae1ff73fc64.0",
24
+ "@trackunit/iris-app-runtime-core-api": "1.12.52-alpha-ae1ff73fc64.0",
25
25
  "graphql": "^16.10.0"
26
26
  },
27
27
  "module": "./index.esm.js",
@@ -1,8 +1,8 @@
1
- export declare const cvaActionSheet: (props?: import("class-variance-authority/dist/types").ClassProp | undefined) => string;
2
- export declare const cvaDivider: (props?: import("class-variance-authority/dist/types").ClassProp | undefined) => string;
1
+ export declare const cvaActionSheet: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
2
+ export declare const cvaDivider: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
3
3
  export declare const cvaActionContainerAndOverflow: (props?: ({
4
4
  isDropdown?: boolean | null | undefined;
5
- } & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
5
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
6
6
  export declare const cvaMoreContainer: (props?: ({
7
7
  isDropdown?: boolean | null | undefined;
8
- } & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
8
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
@@ -1,3 +1,3 @@
1
1
  export declare const cvaColumnFilterGrabbable: (props?: ({
2
2
  disabled?: boolean | null | undefined;
3
- } & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
3
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;