lecom-ui 4.1.4 → 4.1.6
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.
|
@@ -6,8 +6,6 @@ import { Skeleton } from '../Skeleton/Skeleton.js';
|
|
|
6
6
|
import { buildColumns } from './DataTable.utils.js';
|
|
7
7
|
|
|
8
8
|
function DataTable({
|
|
9
|
-
columnFullSize,
|
|
10
|
-
fixedColumns,
|
|
11
9
|
isLoading,
|
|
12
10
|
columns,
|
|
13
11
|
data,
|
|
@@ -25,10 +23,7 @@ function DataTable({
|
|
|
25
23
|
onSortingChange: setSorting,
|
|
26
24
|
getSortedRowModel: getSortedRowModel(),
|
|
27
25
|
state: {
|
|
28
|
-
sorting
|
|
29
|
-
columnPinning: {
|
|
30
|
-
left: fixedColumns || []
|
|
31
|
-
}
|
|
26
|
+
sorting
|
|
32
27
|
}
|
|
33
28
|
});
|
|
34
29
|
const styleDataTableContainer = () => ({
|
|
@@ -41,15 +36,30 @@ function DataTable({
|
|
|
41
36
|
}
|
|
42
37
|
return /* @__PURE__ */ React.createElement(Pagination, { ...pagination });
|
|
43
38
|
};
|
|
39
|
+
const styleColumn = (meta) => ({
|
|
40
|
+
width: meta.width
|
|
41
|
+
});
|
|
42
|
+
const getFixed = (meta) => meta.fixed;
|
|
44
43
|
const arrSkeleton = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15];
|
|
45
44
|
React.useEffect(() => {
|
|
46
45
|
if (!isLoading) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
46
|
+
const listRows = document.querySelectorAll(`table#data-table tr`);
|
|
47
|
+
listRows.forEach((listRow, listRowIndex) => {
|
|
48
|
+
const rowsElem = listRow.querySelectorAll("[data-fixed]");
|
|
49
|
+
rowsElem.forEach((rowElem, rowElemIndex) => {
|
|
50
|
+
const beforeElem = rowsElem[rowElemIndex - 1];
|
|
51
|
+
const currentElem = rowElem;
|
|
52
|
+
const beforeElemWidth = beforeElem?.getBoundingClientRect()?.width ?? 0;
|
|
53
|
+
const beforeElemLeft = beforeElem?.style?.left ? Number(beforeElem.style.left.replace(/px/g, "")) : 0;
|
|
54
|
+
const lastColumnFixed = rowsElem.length - 1 === rowElemIndex;
|
|
55
|
+
const lastRow = listRows.length - 1 === listRowIndex;
|
|
56
|
+
const currentElemIsTh = currentElem.tagName === "TH";
|
|
57
|
+
const boxShadow = lastColumnFixed ? `#c9c9c9 -0.5px ${lastRow ? "0px" : currentElemIsTh ? "-1.5px" : "-0.5px"} 0px inset` : `#c9c9c9 0px ${lastRow ? "0px" : currentElemIsTh ? "-1.5px" : "-0.5px"} 0px inset`;
|
|
58
|
+
currentElem.style.position = "sticky";
|
|
59
|
+
currentElem.style.left = `${beforeElemWidth + beforeElemLeft}px`;
|
|
60
|
+
currentElem.style.boxShadow = boxShadow;
|
|
61
|
+
});
|
|
62
|
+
});
|
|
53
63
|
}
|
|
54
64
|
}, [isLoading]);
|
|
55
65
|
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
|
|
@@ -74,7 +84,14 @@ function DataTable({
|
|
|
74
84
|
"th",
|
|
75
85
|
{
|
|
76
86
|
key: header.id,
|
|
77
|
-
className: "h-12 px-4 [&:has([role=checkbox])]:pr-0 bg-white shadow-[0_-1.5px_0px_0px_#c9c9c9_inset] text-left"
|
|
87
|
+
className: "h-12 px-4 [&:has([role=checkbox])]:pr-0 bg-white shadow-[0_-1.5px_0px_0px_#c9c9c9_inset] text-left",
|
|
88
|
+
"data-header": header.id,
|
|
89
|
+
"data-fixed": getFixed(
|
|
90
|
+
header.column.columnDef.meta
|
|
91
|
+
),
|
|
92
|
+
style: styleColumn(
|
|
93
|
+
header.column.columnDef.meta
|
|
94
|
+
)
|
|
78
95
|
},
|
|
79
96
|
header.isPlaceholder ? null : flexRender(
|
|
80
97
|
header.column.columnDef.header,
|
|
@@ -91,7 +108,14 @@ function DataTable({
|
|
|
91
108
|
"td",
|
|
92
109
|
{
|
|
93
110
|
key: cell.id,
|
|
94
|
-
className: "p-4 py-0 h-10 [&:has([role=checkbox])]:pr-0 transition-colors bg-white shadow-[0_-0.5px_0px_0px_#c9c9c9_inset] text-left"
|
|
111
|
+
className: "p-4 py-0 h-10 [&:has([role=checkbox])]:pr-0 transition-colors bg-white shadow-[0_-0.5px_0px_0px_#c9c9c9_inset] text-left",
|
|
112
|
+
"data-column": cell.column.id,
|
|
113
|
+
"data-fixed": getFixed(
|
|
114
|
+
cell.column.columnDef.meta
|
|
115
|
+
),
|
|
116
|
+
style: styleColumn(
|
|
117
|
+
cell.column.columnDef.meta
|
|
118
|
+
)
|
|
95
119
|
},
|
|
96
120
|
flexRender(
|
|
97
121
|
cell.column.columnDef.cell,
|
|
@@ -87,6 +87,10 @@ function buildColumns({
|
|
|
87
87
|
return externalColumn.render;
|
|
88
88
|
}
|
|
89
89
|
return /* @__PURE__ */ React.createElement(Typography, { variant: "body-large-400", textColor: "text-grey-800" }, row.getValue(externalColumn.key));
|
|
90
|
+
},
|
|
91
|
+
meta: {
|
|
92
|
+
width: externalColumn.width,
|
|
93
|
+
fixed: externalColumn.fixed
|
|
90
94
|
}
|
|
91
95
|
}));
|
|
92
96
|
return mappedColumns;
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import * as AccordionPrimitive from '@radix-ui/react-accordion';
|
|
|
4
4
|
import { VariantProps } from 'class-variance-authority';
|
|
5
5
|
import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
|
|
6
6
|
import { Row as Row$1, Table, Column as Column$1 } from '@tanstack/react-table';
|
|
7
|
+
export { ColumnDef } from '@tanstack/react-table';
|
|
7
8
|
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
8
9
|
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
|
|
9
10
|
import { CustomStyles as CustomStyles$2 } from '@/components/Button';
|
|
@@ -348,6 +349,8 @@ interface Column<TData, TValue> {
|
|
|
348
349
|
key: string;
|
|
349
350
|
title?: (({ table, column }: ColumnTitle<TData, TValue>) => React.ReactNode) | React.ReactNode;
|
|
350
351
|
enableSelect?: boolean;
|
|
352
|
+
width?: number | string;
|
|
353
|
+
fixed?: string;
|
|
351
354
|
render?: (({ value, row }: ColumnRender<TData, TValue>) => React.ReactNode) | React.ReactNode;
|
|
352
355
|
onSort?: ({ table, column }: ColumnSort<TData, TValue>) => void;
|
|
353
356
|
checkedHeader?: ({ table, column }: CheckedHeader<TData, TValue>) => boolean;
|
|
@@ -356,8 +359,6 @@ interface Column<TData, TValue> {
|
|
|
356
359
|
onCheckedCellChange?: ({ row, value }: CheckedCellChange<TData>) => void;
|
|
357
360
|
}
|
|
358
361
|
interface DataTableProps<TData, TValue> {
|
|
359
|
-
columnFullSize?: string;
|
|
360
|
-
fixedColumns?: string[];
|
|
361
362
|
isLoading?: boolean;
|
|
362
363
|
columns: Column<TData, TValue>[];
|
|
363
364
|
data: TData[];
|
|
@@ -388,8 +389,9 @@ interface BuildCellSelect<TData, TValue> {
|
|
|
388
389
|
checkedCell: Column<TData, TValue>['checkedCell'];
|
|
389
390
|
onCheckedCellChange: Column<TData, TValue>['onCheckedCellChange'];
|
|
390
391
|
}
|
|
392
|
+
type Meta = Record<string, string | number>;
|
|
391
393
|
|
|
392
|
-
declare function DataTable<TData, TValue>({
|
|
394
|
+
declare function DataTable<TData, TValue>({ isLoading, columns, data, noResults, pagination, vwDiff, vhDiff, onIsSelected, }: DataTableProps<TData, TValue>): React$1.JSX.Element;
|
|
393
395
|
declare namespace DataTable {
|
|
394
396
|
var displayName: string;
|
|
395
397
|
}
|
|
@@ -733,4 +735,4 @@ declare const fonts: {
|
|
|
733
735
|
ibm: string[];
|
|
734
736
|
};
|
|
735
737
|
|
|
736
|
-
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, type BgColor, type BuildCellSelect, type BuildColumns, type BuildHeaderSelect, Button, type ButtonProps, CadastroFacil, type CadastroFacilProps, type CalloutNotificationProps, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, type CheckboxProps, type CheckedCell, type CheckedCellChange, type CheckedHeader, type CheckedHeaderChange, type Color, type ColorToken, type Column, type ColumnRender, type ColumnSort, type ColumnTitle, type CustomStyles$1 as CustomStyles, DataTable, type DataTableProps, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, type FillColor, type Fonts, type Header, type HeaderProps, type InlineNotificationProps, Layout, type LayoutProps, LogoLecom, LogoLecomBrand, type LogoLecomBrandProps, type LogoLecomProps, ModoTeste, type ModoTesteProps, Notification, type NotificationProps, Pagination, PaginationContent, PaginationEllipsis, PaginationFirst, PaginationIndex, PaginationItem, PaginationLast, PaginationNext, PaginationPrevious, type PaginationProps, Popover, PopoverContent, PopoverTrigger, type Row, Rpa, type RpaProps, ScrollArea, ScrollBar, type SideBarProps, Skeleton, Spin, type SpinProps, Switch, TOAST_REMOVE_DELAY, Tag, type TagProps, type TextColor, type ToastNotificationProps, type ToasterToast, Tooltip, TooltipArrow, TooltipContent, type TooltipContentProps, TooltipPortal, TooltipProvider, TooltipTrigger, Translations, TypeMessageNotification, Typography, type TypographyProps, type UsePaginationItem, accordionVariants, buttonVariants, colors, fonts, getPositionClass, initializeI18n, notificationVariants, reducer, tagVariants, toast, typographyVariants, useIsMobile, useNotificationToast, usePagination, useSidebar };
|
|
738
|
+
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, type BgColor, type BuildCellSelect, type BuildColumns, type BuildHeaderSelect, Button, type ButtonProps, CadastroFacil, type CadastroFacilProps, type CalloutNotificationProps, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, type CheckboxProps, type CheckedCell, type CheckedCellChange, type CheckedHeader, type CheckedHeaderChange, type Color, type ColorToken, type Column, type ColumnRender, type ColumnSort, type ColumnTitle, type CustomStyles$1 as CustomStyles, DataTable, type DataTableProps, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, type FillColor, type Fonts, type Header, type HeaderProps, type InlineNotificationProps, Layout, type LayoutProps, LogoLecom, LogoLecomBrand, type LogoLecomBrandProps, type LogoLecomProps, type Meta, ModoTeste, type ModoTesteProps, Notification, type NotificationProps, Pagination, PaginationContent, PaginationEllipsis, PaginationFirst, PaginationIndex, PaginationItem, PaginationLast, PaginationNext, PaginationPrevious, type PaginationProps, Popover, PopoverContent, PopoverTrigger, type Row, Rpa, type RpaProps, ScrollArea, ScrollBar, type SideBarProps, Skeleton, Spin, type SpinProps, Switch, TOAST_REMOVE_DELAY, Tag, type TagProps, type TextColor, type ToastNotificationProps, type ToasterToast, Tooltip, TooltipArrow, TooltipContent, type TooltipContentProps, TooltipPortal, TooltipProvider, TooltipTrigger, Translations, TypeMessageNotification, Typography, type TypographyProps, type UsePaginationItem, accordionVariants, buttonVariants, colors, fonts, getPositionClass, initializeI18n, notificationVariants, reducer, tagVariants, toast, typographyVariants, useIsMobile, useNotificationToast, usePagination, useSidebar };
|