@trackunit/react-table 1.3.176 → 1.3.179

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
@@ -820,22 +820,50 @@ const useColumnDragDrop = ({ table, }) => {
820
820
  * `ColumnActions` component to render column action controls for a table.
821
821
  *
822
822
  * @template TData The type of the table row data.
823
- * @param {object} props Component properties.
823
+ * @param {ColumnActionsProps} props Component properties.
824
824
  * @param {Header<TData, unknown>} props.header The header of the current column provided by React Table.
825
825
  * @param {number} props.visibleColumnsCount The number of visible columns in the table.
826
826
  */
827
- const ColumnActions = ({ header, visibleColumnsCount, }) => {
827
+ const ColumnActions = ({ header, visibleColumnsCount, setSorting, getColumn }) => {
828
828
  const [t] = useTranslation();
829
- const isSorted = header.column.getIsSorted();
830
- const canSort = header.column.getCanSort();
831
- const canHide = header.column.getCanHide();
832
- const canPin = header.column.getCanPin();
833
- const isPinned = header.column.getIsPinned();
834
- const isAnyActionAvailable = canSort || canPin || (canHide && visibleColumnsCount > 1);
829
+ const isSorted = react.useMemo(() => header.column.getIsSorted(), [header]);
830
+ const canSort = react.useMemo(() => header.column.getCanSort(), [header]);
831
+ const canHide = react.useMemo(() => header.column.getCanHide(), [header]);
832
+ const canPin = react.useMemo(() => header.column.getCanPin(), [header]);
833
+ const isPinned = react.useMemo(() => header.column.getIsPinned(), [header]);
834
+ const showHideColumn = react.useMemo(() => canHide && visibleColumnsCount > 1, [canHide, visibleColumnsCount]);
835
+ const isAnyActionAvailable = react.useMemo(() => canSort || canPin || showHideColumn, [canPin, canSort, showHideColumn]);
836
+ const sortByKey = header.column.columnDef.meta?.sortByKey;
837
+ const sortByColumn = react.useMemo(() => (sortByKey ? getColumn(sortByKey) : undefined), [sortByKey, getColumn]);
838
+ const isSortedByKey = sortByKey ? sortByColumn?.getIsSorted() : undefined;
839
+ const showSortAscending = canSort && (sortByKey ? isSortedByKey === "desc" || !isSortedByKey : isSorted === "desc" || !isSorted);
840
+ const showSortDescending = canSort && (sortByKey ? isSortedByKey === "asc" || !isSortedByKey : isSorted === "asc" || !isSorted);
841
+ const showClearSorting = canSort && (sortByKey ? isSortedByKey : isSorted);
842
+ const handleSortAscending = react.useCallback(() => {
843
+ if (sortByKey) {
844
+ setSorting([{ id: sortByKey, desc: false }]);
845
+ return;
846
+ }
847
+ header.column.toggleSorting(false);
848
+ }, [sortByKey, setSorting, header]);
849
+ const handleSortDescending = react.useCallback(() => {
850
+ if (sortByKey) {
851
+ setSorting([{ id: sortByKey, desc: true }]);
852
+ return;
853
+ }
854
+ header.column.toggleSorting(true);
855
+ }, [sortByKey, setSorting, header]);
856
+ const handleClearSorting = react.useCallback(() => {
857
+ if (sortByKey) {
858
+ sortByColumn?.clearSorting();
859
+ return;
860
+ }
861
+ header.column.clearSorting();
862
+ }, [sortByKey, sortByColumn, header]);
835
863
  if (!isAnyActionAvailable) {
836
864
  return null;
837
865
  }
838
- return (jsxRuntime.jsx(reactComponents.MoreMenu, { customButton: jsxRuntime.jsx(reactComponents.IconButton, { icon: jsxRuntime.jsx(reactComponents.Icon, { name: "EllipsisVertical", size: "small" }), onClick: event => event.stopPropagation(), size: "extraSmall", variant: "ghost-neutral" }), children: close => (jsxRuntime.jsxs(reactComponents.MenuList, { children: [canSort && (isSorted === "desc" || !isSorted) ? (jsxRuntime.jsx(reactComponents.MenuItem, { label: t("table.columnActions.sortAscending"), onClick: () => header.column.toggleSorting(false), prefix: jsxRuntime.jsx(reactComponents.Icon, { name: "ArrowUp", size: "medium" }) })) : null, canSort && (isSorted === "asc" || !isSorted) ? (jsxRuntime.jsx(reactComponents.MenuItem, { label: t("table.columnActions.sortDescending"), onClick: () => header.column.toggleSorting(true), prefix: jsxRuntime.jsx(reactComponents.Icon, { name: "ArrowDown", size: "medium" }) })) : null, canSort && isSorted ? (jsxRuntime.jsx(reactComponents.MenuItem, { label: t("table.columnActions.clearSorting"), onClick: () => header.column.clearSorting(), prefix: jsxRuntime.jsx(reactComponents.Icon, { name: "ArrowsUpDown", size: "medium" }) })) : null, canHide && visibleColumnsCount > 1 ? (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: () => {
866
+ return (jsxRuntime.jsx(reactComponents.MoreMenu, { customButton: jsxRuntime.jsx(reactComponents.IconButton, { icon: jsxRuntime.jsx(reactComponents.Icon, { name: "EllipsisVertical", size: "small" }), onClick: event => event.stopPropagation(), size: "extraSmall", 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: () => {
839
867
  header.column.pin(isPinned ? false : "left");
840
868
  close();
841
869
  }, prefix: jsxRuntime.jsx(reactComponents.Icon, { name: isPinned ? "Unpin" : "Pin", size: "medium" }) })) : null] })) }));
@@ -922,6 +950,28 @@ const Table = ({ rowHeight = 50, ...props }) => {
922
950
  });
923
951
  const offsets = useCellsOffset(headerGroups.map(group => group.headers), draggingColumnId);
924
952
  const hasResults = props.getRowModel().rows.length > 0;
953
+ const handleColumnClick = react.useCallback((event, header) => {
954
+ if (header.column.columnDef.meta?.sortByKey) {
955
+ const column = props.getColumn(header.column.columnDef.meta.sortByKey);
956
+ if (column) {
957
+ const isCurrentlySorted = column.getIsSorted();
958
+ if (isCurrentlySorted === "desc") {
959
+ column.clearSorting();
960
+ return;
961
+ }
962
+ if (isCurrentlySorted === "asc") {
963
+ props.setSorting([{ id: header.column.columnDef.meta.sortByKey, desc: true }]);
964
+ return;
965
+ }
966
+ props.setSorting([{ id: header.column.columnDef.meta.sortByKey, desc: false }]);
967
+ return;
968
+ }
969
+ return;
970
+ }
971
+ else {
972
+ header.column.getToggleSortingHandler()?.(event);
973
+ }
974
+ }, [props]);
925
975
  return (jsxRuntime.jsxs(reactComponents.Card, { className: tailwindMerge.twMerge("flex flex-col overflow-hidden", props.className), dataTestId: props.dataTestId, 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, jsxRuntime.jsx("div", { className: "h-full overflow-x-auto overflow-y-scroll border-b border-t border-neutral-200", onScroll: e => fetchMoreOnBottomReached(e.target), ref: tableContainerRef, children: jsxRuntime.jsxs(reactTableBaseComponents.TableRoot, { style: {
926
976
  height: hasResults ? "auto" : "100%",
927
977
  width: "100%",
@@ -946,11 +996,13 @@ const Table = ({ rowHeight = 50, ...props }) => {
946
996
  renderDropIndicator(header.id),
947
997
  header.isPlaceholder ? null : (jsxRuntime.jsxs("div", { ...getDragHandleProps(header.id, header.isPlaceholder, pinned), className: tailwindMerge.twMerge(cvaColumnHeaderContainer({
948
998
  sortable: canSort,
949
- })), onClick: header.column.getToggleSortingHandler(), children: [jsxRuntime.jsxs("div", { className: "flex flex-1 items-center gap-1 truncate", 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
999
+ })), onClick: event => handleColumnClick(event, header), children: [jsxRuntime.jsxs("div", { className: "flex flex-1 items-center gap-1 truncate", 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
950
1000
  ? header.column.columnDef.meta.subHeader
951
- : null] })) : null, jsxRuntime.jsx(ColumnSorting, { canSort: canSort, sortingState: header.column.getIsSorted() })] }), jsxRuntime.jsxs("div", { className: "flex flex-none items-center", children: [props.renderFilterButton && header.column.columnDef.meta?.filterName
1001
+ : null] })) : null, jsxRuntime.jsx(ColumnSorting, { canSort: canSort, sortingState: header.column.columnDef.meta?.sortByKey
1002
+ ? props.getColumn(header.column.columnDef.meta.sortByKey)?.getIsSorted()
1003
+ : header.column.getIsSorted() })] }), jsxRuntime.jsxs("div", { className: "flex flex-none items-center", children: [props.renderFilterButton && header.column.columnDef.meta?.filterName
952
1004
  ? props.renderFilterButton(header.column.columnDef.meta.filterName)
953
- : null, jsxRuntime.jsx(ColumnActions, { header: header, visibleColumnsCount: visibleColumnsCount })] })] })),
1005
+ : null, jsxRuntime.jsx(ColumnActions, { getColumn: props.getColumn, header: header, setSorting: props.setSorting, visibleColumnsCount: visibleColumnsCount })] })] })),
954
1006
  !header.column.columnDef.meta?.shouldGrow && header.column.getCanResize() ? (jsxRuntime.jsx(reactTableBaseComponents.ResizeHandle, { isResizing: header.column.getIsResizing(), onMouseDown: header.getResizeHandler(), onTouchStart: header.getResizeHandler() })) : null));
955
1007
  }) }, headerGroup.id));
956
1008
  }) }), hasResults ? (jsxRuntime.jsx(reactTableBaseComponents.Tbody, { className: "text-sm font-normal", style: {
package/index.esm.js CHANGED
@@ -819,22 +819,50 @@ const useColumnDragDrop = ({ table, }) => {
819
819
  * `ColumnActions` component to render column action controls for a table.
820
820
  *
821
821
  * @template TData The type of the table row data.
822
- * @param {object} props Component properties.
822
+ * @param {ColumnActionsProps} props Component properties.
823
823
  * @param {Header<TData, unknown>} props.header The header of the current column provided by React Table.
824
824
  * @param {number} props.visibleColumnsCount The number of visible columns in the table.
825
825
  */
826
- const ColumnActions = ({ header, visibleColumnsCount, }) => {
826
+ const ColumnActions = ({ header, visibleColumnsCount, setSorting, getColumn }) => {
827
827
  const [t] = useTranslation();
828
- const isSorted = header.column.getIsSorted();
829
- const canSort = header.column.getCanSort();
830
- const canHide = header.column.getCanHide();
831
- const canPin = header.column.getCanPin();
832
- const isPinned = header.column.getIsPinned();
833
- const isAnyActionAvailable = canSort || canPin || (canHide && visibleColumnsCount > 1);
828
+ const isSorted = useMemo(() => header.column.getIsSorted(), [header]);
829
+ const canSort = useMemo(() => header.column.getCanSort(), [header]);
830
+ const canHide = useMemo(() => header.column.getCanHide(), [header]);
831
+ const canPin = useMemo(() => header.column.getCanPin(), [header]);
832
+ const isPinned = useMemo(() => header.column.getIsPinned(), [header]);
833
+ const showHideColumn = useMemo(() => canHide && visibleColumnsCount > 1, [canHide, visibleColumnsCount]);
834
+ const isAnyActionAvailable = useMemo(() => canSort || canPin || showHideColumn, [canPin, canSort, showHideColumn]);
835
+ const sortByKey = header.column.columnDef.meta?.sortByKey;
836
+ const sortByColumn = useMemo(() => (sortByKey ? getColumn(sortByKey) : undefined), [sortByKey, getColumn]);
837
+ const isSortedByKey = sortByKey ? sortByColumn?.getIsSorted() : undefined;
838
+ const showSortAscending = canSort && (sortByKey ? isSortedByKey === "desc" || !isSortedByKey : isSorted === "desc" || !isSorted);
839
+ const showSortDescending = canSort && (sortByKey ? isSortedByKey === "asc" || !isSortedByKey : isSorted === "asc" || !isSorted);
840
+ const showClearSorting = canSort && (sortByKey ? isSortedByKey : isSorted);
841
+ const handleSortAscending = useCallback(() => {
842
+ if (sortByKey) {
843
+ setSorting([{ id: sortByKey, desc: false }]);
844
+ return;
845
+ }
846
+ header.column.toggleSorting(false);
847
+ }, [sortByKey, setSorting, header]);
848
+ const handleSortDescending = useCallback(() => {
849
+ if (sortByKey) {
850
+ setSorting([{ id: sortByKey, desc: true }]);
851
+ return;
852
+ }
853
+ header.column.toggleSorting(true);
854
+ }, [sortByKey, setSorting, header]);
855
+ const handleClearSorting = useCallback(() => {
856
+ if (sortByKey) {
857
+ sortByColumn?.clearSorting();
858
+ return;
859
+ }
860
+ header.column.clearSorting();
861
+ }, [sortByKey, sortByColumn, header]);
834
862
  if (!isAnyActionAvailable) {
835
863
  return null;
836
864
  }
837
- return (jsx(MoreMenu, { customButton: jsx(IconButton, { icon: jsx(Icon, { name: "EllipsisVertical", size: "small" }), onClick: event => event.stopPropagation(), size: "extraSmall", variant: "ghost-neutral" }), children: close => (jsxs(MenuList, { children: [canSort && (isSorted === "desc" || !isSorted) ? (jsx(MenuItem, { label: t("table.columnActions.sortAscending"), onClick: () => header.column.toggleSorting(false), prefix: jsx(Icon, { name: "ArrowUp", size: "medium" }) })) : null, canSort && (isSorted === "asc" || !isSorted) ? (jsx(MenuItem, { label: t("table.columnActions.sortDescending"), onClick: () => header.column.toggleSorting(true), prefix: jsx(Icon, { name: "ArrowDown", size: "medium" }) })) : null, canSort && isSorted ? (jsx(MenuItem, { label: t("table.columnActions.clearSorting"), onClick: () => header.column.clearSorting(), prefix: jsx(Icon, { name: "ArrowsUpDown", size: "medium" }) })) : null, canHide && visibleColumnsCount > 1 ? (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: () => {
865
+ return (jsx(MoreMenu, { customButton: jsx(IconButton, { icon: jsx(Icon, { name: "EllipsisVertical", size: "small" }), onClick: event => event.stopPropagation(), size: "extraSmall", 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: () => {
838
866
  header.column.pin(isPinned ? false : "left");
839
867
  close();
840
868
  }, prefix: jsx(Icon, { name: isPinned ? "Unpin" : "Pin", size: "medium" }) })) : null] })) }));
@@ -921,6 +949,28 @@ const Table = ({ rowHeight = 50, ...props }) => {
921
949
  });
922
950
  const offsets = useCellsOffset(headerGroups.map(group => group.headers), draggingColumnId);
923
951
  const hasResults = props.getRowModel().rows.length > 0;
952
+ const handleColumnClick = useCallback((event, header) => {
953
+ if (header.column.columnDef.meta?.sortByKey) {
954
+ const column = props.getColumn(header.column.columnDef.meta.sortByKey);
955
+ if (column) {
956
+ const isCurrentlySorted = column.getIsSorted();
957
+ if (isCurrentlySorted === "desc") {
958
+ column.clearSorting();
959
+ return;
960
+ }
961
+ if (isCurrentlySorted === "asc") {
962
+ props.setSorting([{ id: header.column.columnDef.meta.sortByKey, desc: true }]);
963
+ return;
964
+ }
965
+ props.setSorting([{ id: header.column.columnDef.meta.sortByKey, desc: false }]);
966
+ return;
967
+ }
968
+ return;
969
+ }
970
+ else {
971
+ header.column.getToggleSortingHandler()?.(event);
972
+ }
973
+ }, [props]);
924
974
  return (jsxs(Card, { className: twMerge("flex flex-col overflow-hidden", props.className), dataTestId: props.dataTestId, 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, jsx("div", { className: "h-full overflow-x-auto overflow-y-scroll border-b border-t border-neutral-200", onScroll: e => fetchMoreOnBottomReached(e.target), ref: tableContainerRef, children: jsxs(TableRoot, { style: {
925
975
  height: hasResults ? "auto" : "100%",
926
976
  width: "100%",
@@ -945,11 +995,13 @@ const Table = ({ rowHeight = 50, ...props }) => {
945
995
  renderDropIndicator(header.id),
946
996
  header.isPlaceholder ? null : (jsxs("div", { ...getDragHandleProps(header.id, header.isPlaceholder, pinned), className: twMerge(cvaColumnHeaderContainer({
947
997
  sortable: canSort,
948
- })), onClick: header.column.getToggleSortingHandler(), children: [jsxs("div", { className: "flex flex-1 items-center gap-1 truncate", 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
998
+ })), onClick: event => handleColumnClick(event, header), children: [jsxs("div", { className: "flex flex-1 items-center gap-1 truncate", 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
949
999
  ? header.column.columnDef.meta.subHeader
950
- : null] })) : null, jsx(ColumnSorting, { canSort: canSort, sortingState: header.column.getIsSorted() })] }), jsxs("div", { className: "flex flex-none items-center", children: [props.renderFilterButton && header.column.columnDef.meta?.filterName
1000
+ : null] })) : null, jsx(ColumnSorting, { canSort: canSort, sortingState: header.column.columnDef.meta?.sortByKey
1001
+ ? props.getColumn(header.column.columnDef.meta.sortByKey)?.getIsSorted()
1002
+ : header.column.getIsSorted() })] }), jsxs("div", { className: "flex flex-none items-center", children: [props.renderFilterButton && header.column.columnDef.meta?.filterName
951
1003
  ? props.renderFilterButton(header.column.columnDef.meta.filterName)
952
- : null, jsx(ColumnActions, { header: header, visibleColumnsCount: visibleColumnsCount })] })] })),
1004
+ : null, jsx(ColumnActions, { getColumn: props.getColumn, header: header, setSorting: props.setSorting, visibleColumnsCount: visibleColumnsCount })] })] })),
953
1005
  !header.column.columnDef.meta?.shouldGrow && header.column.getCanResize() ? (jsx(ResizeHandle, { isResizing: header.column.getIsResizing(), onMouseDown: header.getResizeHandler(), onTouchStart: header.getResizeHandler() })) : null));
954
1006
  }) }, headerGroup.id));
955
1007
  }) }), hasResults ? (jsx(Tbody, { className: "text-sm font-normal", style: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-table",
3
- "version": "1.3.176",
3
+ "version": "1.3.179",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -15,16 +15,16 @@
15
15
  "jest-fetch-mock": "^3.0.3",
16
16
  "@tanstack/react-router": "1.114.29",
17
17
  "tailwind-merge": "^2.0.0",
18
- "@trackunit/react-components": "1.4.141",
19
- "@trackunit/shared-utils": "1.5.118",
20
- "@trackunit/css-class-variance-utilities": "1.3.118",
21
- "@trackunit/ui-icons": "1.3.119",
22
- "@trackunit/react-table-base-components": "1.3.159",
23
- "@trackunit/react-table-pagination": "1.3.118",
24
- "@trackunit/react-form-components": "1.3.159",
25
- "@trackunit/i18n-library-translation": "1.3.132",
26
- "@trackunit/react-core-contexts-api": "1.4.124",
27
- "@trackunit/react-test-setup": "1.0.8"
18
+ "@trackunit/react-components": "1.4.143",
19
+ "@trackunit/shared-utils": "1.5.119",
20
+ "@trackunit/css-class-variance-utilities": "1.3.119",
21
+ "@trackunit/ui-icons": "1.3.120",
22
+ "@trackunit/react-table-base-components": "1.3.161",
23
+ "@trackunit/react-table-pagination": "1.3.119",
24
+ "@trackunit/react-form-components": "1.3.161",
25
+ "@trackunit/i18n-library-translation": "1.3.133",
26
+ "@trackunit/react-core-contexts-api": "1.4.125",
27
+ "@trackunit/react-test-setup": "1.0.9"
28
28
  },
29
29
  "module": "./index.esm.js",
30
30
  "main": "./index.cjs.js",
@@ -1,14 +1,17 @@
1
- import { Header } from "@tanstack/react-table";
1
+ import { Column, Header, SortingState, Updater } from "@tanstack/react-table";
2
+ interface ColumnActionsProps<TData> {
3
+ header: Header<TData, unknown>;
4
+ visibleColumnsCount: number;
5
+ setSorting: (updater: Updater<SortingState>) => void;
6
+ getColumn: (columnId: string) => Column<TData, unknown> | undefined;
7
+ }
2
8
  /**
3
9
  * `ColumnActions` component to render column action controls for a table.
4
10
  *
5
11
  * @template TData The type of the table row data.
6
- * @param {object} props Component properties.
12
+ * @param {ColumnActionsProps} props Component properties.
7
13
  * @param {Header<TData, unknown>} props.header The header of the current column provided by React Table.
8
14
  * @param {number} props.visibleColumnsCount The number of visible columns in the table.
9
15
  */
10
- declare const ColumnActions: <TData>({ header, visibleColumnsCount, }: {
11
- header: Header<TData, unknown>;
12
- visibleColumnsCount: number;
13
- }) => import("react/jsx-runtime").JSX.Element | null;
16
+ declare const ColumnActions: <TData>({ header, visibleColumnsCount, setSorting, getColumn }: ColumnActionsProps<TData>) => import("react/jsx-runtime").JSX.Element | null;
14
17
  export default ColumnActions;
package/src/types.d.ts CHANGED
@@ -31,6 +31,10 @@ declare module "@tanstack/react-table" {
31
31
  * Pinned columns remain visible and stationary during horizontal scrolling of the table.
32
32
  */
33
33
  pinned?: "left" | "right";
34
+ /**
35
+ * Indicates that sorting is applied for example based on 'userId', while the column displays 'userDisplayName'.
36
+ */
37
+ sortByKey?: string;
34
38
  }
35
39
  }
36
40
  export type Alignment = "left" | "center" | "right";