@trackunit/react-table 1.3.226 → 1.3.227
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,39 +503,6 @@ 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
|
-
|
|
539
506
|
/**
|
|
540
507
|
* This component is used to display a text with a tooltip.
|
|
541
508
|
* The tooltip is displayed if the text is truncated with ellipsis.
|
|
@@ -1038,7 +1005,7 @@ const Table = ({ rowHeight = 50, ...props }) => {
|
|
|
1038
1005
|
: null, jsxRuntime.jsx(ColumnActions, { getColumn: props.getColumn, header: header, setSorting: props.setSorting, visibleColumnsCount: visibleColumnsCount })] })] })),
|
|
1039
1006
|
!header.column.columnDef.meta?.shouldGrow && header.column.getCanResize() ? (jsxRuntime.jsx(reactTableBaseComponents.ResizeHandle, { isResizing: header.column.getIsResizing(), onMouseDown: header.getResizeHandler(), onTouchStart: header.getResizeHandler() })) : null));
|
|
1040
1007
|
}) }, headerGroup.id));
|
|
1041
|
-
}) }),
|
|
1008
|
+
}) }), hasResults ? (jsxRuntime.jsx(reactTableBaseComponents.Tbody, { className: "text-sm font-normal", style: {
|
|
1042
1009
|
height: `${getTotalSize()}px`,
|
|
1043
1010
|
flexGrow: 1,
|
|
1044
1011
|
}, children: getVirtualItems().map((virtualRow, index) => {
|
|
@@ -1093,7 +1060,7 @@ const Table = ({ rowHeight = 50, ...props }) => {
|
|
|
1093
1060
|
jsxRuntime.jsx("div", { className: "grid h-full items-center p-0", children: reactTable.flexRender(cell.column.columnDef.cell, cell.getContext()) })));
|
|
1094
1061
|
}) }, row.id));
|
|
1095
1062
|
}
|
|
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", {
|
|
1063
|
+
}) })) : (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" })) : 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", 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", {
|
|
1097
1064
|
count: props.getRowModel().rows.length,
|
|
1098
1065
|
total: props.pagination?.pageInfo?.count || 0,
|
|
1099
1066
|
}) }), 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, IconButton, Card, Spinner, EmptyState } 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,39 +502,6 @@ 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
|
-
|
|
538
505
|
/**
|
|
539
506
|
* This component is used to display a text with a tooltip.
|
|
540
507
|
* The tooltip is displayed if the text is truncated with ellipsis.
|
|
@@ -1037,7 +1004,7 @@ const Table = ({ rowHeight = 50, ...props }) => {
|
|
|
1037
1004
|
: null, jsx(ColumnActions, { getColumn: props.getColumn, header: header, setSorting: props.setSorting, visibleColumnsCount: visibleColumnsCount })] })] })),
|
|
1038
1005
|
!header.column.columnDef.meta?.shouldGrow && header.column.getCanResize() ? (jsx(ResizeHandle, { isResizing: header.column.getIsResizing(), onMouseDown: header.getResizeHandler(), onTouchStart: header.getResizeHandler() })) : null));
|
|
1039
1006
|
}) }, headerGroup.id));
|
|
1040
|
-
}) }),
|
|
1007
|
+
}) }), hasResults ? (jsx(Tbody, { className: "text-sm font-normal", style: {
|
|
1041
1008
|
height: `${getTotalSize()}px`,
|
|
1042
1009
|
flexGrow: 1,
|
|
1043
1010
|
}, children: getVirtualItems().map((virtualRow, index) => {
|
|
@@ -1092,7 +1059,7 @@ const Table = ({ rowHeight = 50, ...props }) => {
|
|
|
1092
1059
|
jsx("div", { className: "grid h-full items-center p-0", children: flexRender(cell.column.columnDef.cell, cell.getContext()) })));
|
|
1093
1060
|
}) }, row.id));
|
|
1094
1061
|
}
|
|
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", {
|
|
1062
|
+
}) })) : (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" })) : 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", 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", {
|
|
1096
1063
|
count: props.getRowModel().rows.length,
|
|
1097
1064
|
total: props.pagination?.pageInfo?.count || 0,
|
|
1098
1065
|
}) }), 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
|
@@ -1,15 +0,0 @@
|
|
|
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 {};
|
|
@@ -1,9 +0,0 @@
|
|
|
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;
|
|
@@ -1,13 +0,0 @@
|
|
|
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 {};
|