@trackunit/react-table 1.3.138 → 1.3.141

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-table",
3
- "version": "1.3.138",
3
+ "version": "1.3.141",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -15,15 +15,15 @@
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.114",
19
- "@trackunit/shared-utils": "1.5.97",
20
- "@trackunit/css-class-variance-utilities": "1.3.97",
21
- "@trackunit/ui-icons": "1.3.97",
22
- "@trackunit/react-table-base-components": "1.3.130",
23
- "@trackunit/react-table-pagination": "1.3.98",
24
- "@trackunit/react-form-components": "1.3.130",
25
- "@trackunit/i18n-library-translation": "1.3.106",
26
- "@trackunit/react-core-contexts-api": "1.4.100"
18
+ "@trackunit/react-components": "1.4.117",
19
+ "@trackunit/shared-utils": "1.5.98",
20
+ "@trackunit/css-class-variance-utilities": "1.3.98",
21
+ "@trackunit/ui-icons": "1.3.99",
22
+ "@trackunit/react-table-base-components": "1.3.133",
23
+ "@trackunit/react-table-pagination": "1.3.99",
24
+ "@trackunit/react-form-components": "1.3.133",
25
+ "@trackunit/i18n-library-translation": "1.3.108",
26
+ "@trackunit/react-core-contexts-api": "1.4.101"
27
27
  },
28
28
  "module": "./index.esm.js",
29
29
  "main": "./index.cjs.js",
package/src/Table.d.ts CHANGED
@@ -2,6 +2,7 @@ import { Table as ReactTable, Row } from "@tanstack/react-table";
2
2
  import { CommonProps, EmptyStateProps } from "@trackunit/react-components";
3
3
  import { RelayPagination } from "@trackunit/react-table-pagination";
4
4
  import { ReactElement, ReactNode } from "react";
5
+ import "./table-animations.css";
5
6
  export interface TableProps<TData extends object> extends ReactTable<TData>, CommonProps {
6
7
  pagination?: RelayPagination;
7
8
  headerLeftActions?: ReactNode;
@@ -14,6 +15,7 @@ export interface TableProps<TData extends object> extends ReactTable<TData>, Com
14
15
  hideFooter?: boolean;
15
16
  emptyState?: EmptyStateProps;
16
17
  selectionColId?: string;
18
+ renderFilterButton?: (filterKey: string | string[]) => React.ReactNode;
17
19
  isRowClickable?: (row: TData) => boolean;
18
20
  }
19
21
  /**
@@ -0,0 +1,13 @@
1
+ import { TextWeight } from "@trackunit/react-components";
2
+ import { ReactNode } from "react";
3
+ /**
4
+ * This component is used to display a text with a tooltip.
5
+ * The tooltip is displayed if the text is truncated with ellipsis.
6
+ * The text is the text to display.
7
+ * The tooltipLabel is the label to display in the tooltip.
8
+ */
9
+ export declare const TextWithTooltip: ({ children, tooltipLabel, weight, }: {
10
+ children: ReactNode;
11
+ tooltipLabel?: string;
12
+ weight?: TextWeight;
13
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,21 @@
1
+ import { Header } from "@tanstack/react-table";
2
+ /**
3
+ * The `useCellsOffset` hook calculates column offsets for pinned columns ("left" or "right") in a table.
4
+ *
5
+ * @template TData The type of the row data in the table.
6
+ * @param {Header<TData, unknown>[][]} headerGroups - Array of table header groups.
7
+ * @param {string | null} draggingColumnId - The ID of the column currently being dragged. If null, no dragging is occurring.
8
+ * @returns {Array<object>} Returns an array of objects containing `leftOffsets` and `rightOffsets` for each header group.
9
+ */
10
+ export declare const useCellsOffset: <TData extends object>(headerGroups: Header<TData, unknown>[][], draggingColumnId: string | null) => {
11
+ leftOffsets: Record<string, {
12
+ id: string;
13
+ offset: number;
14
+ pinned: "left";
15
+ }>;
16
+ rightOffsets: Record<string, {
17
+ id: string;
18
+ offset: number;
19
+ pinned: "right";
20
+ }>;
21
+ }[];
@@ -0,0 +1,25 @@
1
+ import { Table as ReactTable } from "@tanstack/react-table";
2
+ interface ColumnDragDropOptions<TData extends object> {
3
+ table: ReactTable<TData>;
4
+ }
5
+ type ColumnStyles = {
6
+ [x: string]: number | string | undefined;
7
+ };
8
+ /**
9
+ * Hook for handling column drag and drop functionality in a table
10
+ *
11
+ * @param options - Options including the ReactTable instance and optional callbacks
12
+ * @returns Object containing drag state and handler functions
13
+ */
14
+ export declare const useColumnDragDrop: <TData extends object>({ table, }: ColumnDragDropOptions<TData>) => {
15
+ draggingColumnId: string | null;
16
+ droppedColumnId: string | null;
17
+ dropTargetColumnId: string | null;
18
+ dropPosition: "left" | "right" | null;
19
+ getHeaderProps: (headerId: string, styles?: ColumnStyles) => React.HTMLAttributes<HTMLTableCellElement>;
20
+ getDragHandleProps: (headerId: string, isPlaceholder: boolean, pinned?: "left" | "right" | "") => React.HTMLAttributes<HTMLTableCellElement>;
21
+ renderDropIndicator: (columnId: string) => React.ReactNode;
22
+ isCellDropTarget: (columnId: string) => boolean;
23
+ getCellProps: (columnId: string, styles?: ColumnStyles) => React.HTMLAttributes<HTMLTableCellElement>;
24
+ };
25
+ export {};
@@ -0,0 +1,14 @@
1
+ import { Header } from "@tanstack/react-table";
2
+ /**
3
+ * `ColumnActions` component to render column action controls for a table.
4
+ *
5
+ * @template TData The type of the table row data.
6
+ * @param {object} props Component properties.
7
+ * @param {Header<TData, unknown>} props.header The header of the current column provided by React Table.
8
+ * @param {number} props.visibleColumnsCount The number of visible columns in the table.
9
+ */
10
+ declare const ColumnActions: <TData>({ header, visibleColumnsCount, }: {
11
+ header: Header<TData, unknown>;
12
+ visibleColumnsCount: number;
13
+ }) => import("react/jsx-runtime").JSX.Element | null;
14
+ export default ColumnActions;
@@ -19,5 +19,6 @@ export interface ColumnFiltersDragAndDropProps<TColumnFiltersDragAndDrop extends
19
19
  columns: Column<TColumnFiltersDragAndDrop, TColumnFiltersDragAndDropValue>[];
20
20
  setColumnOrder: (updater: Updater<ColumnOrderState>) => void;
21
21
  onUserEvent?: (event: "Column Reordering" | "Column Filter", payload: Record<string, unknown>) => void;
22
- defaultColumnOrder: ColumnOrderState;
22
+ isSortDisabled: boolean;
23
+ visibleColumnsCount: number;
23
24
  }
@@ -0,0 +1,19 @@
1
+ import { ReactElement } from "react";
2
+ type ColumnSortingProps = {
3
+ canSort: boolean;
4
+ sortingState?: false | "asc" | "desc";
5
+ };
6
+ /**
7
+ * The ColumnSorting is used in the table header to indicate the current sort order of the column.
8
+ * This is a visual only component and does not handle the sorting logic.
9
+ *
10
+ * In most cases, we recommend using the Table Component which already handles sorting indication.
11
+ * However, if you need to construct a custom table, the Table Base Components can be utilized.
12
+ *
13
+ * @param {object} props - Props for the sorting indicator.
14
+ * @param {boolean} [props.canSort] - Indicates the header sorting ability state (ascending/descending).
15
+ * @param {boolean} [props.sortingState=false] - Indicates the sorting state (ascending/descending).
16
+ * @returns {ReactElement | null} A React element representing the sorting indicator.
17
+ */
18
+ declare const ColumnSorting: ({ canSort, sortingState }: ColumnSortingProps) => ReactElement | null;
19
+ export default ColumnSorting;
@@ -14,8 +14,8 @@ export declare const translations: TranslationResource<TranslationKeys>;
14
14
  /**
15
15
  * Local useTranslation for this specific library
16
16
  */
17
- export declare const useTranslation: () => [TransForLibs<"layout.actions.reset" | "table.actionsheet.selected" | "table.columnFilters.columns" | "table.columnFilters.hiddenColumnCount" | "table.columnFilters.hiddenColumnsCount" | "table.columnFilters.title" | "table.columnFilters.tooltip" | "table.error" | "table.exportFileName" | "table.format" | "table.noResults" | "table.pagination.full" | "table.pagination.full.capped" | "table.pagination.of" | "table.pagination.page" | "table.result" | "table.results.plural" | "table.results.plural.capped" | "table.rowDensity.compact" | "table.rowDensity.spacious" | "table.search.placeholder" | "table.searchPlaceholder" | "table.selection.label" | "table.sorting.ascending" | "table.sorting.descending" | "table.sorting.label" | "table.sorting.order" | "table.sorting.toolip" | "table.spacing" | "table.spacing.toolip">, import("i18next").i18n, boolean] & {
18
- t: TransForLibs<"layout.actions.reset" | "table.actionsheet.selected" | "table.columnFilters.columns" | "table.columnFilters.hiddenColumnCount" | "table.columnFilters.hiddenColumnsCount" | "table.columnFilters.title" | "table.columnFilters.tooltip" | "table.error" | "table.exportFileName" | "table.format" | "table.noResults" | "table.pagination.full" | "table.pagination.full.capped" | "table.pagination.of" | "table.pagination.page" | "table.result" | "table.results.plural" | "table.results.plural.capped" | "table.rowDensity.compact" | "table.rowDensity.spacious" | "table.search.placeholder" | "table.searchPlaceholder" | "table.selection.label" | "table.sorting.ascending" | "table.sorting.descending" | "table.sorting.label" | "table.sorting.order" | "table.sorting.toolip" | "table.spacing" | "table.spacing.toolip">;
17
+ export declare const useTranslation: () => [TransForLibs<"layout.actions.reset" | "table.actionsheet.selected" | "table.columnActions.clearSorting" | "table.columnActions.hideColumn" | "table.columnActions.pinColumn" | "table.columnActions.sortAscending" | "table.columnActions.sortDescending" | "table.columnActions.unPinColumn" | "table.columnFilters.columns" | "table.columnFilters.hiddenColumnCount" | "table.columnFilters.hiddenColumnsCount" | "table.columnFilters.title" | "table.columnFilters.tooltip" | "table.error" | "table.exportFileName" | "table.format" | "table.noResults" | "table.pagination.full" | "table.pagination.full.capped" | "table.pagination.of" | "table.pagination.page" | "table.result" | "table.results.plural" | "table.results.plural.capped" | "table.rowDensity.compact" | "table.rowDensity.spacious" | "table.search.placeholder" | "table.searchPlaceholder" | "table.selection.label" | "table.sorting.ascending" | "table.sorting.descending" | "table.sorting.label" | "table.sorting.order" | "table.sorting.toolip" | "table.spacing" | "table.spacing.toolip">, import("i18next").i18n, boolean] & {
18
+ t: TransForLibs<"layout.actions.reset" | "table.actionsheet.selected" | "table.columnActions.clearSorting" | "table.columnActions.hideColumn" | "table.columnActions.pinColumn" | "table.columnActions.sortAscending" | "table.columnActions.sortDescending" | "table.columnActions.unPinColumn" | "table.columnFilters.columns" | "table.columnFilters.hiddenColumnCount" | "table.columnFilters.hiddenColumnsCount" | "table.columnFilters.title" | "table.columnFilters.tooltip" | "table.error" | "table.exportFileName" | "table.format" | "table.noResults" | "table.pagination.full" | "table.pagination.full.capped" | "table.pagination.of" | "table.pagination.page" | "table.result" | "table.results.plural" | "table.results.plural.capped" | "table.rowDensity.compact" | "table.rowDensity.spacious" | "table.search.placeholder" | "table.searchPlaceholder" | "table.selection.label" | "table.sorting.ascending" | "table.sorting.descending" | "table.sorting.label" | "table.sorting.order" | "table.sorting.toolip" | "table.spacing" | "table.spacing.toolip">;
19
19
  i18n: import("i18next").i18n;
20
20
  ready: boolean;
21
21
  };
package/src/types.d.ts CHANGED
@@ -19,6 +19,18 @@ declare module "@tanstack/react-table" {
19
19
  * Used for dynamic headers like the selection column that uses a checkbox header in the table but should have a different column name in the Column Filter.
20
20
  */
21
21
  columnFilterLabel?: string;
22
+ /**
23
+ * Allows to overwrite the Column Filter label.
24
+ * Used for dynamic headers like the selection column that uses a checkbox header in the table but should have a different column name in the Column Filter.
25
+ */
26
+ filterName?: string | string[];
27
+ /**
28
+ * Specifies whether the column should be pinned (fixed) to the left or right side of the table.
29
+ * The value "left" pins the column to the left, and "right" pins it to the right.
30
+ *
31
+ * Pinned columns remain visible and stationary during horizontal scrolling of the table.
32
+ */
33
+ pinned?: "left" | "right";
22
34
  }
23
35
  }
24
36
  export type Alignment = "left" | "center" | "right";