@trackunit/react-table 1.3.223 → 1.3.224
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
|
@@ -503,6 +503,39 @@ const Sorting = ({ columns, }) => {
|
|
|
503
503
|
return (jsxRuntime.jsx(reactComponents.Tooltip, { label: t("table.sorting.toolip"), placement: "bottom", children: jsxRuntime.jsxs(reactComponents.Popover, { placement: "bottom-start", children: [jsxRuntime.jsx(reactComponents.PopoverTrigger, { children: jsxRuntime.jsx(reactComponents.Button, { prefix: currentSortDirection === "asc" ? (jsxRuntime.jsx(reactComponents.Icon, { name: "BarsArrowUp", size: "small" })) : (jsxRuntime.jsx(reactComponents.Icon, { name: "BarsArrowDown", size: "small" })), size: "small", variant: "ghost-neutral", children: jsxRuntime.jsx("span", { className: "hidden sm:block", children: t("table.sorting.label") }) }) }), jsxRuntime.jsx(reactComponents.PopoverContent, { children: jsxRuntime.jsxs(reactComponents.MenuList, { className: "max-h-[55vh] overflow-y-auto", children: [jsxRuntime.jsx(reactFormComponents.RadioGroup, { id: "sortProperty", onChange: handleSelectionChange, value: currentSortValue ?? "", children: sortableColumns.map(column => (jsxRuntime.jsx(reactFormComponents.RadioItem, { className: "w-full", label: column.columnDef.header?.toString() ?? "", value: column.id }, column.id))) }), jsxRuntime.jsxs(reactFormComponents.RadioGroup, { id: "sortOrder", onChange: onSelectOrder, value: currentSortDirection, children: [jsxRuntime.jsx(reactFormComponents.RadioItem, { className: "w-full", label: t("table.sorting.ascending"), value: "asc" }), jsxRuntime.jsx(reactFormComponents.RadioItem, { className: "w-full", label: t("table.sorting.descending"), value: "desc" })] })] }) })] }) }));
|
|
504
504
|
};
|
|
505
505
|
|
|
506
|
+
/**
|
|
507
|
+
* A table component that displays an empty state when there are no data entries available.
|
|
508
|
+
*
|
|
509
|
+
* @param {EmptyStateTableProps} props - The props for the component.
|
|
510
|
+
* @param {string} [props.className] - Additional class names for styling.
|
|
511
|
+
* @param {EmptyStateProps} [props.emptyState] - Optional configuration for customizing the EmptyState component.
|
|
512
|
+
* @returns {ReactElement} A table body element containing the empty state.
|
|
513
|
+
*/
|
|
514
|
+
const EmptyStateTable = ({ className, emptyState }) => {
|
|
515
|
+
const [t] = useTranslation();
|
|
516
|
+
return (jsxRuntime.jsx("tbody", { className: className, children: jsxRuntime.jsx("tr", { children: jsxRuntime.jsx("td", { className: "b-0", children: jsxRuntime.jsx(reactComponents.EmptyState, { className: "absolute inset-0", description: t("table.noResults"), image: "SEARCH_DOCUMENT", ...emptyState }) }) }) }));
|
|
517
|
+
};
|
|
518
|
+
|
|
519
|
+
/**
|
|
520
|
+
* A component to display a loading state with a spinner.
|
|
521
|
+
*
|
|
522
|
+
* @param {CommonProps} props - The props for the component, including an optional `className`.
|
|
523
|
+
* @returns {ReactElement} A table body element displaying a centered spinner.
|
|
524
|
+
*/
|
|
525
|
+
const LoadingState = ({ className }) => {
|
|
526
|
+
return (jsxRuntime.jsx("tbody", { className: className, children: jsxRuntime.jsx("tr", { children: jsxRuntime.jsx("td", { className: "b-0", children: jsxRuntime.jsx(reactComponents.Spinner, { centering: "centered", containerClassName: "absolute inset-0" }) }) }) }));
|
|
527
|
+
};
|
|
528
|
+
|
|
529
|
+
/**
|
|
530
|
+
* Component to display a "No Data" state.
|
|
531
|
+
*
|
|
532
|
+
* @param {NoDataMessageStateProps} props - The props for the component.
|
|
533
|
+
* @returns {ReactElement} A component rendering a message for empty data states.
|
|
534
|
+
*/
|
|
535
|
+
const NoDataMessageState = ({ message, className }) => {
|
|
536
|
+
return (jsxRuntime.jsx("tbody", { className: className, children: jsxRuntime.jsx("tr", { children: jsxRuntime.jsx("td", { className: "b-0", children: message }) }) }));
|
|
537
|
+
};
|
|
538
|
+
|
|
506
539
|
/**
|
|
507
540
|
* This component is used to display a text with a tooltip.
|
|
508
541
|
* The tooltip is displayed if the text is truncated with ellipsis.
|
|
@@ -1005,7 +1038,7 @@ const Table = ({ rowHeight = 50, ...props }) => {
|
|
|
1005
1038
|
: null, jsxRuntime.jsx(ColumnActions, { getColumn: props.getColumn, header: header, setSorting: props.setSorting, visibleColumnsCount: visibleColumnsCount })] })] })),
|
|
1006
1039
|
!header.column.columnDef.meta?.shouldGrow && header.column.getCanResize() ? (jsxRuntime.jsx(reactTableBaseComponents.ResizeHandle, { isResizing: header.column.getIsResizing(), onMouseDown: header.getResizeHandler(), onTouchStart: header.getResizeHandler() })) : null));
|
|
1007
1040
|
}) }, headerGroup.id));
|
|
1008
|
-
}) }), hasResults ? (jsxRuntime.jsx(reactTableBaseComponents.Tbody, { className: "text-sm font-normal", style: {
|
|
1041
|
+
}) }), props.loading ? (jsxRuntime.jsx(LoadingState, { className: cvaTBody({ emptyState: false }) })) : props.noDataMessage && !hasResults ? (jsxRuntime.jsx(NoDataMessageState, { className: cvaTBody({ emptyState: false }), message: props.noDataMessage })) : !hasResults ? (jsxRuntime.jsx(EmptyStateTable, { className: cvaTBody({ emptyState: true }), emptyState: props.emptyState })) : (jsxRuntime.jsx(reactTableBaseComponents.Tbody, { className: "text-sm font-normal", style: {
|
|
1009
1042
|
height: `${getTotalSize()}px`,
|
|
1010
1043
|
flexGrow: 1,
|
|
1011
1044
|
}, children: getVirtualItems().map((virtualRow, index) => {
|
|
@@ -1060,7 +1093,7 @@ const Table = ({ rowHeight = 50, ...props }) => {
|
|
|
1060
1093
|
jsxRuntime.jsx("div", { className: "grid h-full items-center p-0", children: reactTable.flexRender(cell.column.columnDef.cell, cell.getContext()) })));
|
|
1061
1094
|
}) }, row.id));
|
|
1062
1095
|
}
|
|
1063
|
-
}) }))
|
|
1096
|
+
}) }))] }) }), props.hideFooter ? null : (jsxRuntime.jsxs("div", { className: "flex items-center p-2", children: [jsxRuntime.jsx("div", { className: "whitespace-nowrap text-xs font-medium text-neutral-600", children: t(props.pagination?.pageInfo?.isCountCapped ? "table.pagination.full.capped" : "table.pagination.full", {
|
|
1064
1097
|
count: props.getRowModel().rows.length,
|
|
1065
1098
|
total: props.pagination?.pageInfo?.count || 0,
|
|
1066
1099
|
}) }), 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] }))] }));
|
package/index.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import { registerTranslations, useNamespaceTranslation } from '@trackunit/i18n-library-translation';
|
|
3
|
-
import { MenuItem, Icon, Button, useOverflowItems, MoreMenu, MenuList, Spacer, cvaInteractableItem, Text, Tooltip, Popover, PopoverTrigger, PopoverContent,
|
|
3
|
+
import { MenuItem, Icon, Button, useOverflowItems, MoreMenu, MenuList, Spacer, cvaInteractableItem, Text, Tooltip, Popover, PopoverTrigger, PopoverContent, EmptyState, Spinner, IconButton, Card } from '@trackunit/react-components';
|
|
4
4
|
import { objectValues, nonNullable, objectKeys, objectEntries } from '@trackunit/shared-utils';
|
|
5
5
|
import { useMemo, Children, cloneElement, useRef, useState, useEffect, useCallback, createElement } from 'react';
|
|
6
6
|
import { cvaMerge } from '@trackunit/css-class-variance-utilities';
|
|
@@ -502,6 +502,39 @@ const Sorting = ({ columns, }) => {
|
|
|
502
502
|
return (jsx(Tooltip, { label: t("table.sorting.toolip"), placement: "bottom", children: jsxs(Popover, { placement: "bottom-start", children: [jsx(PopoverTrigger, { children: jsx(Button, { prefix: currentSortDirection === "asc" ? (jsx(Icon, { name: "BarsArrowUp", size: "small" })) : (jsx(Icon, { name: "BarsArrowDown", size: "small" })), size: "small", variant: "ghost-neutral", children: jsx("span", { className: "hidden sm:block", children: t("table.sorting.label") }) }) }), jsx(PopoverContent, { children: jsxs(MenuList, { className: "max-h-[55vh] overflow-y-auto", children: [jsx(RadioGroup, { id: "sortProperty", onChange: handleSelectionChange, value: currentSortValue ?? "", children: sortableColumns.map(column => (jsx(RadioItem, { className: "w-full", label: column.columnDef.header?.toString() ?? "", value: column.id }, column.id))) }), jsxs(RadioGroup, { id: "sortOrder", onChange: onSelectOrder, value: currentSortDirection, children: [jsx(RadioItem, { className: "w-full", label: t("table.sorting.ascending"), value: "asc" }), jsx(RadioItem, { className: "w-full", label: t("table.sorting.descending"), value: "desc" })] })] }) })] }) }));
|
|
503
503
|
};
|
|
504
504
|
|
|
505
|
+
/**
|
|
506
|
+
* A table component that displays an empty state when there are no data entries available.
|
|
507
|
+
*
|
|
508
|
+
* @param {EmptyStateTableProps} props - The props for the component.
|
|
509
|
+
* @param {string} [props.className] - Additional class names for styling.
|
|
510
|
+
* @param {EmptyStateProps} [props.emptyState] - Optional configuration for customizing the EmptyState component.
|
|
511
|
+
* @returns {ReactElement} A table body element containing the empty state.
|
|
512
|
+
*/
|
|
513
|
+
const EmptyStateTable = ({ className, emptyState }) => {
|
|
514
|
+
const [t] = useTranslation();
|
|
515
|
+
return (jsx("tbody", { className: className, children: jsx("tr", { children: jsx("td", { className: "b-0", children: jsx(EmptyState, { className: "absolute inset-0", description: t("table.noResults"), image: "SEARCH_DOCUMENT", ...emptyState }) }) }) }));
|
|
516
|
+
};
|
|
517
|
+
|
|
518
|
+
/**
|
|
519
|
+
* A component to display a loading state with a spinner.
|
|
520
|
+
*
|
|
521
|
+
* @param {CommonProps} props - The props for the component, including an optional `className`.
|
|
522
|
+
* @returns {ReactElement} A table body element displaying a centered spinner.
|
|
523
|
+
*/
|
|
524
|
+
const LoadingState = ({ className }) => {
|
|
525
|
+
return (jsx("tbody", { className: className, children: jsx("tr", { children: jsx("td", { className: "b-0", children: jsx(Spinner, { centering: "centered", containerClassName: "absolute inset-0" }) }) }) }));
|
|
526
|
+
};
|
|
527
|
+
|
|
528
|
+
/**
|
|
529
|
+
* Component to display a "No Data" state.
|
|
530
|
+
*
|
|
531
|
+
* @param {NoDataMessageStateProps} props - The props for the component.
|
|
532
|
+
* @returns {ReactElement} A component rendering a message for empty data states.
|
|
533
|
+
*/
|
|
534
|
+
const NoDataMessageState = ({ message, className }) => {
|
|
535
|
+
return (jsx("tbody", { className: className, children: jsx("tr", { children: jsx("td", { className: "b-0", children: message }) }) }));
|
|
536
|
+
};
|
|
537
|
+
|
|
505
538
|
/**
|
|
506
539
|
* This component is used to display a text with a tooltip.
|
|
507
540
|
* The tooltip is displayed if the text is truncated with ellipsis.
|
|
@@ -1004,7 +1037,7 @@ const Table = ({ rowHeight = 50, ...props }) => {
|
|
|
1004
1037
|
: null, jsx(ColumnActions, { getColumn: props.getColumn, header: header, setSorting: props.setSorting, visibleColumnsCount: visibleColumnsCount })] })] })),
|
|
1005
1038
|
!header.column.columnDef.meta?.shouldGrow && header.column.getCanResize() ? (jsx(ResizeHandle, { isResizing: header.column.getIsResizing(), onMouseDown: header.getResizeHandler(), onTouchStart: header.getResizeHandler() })) : null));
|
|
1006
1039
|
}) }, headerGroup.id));
|
|
1007
|
-
}) }), hasResults ? (jsx(Tbody, { className: "text-sm font-normal", style: {
|
|
1040
|
+
}) }), props.loading ? (jsx(LoadingState, { className: cvaTBody({ emptyState: false }) })) : props.noDataMessage && !hasResults ? (jsx(NoDataMessageState, { className: cvaTBody({ emptyState: false }), message: props.noDataMessage })) : !hasResults ? (jsx(EmptyStateTable, { className: cvaTBody({ emptyState: true }), emptyState: props.emptyState })) : (jsx(Tbody, { className: "text-sm font-normal", style: {
|
|
1008
1041
|
height: `${getTotalSize()}px`,
|
|
1009
1042
|
flexGrow: 1,
|
|
1010
1043
|
}, children: getVirtualItems().map((virtualRow, index) => {
|
|
@@ -1059,7 +1092,7 @@ const Table = ({ rowHeight = 50, ...props }) => {
|
|
|
1059
1092
|
jsx("div", { className: "grid h-full items-center p-0", children: flexRender(cell.column.columnDef.cell, cell.getContext()) })));
|
|
1060
1093
|
}) }, row.id));
|
|
1061
1094
|
}
|
|
1062
|
-
}) }))
|
|
1095
|
+
}) }))] }) }), props.hideFooter ? null : (jsxs("div", { className: "flex items-center p-2", children: [jsx("div", { className: "whitespace-nowrap text-xs font-medium text-neutral-600", children: t(props.pagination?.pageInfo?.isCountCapped ? "table.pagination.full.capped" : "table.pagination.full", {
|
|
1063
1096
|
count: props.getRowModel().rows.length,
|
|
1064
1097
|
total: props.pagination?.pageInfo?.count || 0,
|
|
1065
1098
|
}) }), 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] }))] }));
|
package/package.json
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CommonProps, EmptyStateProps } from "@trackunit/react-components";
|
|
2
|
+
import { ReactElement } from "react";
|
|
3
|
+
interface EmptyStateTableProps extends CommonProps {
|
|
4
|
+
emptyState?: EmptyStateProps;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* A table component that displays an empty state when there are no data entries available.
|
|
8
|
+
*
|
|
9
|
+
* @param {EmptyStateTableProps} props - The props for the component.
|
|
10
|
+
* @param {string} [props.className] - Additional class names for styling.
|
|
11
|
+
* @param {EmptyStateProps} [props.emptyState] - Optional configuration for customizing the EmptyState component.
|
|
12
|
+
* @returns {ReactElement} A table body element containing the empty state.
|
|
13
|
+
*/
|
|
14
|
+
export declare const EmptyStateTable: ({ className, emptyState }: EmptyStateTableProps) => ReactElement;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CommonProps } from "@trackunit/react-components";
|
|
2
|
+
import { ReactElement } from "react";
|
|
3
|
+
/**
|
|
4
|
+
* A component to display a loading state with a spinner.
|
|
5
|
+
*
|
|
6
|
+
* @param {CommonProps} props - The props for the component, including an optional `className`.
|
|
7
|
+
* @returns {ReactElement} A table body element displaying a centered spinner.
|
|
8
|
+
*/
|
|
9
|
+
export declare const LoadingState: ({ className }: CommonProps) => ReactElement;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CommonProps } from "@trackunit/react-components";
|
|
2
|
+
import { ReactElement } from "react";
|
|
3
|
+
interface NoDataMessageStateProps extends CommonProps {
|
|
4
|
+
message?: ReactElement | string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Component to display a "No Data" state.
|
|
8
|
+
*
|
|
9
|
+
* @param {NoDataMessageStateProps} props - The props for the component.
|
|
10
|
+
* @returns {ReactElement} A component rendering a message for empty data states.
|
|
11
|
+
*/
|
|
12
|
+
export declare const NoDataMessageState: ({ message, className }: NoDataMessageStateProps) => ReactElement;
|
|
13
|
+
export {};
|