lecom-ui 4.8.1 → 4.8.3
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.
|
@@ -130,7 +130,7 @@ const Button = React.forwardRef(
|
|
|
130
130
|
customStyles,
|
|
131
131
|
isActive,
|
|
132
132
|
children,
|
|
133
|
-
|
|
133
|
+
isLoading,
|
|
134
134
|
...props
|
|
135
135
|
}, ref) => {
|
|
136
136
|
if (customStyles) {
|
|
@@ -146,7 +146,7 @@ const Button = React.forwardRef(
|
|
|
146
146
|
...props
|
|
147
147
|
},
|
|
148
148
|
children,
|
|
149
|
-
|
|
149
|
+
isLoading && /* @__PURE__ */ React.createElement(Spin, null)
|
|
150
150
|
);
|
|
151
151
|
}
|
|
152
152
|
const Comp = "button";
|
|
@@ -161,7 +161,7 @@ const Button = React.forwardRef(
|
|
|
161
161
|
...props
|
|
162
162
|
},
|
|
163
163
|
children,
|
|
164
|
-
|
|
164
|
+
isLoading && /* @__PURE__ */ React.createElement(Spin, null)
|
|
165
165
|
);
|
|
166
166
|
}
|
|
167
167
|
);
|
|
@@ -16,12 +16,13 @@ function DataTable({
|
|
|
16
16
|
vhDiff,
|
|
17
17
|
className,
|
|
18
18
|
noScroll,
|
|
19
|
+
size = "middle",
|
|
19
20
|
onIsSelected
|
|
20
21
|
}) {
|
|
21
22
|
const [sorting, setSorting] = React.useState([]);
|
|
22
23
|
const table = useReactTable({
|
|
23
24
|
data,
|
|
24
|
-
columns: buildColumns({ columns }),
|
|
25
|
+
columns: buildColumns({ columns, size }),
|
|
25
26
|
getCoreRowModel: getCoreRowModel(),
|
|
26
27
|
onSortingChange: setSorting,
|
|
27
28
|
getSortedRowModel: getSortedRowModel(),
|
|
@@ -99,7 +100,8 @@ function DataTable({
|
|
|
99
100
|
columns,
|
|
100
101
|
noResults,
|
|
101
102
|
onIsSelected,
|
|
102
|
-
isLoading
|
|
103
|
+
isLoading,
|
|
104
|
+
size
|
|
103
105
|
}
|
|
104
106
|
);
|
|
105
107
|
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
|
|
@@ -32,7 +32,8 @@ function buildCellSelect({
|
|
|
32
32
|
);
|
|
33
33
|
}
|
|
34
34
|
function buildColumns({
|
|
35
|
-
columns
|
|
35
|
+
columns,
|
|
36
|
+
size = "middle"
|
|
36
37
|
}) {
|
|
37
38
|
const mappedColumns = columns.map((externalColumn) => ({
|
|
38
39
|
accessorKey: externalColumn.key,
|
|
@@ -48,7 +49,7 @@ function buildColumns({
|
|
|
48
49
|
if (!externalColumn.title) {
|
|
49
50
|
return null;
|
|
50
51
|
}
|
|
51
|
-
const hasSort = !!externalColumn.onSort;
|
|
52
|
+
const hasSort = !!externalColumn.onSort || !!externalColumn.onSortClient;
|
|
52
53
|
const title = typeof externalColumn.title === "function" ? externalColumn.title({ table, column }) : externalColumn.title;
|
|
53
54
|
return /* @__PURE__ */ React.createElement(
|
|
54
55
|
"div",
|
|
@@ -62,7 +63,7 @@ function buildColumns({
|
|
|
62
63
|
typeof externalColumn.title === "string" ? /* @__PURE__ */ React.createElement(
|
|
63
64
|
Typography,
|
|
64
65
|
{
|
|
65
|
-
variant: "body-large-500",
|
|
66
|
+
variant: size === "small" ? "body-medium-500" : "body-large-500",
|
|
66
67
|
textColor: "text-grey-950",
|
|
67
68
|
className: "truncate",
|
|
68
69
|
title: externalColumn.title
|
|
@@ -98,7 +99,7 @@ function buildColumns({
|
|
|
98
99
|
return /* @__PURE__ */ React.createElement(
|
|
99
100
|
Typography,
|
|
100
101
|
{
|
|
101
|
-
variant: "body-large-400",
|
|
102
|
+
variant: size === "small" ? "body-medium-400" : "body-large-400",
|
|
102
103
|
textColor: "text-grey-800",
|
|
103
104
|
title: row.getValue(externalColumn.key)
|
|
104
105
|
},
|
|
@@ -109,6 +110,13 @@ function buildColumns({
|
|
|
109
110
|
width: externalColumn.width,
|
|
110
111
|
fixed: externalColumn.fixed,
|
|
111
112
|
truncate: !!externalColumn.truncate
|
|
113
|
+
},
|
|
114
|
+
sortingFn: (rowA, rowB, columnId) => {
|
|
115
|
+
if (externalColumn.onSortClient) {
|
|
116
|
+
return externalColumn.onSortClient({ rowA, rowB, columnId });
|
|
117
|
+
} else {
|
|
118
|
+
return 0;
|
|
119
|
+
}
|
|
112
120
|
}
|
|
113
121
|
}));
|
|
114
122
|
return mappedColumns;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { cn } from '../../lib/utils.js';
|
|
2
3
|
import { flexRender } from '@tanstack/react-table';
|
|
3
4
|
import { Skeleton } from '../Skeleton/Skeleton.js';
|
|
4
5
|
|
|
@@ -7,6 +8,7 @@ function Table({
|
|
|
7
8
|
isLoading,
|
|
8
9
|
columns,
|
|
9
10
|
noResults,
|
|
11
|
+
size = "middle",
|
|
10
12
|
onIsSelected
|
|
11
13
|
}) {
|
|
12
14
|
const styleColumn = (meta, elem) => {
|
|
@@ -38,10 +40,14 @@ function Table({
|
|
|
38
40
|
"th",
|
|
39
41
|
{
|
|
40
42
|
key: header.id,
|
|
41
|
-
className:
|
|
43
|
+
className: cn(
|
|
44
|
+
"h-12 px-4 [&:has([role=checkbox])]:pr-0 shadow-[0_-1.5px_0px_0px_#c9c9c9_inset] text-left",
|
|
45
|
+
size === "small" && "h-10"
|
|
46
|
+
),
|
|
42
47
|
"data-header": header.id,
|
|
43
48
|
"data-fixed": getFixed(header.column.columnDef.meta),
|
|
44
|
-
style: styleColumn(header.column.columnDef.meta, "th")
|
|
49
|
+
style: styleColumn(header.column.columnDef.meta, "th"),
|
|
50
|
+
onClick: header.column.getToggleSortingHandler()
|
|
45
51
|
},
|
|
46
52
|
header.isPlaceholder ? null : flexRender(
|
|
47
53
|
header.column.columnDef.header,
|
package/dist/index.d.ts
CHANGED
|
@@ -58,7 +58,7 @@ interface CustomStyles$1 {
|
|
|
58
58
|
interface ButtonProps extends Omit<React$1.ButtonHTMLAttributes<HTMLButtonElement>, 'color'>, VariantProps<typeof buttonVariants> {
|
|
59
59
|
customStyles?: CustomStyles$1;
|
|
60
60
|
isActive?: boolean;
|
|
61
|
-
|
|
61
|
+
isLoading?: boolean;
|
|
62
62
|
}
|
|
63
63
|
declare const Button: React$1.ForwardRefExoticComponent<ButtonProps & React$1.RefAttributes<HTMLButtonElement>>;
|
|
64
64
|
|
|
@@ -331,6 +331,11 @@ interface ColumnSort<TData, TValue> {
|
|
|
331
331
|
table: Table<TData>;
|
|
332
332
|
column: Column$1<TData, TValue>;
|
|
333
333
|
}
|
|
334
|
+
interface ColumnSortClient<TData> {
|
|
335
|
+
rowA: Row<TData>['row'];
|
|
336
|
+
rowB: Row<TData>['row'];
|
|
337
|
+
columnId: string;
|
|
338
|
+
}
|
|
334
339
|
type ColumnTitle<TData, TValue> = ColumnSort<TData, TValue>;
|
|
335
340
|
interface CheckedHeader<TData, TValue> {
|
|
336
341
|
table: Table<TData>;
|
|
@@ -357,6 +362,7 @@ interface Column<TData, TValue> {
|
|
|
357
362
|
truncate?: boolean;
|
|
358
363
|
render?: (({ value, row }: ColumnRender<TData, TValue>) => React.ReactNode) | React.ReactNode;
|
|
359
364
|
onSort?: ({ table, column }: ColumnSort<TData, TValue>) => void;
|
|
365
|
+
onSortClient?: ({ rowA, rowB, columnId }: ColumnSortClient<TData>) => number;
|
|
360
366
|
checkedHeader?: ({ table, column }: CheckedHeader<TData, TValue>) => boolean;
|
|
361
367
|
checkedCell?: ({ row }: CheckedCell<TData>) => boolean;
|
|
362
368
|
onCheckedHeaderChange?: ({ table, column, value, }: CheckedHeaderChange<TData, TValue>) => void;
|
|
@@ -372,6 +378,7 @@ interface DataTableProps<TData, TValue> {
|
|
|
372
378
|
vhDiff?: number;
|
|
373
379
|
className?: string;
|
|
374
380
|
noScroll?: boolean;
|
|
381
|
+
size?: 'small' | 'middle';
|
|
375
382
|
onIsSelected?: (row: Row$1<TData>) => boolean;
|
|
376
383
|
}
|
|
377
384
|
interface Row<TData> {
|
|
@@ -383,6 +390,7 @@ interface Header<TData, TValue> {
|
|
|
383
390
|
}
|
|
384
391
|
interface BuildColumns<TData, TValue> {
|
|
385
392
|
columns: Column<TData, TValue>[];
|
|
393
|
+
size?: 'small' | 'middle';
|
|
386
394
|
}
|
|
387
395
|
interface BuildHeaderSelect<TData, TValue> {
|
|
388
396
|
table: Table<TData>;
|
|
@@ -401,10 +409,11 @@ interface TableProps<TData, TValue> {
|
|
|
401
409
|
isLoading?: boolean;
|
|
402
410
|
columns: Column<TData, TValue>[];
|
|
403
411
|
noResults?: React.ReactNode;
|
|
412
|
+
size?: 'small' | 'middle';
|
|
404
413
|
onIsSelected?: (row: Row$1<TData>) => boolean;
|
|
405
414
|
}
|
|
406
415
|
|
|
407
|
-
declare function DataTable<TData, TValue>({ isLoading, columns, data, noResults, pagination, vwDiff, vhDiff, className, noScroll, onIsSelected, }: DataTableProps<TData, TValue>): React$1.JSX.Element;
|
|
416
|
+
declare function DataTable<TData, TValue>({ isLoading, columns, data, noResults, pagination, vwDiff, vhDiff, className, noScroll, size, onIsSelected, }: DataTableProps<TData, TValue>): React$1.JSX.Element;
|
|
408
417
|
declare namespace DataTable {
|
|
409
418
|
var displayName: string;
|
|
410
419
|
}
|
|
@@ -560,9 +569,9 @@ interface HeaderProps extends React$1.HTMLAttributes<HTMLElement>, VariantProps<
|
|
|
560
569
|
}
|
|
561
570
|
|
|
562
571
|
declare const inputVariants: (props?: ({
|
|
563
|
-
variant?: "
|
|
564
|
-
size?: "
|
|
565
|
-
radius?: "
|
|
572
|
+
variant?: "default" | "filled" | "borderless" | null | undefined;
|
|
573
|
+
size?: "default" | "small" | "large" | null | undefined;
|
|
574
|
+
radius?: "default" | "small" | "large" | null | undefined;
|
|
566
575
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
567
576
|
interface InputProps extends Omit<React$1.InputHTMLAttributes<HTMLInputElement>, 'size' | 'sufix' | 'prefix'>, VariantProps<typeof inputVariants> {
|
|
568
577
|
sufix?: React$1.ReactNode;
|
|
@@ -819,4 +828,4 @@ declare const fonts: {
|
|
|
819
828
|
};
|
|
820
829
|
|
|
821
830
|
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, Button, CadastroFacil, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, DataTable, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogScroll, DialogTitle, DialogTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, ErrorEmptyDisplay, Input, Layout, LogoLecom, LogoLecomBrand, ModoTeste, Notification, Pagination, PaginationContent, PaginationEllipsis, PaginationFirst, PaginationIndex, PaginationItem, PaginationLast, PaginationNext, PaginationPrevious, Popover, PopoverContent, PopoverTrigger, RadioGroup, RadioGroupItem, Rpa, ScrollArea, ScrollBar, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Skeleton, Spin, Switch, TOAST_REMOVE_DELAY, Tag, Tooltip, TooltipArrow, TooltipContent, TooltipPortal, TooltipProvider, TooltipTrigger, Translations, TypeMessageNotification, Typography, Upload, accordionVariants, buttonVariants, colors, fonts, getPositionClass, initializeI18n, inputVariants, notificationVariants, reducer, tagVariants, toast, typographyVariants, useIsMobile, useNotificationToast, usePagination, useSidebar };
|
|
822
|
-
export type { BgColor, BuildCellSelect, BuildColumns, BuildHeaderSelect, ButtonProps, CadastroFacilProps, CalloutNotificationProps, CheckboxProps, CheckedCell, CheckedCellChange, CheckedHeader, CheckedHeaderChange, Color, ColorToken, Column, ColumnRender, ColumnSort, ColumnTitle, CustomStyles$1 as CustomStyles, DataTableProps, ErrorEmptyDisplayProps, File, FillColor, Fonts, Header, HeaderProps, InlineNotificationProps, InputProps, LayoutProps, LogoLecomBrandProps, LogoLecomProps, Meta, ModoTesteProps, NotificationProps, PaginationProps, Row, RpaProps, SideBarProps, SpinProps, TableProps, TagProps, TextColor, ToastNotificationProps, ToasterToast, TooltipContentProps, TypographyProps, UploadProps, UsePaginationItem };
|
|
831
|
+
export type { BgColor, BuildCellSelect, BuildColumns, BuildHeaderSelect, ButtonProps, CadastroFacilProps, CalloutNotificationProps, CheckboxProps, CheckedCell, CheckedCellChange, CheckedHeader, CheckedHeaderChange, Color, ColorToken, Column, ColumnRender, ColumnSort, ColumnSortClient, ColumnTitle, CustomStyles$1 as CustomStyles, DataTableProps, ErrorEmptyDisplayProps, File, FillColor, Fonts, Header, HeaderProps, InlineNotificationProps, InputProps, LayoutProps, LogoLecomBrandProps, LogoLecomProps, Meta, ModoTesteProps, NotificationProps, PaginationProps, Row, RpaProps, SideBarProps, SpinProps, TableProps, TagProps, TextColor, ToastNotificationProps, ToasterToast, TooltipContentProps, TypographyProps, UploadProps, UsePaginationItem };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lecom-ui",
|
|
3
|
-
"version": "4.8.
|
|
3
|
+
"version": "4.8.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@radix-ui/react-slot": "^1.1.1",
|
|
37
37
|
"@radix-ui/react-switch": "^1.1.2",
|
|
38
38
|
"@radix-ui/react-tooltip": "^1.1.6",
|
|
39
|
-
"@tanstack/react-table": "^8.
|
|
39
|
+
"@tanstack/react-table": "^8.21.2",
|
|
40
40
|
"class-variance-authority": "^0.7.1",
|
|
41
41
|
"clsx": "^2.1.1",
|
|
42
42
|
"hex-color-opacity": "^0.4.2",
|