lecom-ui 4.1.5 → 4.1.7

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
- console.log(
48
- isLoading,
49
- document.querySelector(
50
- `table#data-table tbody tr:nth-child(50) td:nth-child(2)`
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;
@@ -0,0 +1,42 @@
1
+ import * as React from 'react';
2
+ import { cn } from '../../lib/utils.js';
3
+ import * as RadioGroupPrimitive from '@radix-ui/react-radio-group';
4
+ import { Circle } from 'lucide-react';
5
+
6
+ const RadioGroup = React.forwardRef(({ className, disabled, ...props }, ref) => /* @__PURE__ */ React.createElement(
7
+ RadioGroupPrimitive.Root,
8
+ {
9
+ className: cn("grid gap-2", className),
10
+ disabled,
11
+ ...props,
12
+ ref
13
+ }
14
+ ));
15
+ RadioGroup.displayName = RadioGroupPrimitive.Root.displayName;
16
+ const RadioGroupItem = React.forwardRef(({ className, children, disabled, ...props }, ref) => {
17
+ const id = React.useId();
18
+ return /* @__PURE__ */ React.createElement("div", { className: "flex items-center space-x-2" }, /* @__PURE__ */ React.createElement(
19
+ RadioGroupPrimitive.Item,
20
+ {
21
+ ref,
22
+ className: cn(
23
+ "peer relative aspect-square h-5 w-5 rounded-full border-2 border-grey-400 transition-all hover:border-grey-500 active:border-grey-700 disabled:cursor-not-allowed disabled:border-grey-300 focus-visible:outline-none focus-visible:before:absolute focus-visible:before:-z-10 focus-visible:before:top-1/2 focus-visible:before:left-1/2 focus-visible:before:transform focus-visible:before:-translate-x-1/2 focus-visible:before:-translate-y-1/2 focus-visible:before:w-10 focus-visible:before:h-10 focus-visible:before:rounded-full focus-visible:before:bg-blue-100 data-[state=checked]:border-blue-600 data-[state=checked]:text-blue-600 data-[state=checked]:hover:border-blue-700 data-[state=checked]:hover:text-blue-700 data-[state=checked]:active:border-blue-800 data-[state=checked]:active:text-blue-800 data-[state=checked]:disabled:border-blue-400 data-[state=checked]:disabled:text-blue-400",
24
+ className
25
+ ),
26
+ disabled,
27
+ ...props,
28
+ id
29
+ },
30
+ /* @__PURE__ */ React.createElement(RadioGroupPrimitive.Indicator, { className: "flex items-center justify-center" }, /* @__PURE__ */ React.createElement(Circle, { className: "h-2.5 w-2.5 fill-current text-current" }))
31
+ ), /* @__PURE__ */ React.createElement(
32
+ "label",
33
+ {
34
+ htmlFor: id,
35
+ className: "body-medium-400 leading-none cursor-pointer peer-disabled:cursor-not-allowed peer-disabled:opacity-50 transition-opacity"
36
+ },
37
+ children
38
+ ));
39
+ });
40
+ RadioGroupItem.displayName = RadioGroupPrimitive.Item.displayName;
41
+
42
+ export { RadioGroup, RadioGroupItem };
package/dist/index.d.ts CHANGED
@@ -11,6 +11,7 @@ import { CustomStyles as CustomStyles$2 } from '@/components/Button';
11
11
  import * as PopoverPrimitive from '@radix-ui/react-popover';
12
12
  import * as SwitchPrimitives from '@radix-ui/react-switch';
13
13
  import * as TooltipPrimitive from '@radix-ui/react-tooltip';
14
+ import * as RadioGroupPrimitive from '@radix-ui/react-radio-group';
14
15
  import * as ScrollAreaPrimitive from '@radix-ui/react-scroll-area';
15
16
  import { InitOptions } from 'i18next';
16
17
  export { TFunction, default as i18n } from 'i18next';
@@ -349,6 +350,8 @@ interface Column<TData, TValue> {
349
350
  key: string;
350
351
  title?: (({ table, column }: ColumnTitle<TData, TValue>) => React.ReactNode) | React.ReactNode;
351
352
  enableSelect?: boolean;
353
+ width?: number | string;
354
+ fixed?: string;
352
355
  render?: (({ value, row }: ColumnRender<TData, TValue>) => React.ReactNode) | React.ReactNode;
353
356
  onSort?: ({ table, column }: ColumnSort<TData, TValue>) => void;
354
357
  checkedHeader?: ({ table, column }: CheckedHeader<TData, TValue>) => boolean;
@@ -357,8 +360,6 @@ interface Column<TData, TValue> {
357
360
  onCheckedCellChange?: ({ row, value }: CheckedCellChange<TData>) => void;
358
361
  }
359
362
  interface DataTableProps<TData, TValue> {
360
- columnFullSize?: string;
361
- fixedColumns?: string[];
362
363
  isLoading?: boolean;
363
364
  columns: Column<TData, TValue>[];
364
365
  data: TData[];
@@ -389,8 +390,9 @@ interface BuildCellSelect<TData, TValue> {
389
390
  checkedCell: Column<TData, TValue>['checkedCell'];
390
391
  onCheckedCellChange: Column<TData, TValue>['onCheckedCellChange'];
391
392
  }
393
+ type Meta = Record<string, string | number>;
392
394
 
393
- declare function DataTable<TData, TValue>({ columnFullSize, fixedColumns, isLoading, columns, data, noResults, pagination, vwDiff, vhDiff, onIsSelected, }: DataTableProps<TData, TValue>): React$1.JSX.Element;
395
+ declare function DataTable<TData, TValue>({ isLoading, columns, data, noResults, pagination, vwDiff, vhDiff, onIsSelected, }: DataTableProps<TData, TValue>): React$1.JSX.Element;
394
396
  declare namespace DataTable {
395
397
  var displayName: string;
396
398
  }
@@ -691,6 +693,9 @@ declare const Typography: {
691
693
  displayName: string;
692
694
  };
693
695
 
696
+ declare const RadioGroup: React$1.ForwardRefExoticComponent<Omit<RadioGroupPrimitive.RadioGroupProps & React$1.RefAttributes<HTMLDivElement>, "ref"> & React$1.RefAttributes<HTMLDivElement>>;
697
+ declare const RadioGroupItem: React$1.ForwardRefExoticComponent<Omit<RadioGroupPrimitive.RadioGroupItemProps & React$1.RefAttributes<HTMLButtonElement>, "ref"> & React$1.RefAttributes<HTMLButtonElement>>;
698
+
694
699
  declare const ScrollArea: React$1.ForwardRefExoticComponent<Omit<ScrollAreaPrimitive.ScrollAreaProps & React$1.RefAttributes<HTMLDivElement>, "ref"> & React$1.RefAttributes<HTMLDivElement>>;
695
700
  declare const ScrollBar: React$1.ForwardRefExoticComponent<Omit<ScrollAreaPrimitive.ScrollAreaScrollbarProps & React$1.RefAttributes<HTMLDivElement>, "ref"> & React$1.RefAttributes<HTMLDivElement>>;
696
701
 
@@ -734,4 +739,4 @@ declare const fonts: {
734
739
  ibm: string[];
735
740
  };
736
741
 
737
- 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 };
742
+ 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, RadioGroup, RadioGroupItem, 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 };
package/dist/index.js CHANGED
@@ -20,6 +20,7 @@ export { Switch } from './components/Switch/Switch.js';
20
20
  export { Tag, tagVariants } from './components/Tag/Tag.js';
21
21
  export { Tooltip, TooltipArrow, TooltipContent, TooltipPortal, TooltipProvider, TooltipTrigger } from './components/Tooltip/Tooltip.js';
22
22
  export { Typography, typographyVariants } from './components/Typography/Typography.js';
23
+ export { RadioGroup, RadioGroupItem } from './components/RadioGroup/RadioGroup.js';
23
24
  export { ScrollArea, ScrollBar } from './components/ScrollArea/ScrollArea.js';
24
25
  export { Spin } from './components/Spin/Spin.js';
25
26
  export { useSidebar } from './components/Sidebar/Sidebar.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lecom-ui",
3
- "version": "4.1.5",
3
+ "version": "4.1.7",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "module": "dist/index.js",