lecom-ui 5.2.71 → 5.2.72

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.
Files changed (82) hide show
  1. package/dist/components/Combobox/Combobox.js +5 -19
  2. package/dist/components/CustomDivider/CustomDivider.js +18 -36
  3. package/dist/components/DataTable/DataTable.utils.js +1 -5
  4. package/dist/components/DataTable/Table.js +40 -60
  5. package/dist/components/Sheet/Sheet.js +1 -31
  6. package/dist/components/Steps/{StepsTimeline.js → Steps.js} +1 -0
  7. package/dist/components/Switch/Switch.js +20 -5
  8. package/dist/components/TagInput/TagInput.js +55 -58
  9. package/dist/index.d.ts +47 -93
  10. package/dist/index.js +2 -4
  11. package/dist/style.min.css +1 -1
  12. package/package.json +4 -3
  13. package/dist/badge.js +0 -26
  14. package/dist/button-dropdown.js +0 -117
  15. package/dist/button.js +0 -104
  16. package/dist/calendar.js +0 -62
  17. package/dist/card.js +0 -56
  18. package/dist/checkbox.js +0 -55
  19. package/dist/collapse.js +0 -60
  20. package/dist/collapsible.js +0 -7
  21. package/dist/command.js +0 -107
  22. package/dist/components/Collapse/Collapse.js +0 -94
  23. package/dist/components/DataTable/useOptimizedTable.js +0 -75
  24. package/dist/data-table/data-table.js +0 -490
  25. package/dist/date-picker.js +0 -92
  26. package/dist/dialog.js +0 -95
  27. package/dist/dropdown-menu.js +0 -138
  28. package/dist/fonts/Montserrat-Bold.otf +0 -0
  29. package/dist/fonts/Montserrat-Medium.otf +0 -0
  30. package/dist/fonts/Montserrat-Regular.otf +0 -0
  31. package/dist/fonts/Roboto-Bold.otf +0 -0
  32. package/dist/fonts/Roboto-Light.otf +0 -0
  33. package/dist/fonts/Roboto-Medium.otf +0 -0
  34. package/dist/fonts/Roboto-Regular.otf +0 -0
  35. package/dist/form.js +0 -102
  36. package/dist/header.js +0 -90
  37. package/dist/hook/useDebounce.js +0 -16
  38. package/dist/icon-handler.js +0 -72
  39. package/dist/icons/brandModules.js +0 -27
  40. package/dist/icons/companyLogo.js +0 -61
  41. package/dist/icons/createUseAuxiliary.js +0 -107
  42. package/dist/icons/footerInfo.js +0 -25
  43. package/dist/icons/logo_lecom.svg.js +0 -3
  44. package/dist/icons/newUpdate.js +0 -23
  45. package/dist/icons/robertyRPA.js +0 -30
  46. package/dist/ilustrations/access_denied.js +0 -252
  47. package/dist/ilustrations/page_not_found.js +0 -188
  48. package/dist/input.js +0 -42
  49. package/dist/label.js +0 -20
  50. package/dist/modal.js +0 -27
  51. package/dist/pagination.js +0 -474
  52. package/dist/plugin/extend.ts +0 -78
  53. package/dist/plugin/fontFaces.ts +0 -172
  54. package/dist/plugin/general.ts +0 -12
  55. package/dist/plugin/pluginDev.js +0 -5
  56. package/dist/plugin/pluginNext.js +0 -5
  57. package/dist/plugin/pluginVite.js +0 -5
  58. package/dist/plugin/template.ts +0 -31
  59. package/dist/plugin/typographies.ts +0 -152
  60. package/dist/plugin/varsTheme.ts +0 -79
  61. package/dist/plugin.cjs +0 -298
  62. package/dist/popover.js +0 -24
  63. package/dist/radio-group.js +0 -74
  64. package/dist/range-picker.js +0 -99
  65. package/dist/scroll-area.js +0 -37
  66. package/dist/search-bar.js +0 -151
  67. package/dist/select.js +0 -156
  68. package/dist/separator.js +0 -24
  69. package/dist/sheet.js +0 -106
  70. package/dist/sidebar.js +0 -188
  71. package/dist/skeleton.js +0 -17
  72. package/dist/slider.js +0 -23
  73. package/dist/status-screen.js +0 -71
  74. package/dist/switch.js +0 -27
  75. package/dist/table.js +0 -83
  76. package/dist/tabs.js +0 -44
  77. package/dist/tag.js +0 -33
  78. package/dist/textarea.js +0 -22
  79. package/dist/toast.js +0 -105
  80. package/dist/toaster.js +0 -23
  81. package/dist/tooltip.js +0 -133
  82. package/dist/use-toast.js +0 -121
@@ -1,10 +1,10 @@
1
1
  import * as React from 'react';
2
+ import { ChevronUpIcon, ChevronDownIcon } from 'lucide-react';
3
+ import { cn } from '../../lib/utils.js';
2
4
  import { Button } from '../Button/Button.js';
3
5
  import { Command, CommandInput, CommandList, CommandEmpty, CommandGroup, CommandItem } from '../Command/Command.js';
4
6
  import { Popover, PopoverTrigger, PopoverContent } from '../Popover/Popover.js';
5
7
  import { Typography } from '../Typography/Typography.js';
6
- import { cn } from '../../lib/utils.js';
7
- import { ChevronUpIcon, ChevronDownIcon } from 'lucide-react';
8
8
 
9
9
  function Combobox({
10
10
  options,
@@ -65,26 +65,12 @@ function Combobox({
65
65
  {
66
66
  className: cn(
67
67
  value ? "text-black" : "text-gray-400",
68
- "font-normal",
69
- "truncate",
70
- "max-w-[calc(100%-2.5rem)]"
68
+ "font-normal truncate max-w-[calc(100%-2.5rem)]"
71
69
  )
72
70
  },
73
71
  /* @__PURE__ */ React.createElement(Typography, { variant: "body-medium-400" }, selectedLabel)
74
72
  ),
75
- open ? /* @__PURE__ */ React.createElement(
76
- ChevronUpIcon,
77
- {
78
- className: "ml-2 h-4 w-4 shrink-0 text-gray-400",
79
- color: "black"
80
- }
81
- ) : /* @__PURE__ */ React.createElement(
82
- ChevronDownIcon,
83
- {
84
- className: "ml-2 h-4 w-4 shrink-0 text-gray-400",
85
- color: "black"
86
- }
87
- )
73
+ open ? /* @__PURE__ */ React.createElement(ChevronUpIcon, { className: "ml-2 h-4 w-4 shrink-0 text-gray-400" }) : /* @__PURE__ */ React.createElement(ChevronDownIcon, { className: "ml-2 h-4 w-4 shrink-0 text-gray-400" })
88
74
  )), /* @__PURE__ */ React.createElement(PopoverContent, { className: "w-[var(--radix-popover-trigger-width)] p-0" }, /* @__PURE__ */ React.createElement(Command, null, /* @__PURE__ */ React.createElement(
89
75
  CommandInput,
90
76
  {
@@ -93,7 +79,7 @@ function Combobox({
93
79
  onValueChange: setSearch
94
80
  }
95
81
  ), /* @__PURE__ */ React.createElement(CommandList, null, /* @__PURE__ */ React.createElement(CommandEmpty, null, notFoundContent), filteredOptions.map(
96
- (item, idx) => "options" in item ? /* @__PURE__ */ React.createElement(CommandGroup, { key: item.label + idx, heading: item.label }, item.options.map((opt) => /* @__PURE__ */ React.createElement(
82
+ (item, idx) => "options" in item ? /* @__PURE__ */ React.createElement(CommandGroup, { key: `${item.label}-${idx}`, heading: item.label }, item.options.map((opt) => /* @__PURE__ */ React.createElement(
97
83
  CommandItem,
98
84
  {
99
85
  key: opt.value,
@@ -26,10 +26,9 @@ function DividerLine({
26
26
  "div",
27
27
  {
28
28
  className: cn(
29
- "w-full",
29
+ "w-full border-t",
30
30
  dashed ? "border-dashed" : "border-solid",
31
- plain ? "border-gray-200" : "border-gray-300",
32
- "border-t"
31
+ plain ? "border-gray-200" : "border-gray-300"
33
32
  )
34
33
  }
35
34
  )
@@ -108,7 +107,14 @@ function CustomDivider({
108
107
  style,
109
108
  children
110
109
  }) {
111
- if (lineOnly) {
110
+ const formContext = useFormContext();
111
+ const controlToUse = control ?? formContext?.control;
112
+ const justifyMap = {
113
+ left: "justify-start",
114
+ center: "justify-center",
115
+ right: "justify-end"
116
+ };
117
+ if (lineOnly && !children) {
112
118
  return /* @__PURE__ */ React.createElement(
113
119
  DividerLine,
114
120
  {
@@ -121,23 +127,7 @@ function CustomDivider({
121
127
  }
122
128
  );
123
129
  }
124
- const dividerLineProps = {
125
- dashed,
126
- plain,
127
- isGroupDivider,
128
- isActive,
129
- className,
130
- style
131
- };
132
- if (lineOnly && children == null) {
133
- return /* @__PURE__ */ React.createElement(DividerLine, { ...dividerLineProps });
134
- }
135
- if (children != null) {
136
- const justifyMap2 = {
137
- left: "justify-start",
138
- center: "justify-center",
139
- right: "justify-end"
140
- };
130
+ if (children) {
141
131
  return /* @__PURE__ */ React.createElement(
142
132
  "div",
143
133
  {
@@ -145,7 +135,7 @@ function CustomDivider({
145
135
  "relative w-full flex items-center",
146
136
  isGroupDivider ? "my-4" : "my-2",
147
137
  isActive ? "opacity-100" : "opacity-50",
148
- justifyMap2[orientation],
138
+ justifyMap[orientation],
149
139
  className
150
140
  ),
151
141
  style
@@ -154,10 +144,9 @@ function CustomDivider({
154
144
  "div",
155
145
  {
156
146
  className: cn(
157
- "absolute inset-x-0",
147
+ "absolute inset-x-0 border-t",
158
148
  dashed ? "border-dashed" : "border-solid",
159
- plain ? "border-gray-200" : "border-gray-300",
160
- "border-t"
149
+ plain ? "border-gray-200" : "border-gray-300"
161
150
  )
162
151
  }
163
152
  ),
@@ -166,16 +155,9 @@ function CustomDivider({
166
155
  }
167
156
  if (!name) {
168
157
  throw new Error(
169
- "CustomDivider: prop `name` is required when `lineOnly` is false."
158
+ "CustomDivider: prop `name` \xE9 obrigat\xF3ria se `lineOnly` for false."
170
159
  );
171
160
  }
172
- const formContext = useFormContext();
173
- const controlToUse = control ?? formContext.control;
174
- const justifyMap = {
175
- left: "justify-start",
176
- center: "justify-center",
177
- right: "justify-end"
178
- };
179
161
  return /* @__PURE__ */ React.createElement(
180
162
  "div",
181
163
  {
@@ -192,10 +174,9 @@ function CustomDivider({
192
174
  "div",
193
175
  {
194
176
  className: cn(
195
- "absolute inset-x-0",
177
+ "absolute inset-x-0 border-t",
196
178
  dashed ? "border-dashed" : "border-solid",
197
- plain ? "border-gray-200" : "border-gray-300",
198
- "border-t"
179
+ plain ? "border-gray-200" : "border-gray-300"
199
180
  )
200
181
  }
201
182
  ),
@@ -221,5 +202,6 @@ function CustomDivider({
221
202
  )
222
203
  );
223
204
  }
205
+ CustomDivider.displayName = "CustomDivider";
224
206
 
225
207
  export { CustomDivider };
@@ -114,11 +114,7 @@ function buildColumns({
114
114
  fixed: externalColumn.fixed,
115
115
  truncate: !!externalColumn.truncate,
116
116
  headerClassName: externalColumn.headerClassName,
117
- headerStyle: externalColumn.headerStyle,
118
- cellClassName: externalColumn.cellClassName,
119
- cellStyle: externalColumn.cellStyle,
120
- cellProps: externalColumn.cellProps,
121
- align: externalColumn.align
117
+ headerStyle: externalColumn.headerStyle
122
118
  },
123
119
  sortingFn: (rowA, rowB, columnId) => {
124
120
  if (externalColumn.onSortClient) {
@@ -13,35 +13,25 @@ function Table({
13
13
  onIsSelected
14
14
  }) {
15
15
  const styleColumn = (meta, elem) => {
16
- if (!meta) return void 0;
17
- let style = {};
18
16
  if (elem === "td" && meta.truncate) {
19
- style = {
20
- ...style,
17
+ return {
21
18
  width: meta.width,
22
19
  overflow: "hidden",
23
20
  maxWidth: "0",
24
21
  textOverflow: "ellipsis",
25
- whiteSpace: "nowrap",
26
- ...typeof meta.cellStyle === "object" && meta.cellStyle !== null ? meta.cellStyle : {}
27
- };
28
- } else {
29
- style = {
30
- ...style,
31
- width: meta.width,
32
- ...elem === "td" ? typeof meta.cellStyle === "object" && meta.cellStyle !== null ? meta.cellStyle : {} : typeof meta.headerStyle === "object" && meta.headerStyle !== null ? meta.headerStyle : {}
22
+ whiteSpace: "nowrap"
33
23
  };
34
24
  }
35
- if (meta.align)
36
- style.textAlign = meta.align;
37
- return style;
25
+ return {
26
+ width: meta.width
27
+ };
38
28
  };
39
- const getFixed = (meta) => meta?.fixed;
29
+ const getFixed = (meta) => meta.fixed;
40
30
  if (isLoading) {
41
31
  if (skeleton) {
42
32
  return skeleton;
43
33
  }
44
- const arrSkeleton = Array.from({ length: 15 }, (_, i) => i + 1);
34
+ const arrSkeleton = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15];
45
35
  return /* @__PURE__ */ React.createElement("div", { className: "flex flex-col gap-4" }, arrSkeleton.map((id) => /* @__PURE__ */ React.createElement(
46
36
  Skeleton,
47
37
  {
@@ -50,55 +40,45 @@ function Table({
50
40
  }
51
41
  )));
52
42
  }
53
- return /* @__PURE__ */ React.createElement("table", { id: "data-table", className: "w-full" }, /* @__PURE__ */ React.createElement("thead", { className: "sticky top-0 z-10 bg-white" }, table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ React.createElement("tr", { key: headerGroup.id }, headerGroup.headers.map((header) => {
54
- const meta = header.column.columnDef.meta || {};
55
- return /* @__PURE__ */ React.createElement(
56
- "th",
57
- {
58
- key: header.id,
59
- className: cn(
60
- "h-12 px-4 [&:has([role=checkbox])]:pr-0 shadow-[0_-1.5px_0px_0px_#c9c9c9_inset]",
61
- size === "small" && "h-10",
62
- meta.headerClassName,
63
- meta.align && `text-${meta.align}`
64
- ),
65
- "data-header": header.id,
66
- "data-fixed": getFixed(meta),
67
- style: styleColumn(meta, "th"),
68
- onClick: header.column.getToggleSortingHandler(),
69
- ...typeof meta.headerProps === "object" && meta.headerProps !== null ? meta.headerProps : {}
70
- },
71
- header.isPlaceholder ? null : flexRender(
72
- header.column.columnDef.header,
73
- header.getContext()
74
- )
75
- );
76
- })))), /* @__PURE__ */ React.createElement("tbody", { className: "[&_tr:last-child]:border-0 [&_tr:last-child_td]:shadow-none" }, table.getRowModel().rows?.length ? table.getRowModel().rows.map((row) => /* @__PURE__ */ React.createElement(
43
+ return /* @__PURE__ */ React.createElement("table", { id: "data-table", className: "w-full" }, /* @__PURE__ */ React.createElement("thead", { className: "sticky top-0 z-10 bg-white" }, table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ React.createElement("tr", { key: headerGroup.id }, headerGroup.headers.map((header) => /* @__PURE__ */ React.createElement(
44
+ "th",
45
+ {
46
+ key: header.id,
47
+ className: cn(
48
+ "h-12 px-4 [&:has([role=checkbox])]:pr-0 shadow-[0_-1.5px_0px_0px_#c9c9c9_inset] text-left",
49
+ size === "small" && "h-10",
50
+ header.column.columnDef.meta?.headerClassName
51
+ ),
52
+ "data-header": header.id,
53
+ "data-fixed": getFixed(header.column.columnDef.meta),
54
+ style: styleColumn(
55
+ header.column.columnDef.meta,
56
+ "th"
57
+ ),
58
+ onClick: header.column.getToggleSortingHandler()
59
+ },
60
+ header.isPlaceholder ? null : flexRender(
61
+ header.column.columnDef.header,
62
+ header.getContext()
63
+ )
64
+ ))))), /* @__PURE__ */ React.createElement("tbody", { className: "[&_tr:last-child]:border-0 [&_tr:last-child_td]:shadow-none" }, table.getRowModel().rows?.length ? table.getRowModel().rows.map((row) => /* @__PURE__ */ React.createElement(
77
65
  "tr",
78
66
  {
79
67
  key: row.id,
80
68
  "data-state": onIsSelected?.(row) ? "selected" : "",
81
69
  className: "[&_td]:hover:bg-grey-100 [&_td]:data-[state=selected]:bg-grey-100"
82
70
  },
83
- row.getVisibleCells().map((cell) => {
84
- const meta = cell.column.columnDef.meta || {};
85
- return /* @__PURE__ */ React.createElement(
86
- "td",
87
- {
88
- key: cell.id,
89
- className: cn(
90
- "p-4 py-0 h-10 [&:has([role=checkbox])]:pr-0 transition-colors shadow-[0_-0.5px_0px_0px_#c9c9c9_inset]",
91
- meta.cellClassName,
92
- meta.align && `text-${meta.align}`
93
- ),
94
- "data-column": cell.column.id,
95
- "data-fixed": getFixed(meta),
96
- style: styleColumn(meta, "td"),
97
- ...typeof meta.cellProps === "object" && meta.cellProps !== null ? meta.cellProps : {}
98
- },
99
- flexRender(cell.column.columnDef.cell, cell.getContext())
100
- );
101
- })
71
+ row.getVisibleCells().map((cell) => /* @__PURE__ */ React.createElement(
72
+ "td",
73
+ {
74
+ key: cell.id,
75
+ className: "p-4 py-0 h-10 [&:has([role=checkbox])]:pr-0 transition-colors shadow-[0_-0.5px_0px_0px_#c9c9c9_inset] text-left",
76
+ "data-column": cell.column.id,
77
+ "data-fixed": getFixed(cell.column.columnDef.meta),
78
+ style: styleColumn(cell.column.columnDef.meta, "td")
79
+ },
80
+ flexRender(cell.column.columnDef.cell, cell.getContext())
81
+ ))
102
82
  )) : /* @__PURE__ */ React.createElement("tr", { className: "border-b-[0.5px] [&_td]:hover:bg-grey-100 [&_td]:data-[state=selected]:bg-grey-100" }, /* @__PURE__ */ React.createElement(
103
83
  "td",
104
84
  {
@@ -5,8 +5,6 @@ import { cva } from 'class-variance-authority';
5
5
  import { X } from 'lucide-react';
6
6
 
7
7
  const Sheet = SheetPrimitive.Root;
8
- const SheetTrigger = SheetPrimitive.Trigger;
9
- const SheetClose = SheetPrimitive.Close;
10
8
  const SheetPortal = SheetPrimitive.Portal;
11
9
  const SheetOverlay = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React.createElement(
12
10
  SheetPrimitive.Overlay,
@@ -48,34 +46,6 @@ const SheetContent = React.forwardRef(({ side = "right", className, children, ..
48
46
  /* @__PURE__ */ React.createElement(SheetPrimitive.Close, { className: "absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary" }, /* @__PURE__ */ React.createElement(X, { className: "h-4 w-4" }), /* @__PURE__ */ React.createElement("span", { className: "sr-only" }, "Close"))
49
47
  )));
50
48
  SheetContent.displayName = SheetPrimitive.Content.displayName;
51
- const SheetHeader = ({
52
- className,
53
- ...props
54
- }) => /* @__PURE__ */ React.createElement(
55
- "div",
56
- {
57
- className: cn(
58
- "flex flex-col space-y-2 text-center sm:text-left",
59
- className
60
- ),
61
- ...props
62
- }
63
- );
64
- SheetHeader.displayName = "SheetHeader";
65
- const SheetFooter = ({
66
- className,
67
- ...props
68
- }) => /* @__PURE__ */ React.createElement(
69
- "div",
70
- {
71
- className: cn(
72
- "flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
73
- className
74
- ),
75
- ...props
76
- }
77
- );
78
- SheetFooter.displayName = "SheetFooter";
79
49
  const SheetTitle = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React.createElement(
80
50
  SheetPrimitive.Title,
81
51
  {
@@ -95,4 +65,4 @@ const SheetDescription = React.forwardRef(({ className, ...props }, ref) => /* @
95
65
  ));
96
66
  SheetDescription.displayName = SheetPrimitive.Description.displayName;
97
67
 
98
- export { Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetOverlay, SheetPortal, SheetTitle, SheetTrigger };
68
+ export { Sheet, SheetContent, SheetDescription, SheetOverlay, SheetPortal, SheetTitle };
@@ -97,5 +97,6 @@ const Steps = ({
97
97
  ));
98
98
  }));
99
99
  };
100
+ Steps.displayName = "Steps";
100
101
 
101
102
  export { Steps };
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
- import { cn } from '../../lib/utils.js';
3
2
  import * as SwitchPrimitives from '@radix-ui/react-switch';
3
+ import { cn } from '../../lib/utils.js';
4
4
 
5
5
  const Spinner = () => /* @__PURE__ */ React.createElement("svg", { className: "animate-spin h-4 w-4 text-blue-600", viewBox: "0 0 24 24" }, /* @__PURE__ */ React.createElement(
6
6
  "circle",
@@ -24,19 +24,34 @@ const Spinner = () => /* @__PURE__ */ React.createElement("svg", { className: "a
24
24
  const Switch = React.forwardRef(({ className, loading = false, disabled, ...props }, ref) => /* @__PURE__ */ React.createElement(
25
25
  SwitchPrimitives.Root,
26
26
  {
27
+ ref,
28
+ disabled: disabled || loading,
27
29
  className: cn(
28
- "peer flex items-center shrink-0 h-6 w-12 p-[2px] group rounded-full cursor-pointer bg-transparent focus:outline-none transition-colors data-[state=unchecked]:border-2 data-[state=unchecked]:border-grey-400 data-[state=unchecked]:hover:border-grey-500 data-[state=unchecked]:active:border-grey-700 data-[state=unchecked]:disabled:border-grey-300 data-[state=checked]:bg-blue-600 data-[state=checked]:hover:bg-blue-700 data-[state=checked]:active:bg-blue-800 data-[state=checked]:disabled:bg-blue-200 disabled:cursor-not-allowed",
30
+ "peer flex items-center shrink-0 h-6 w-12 p-[2px] group rounded-full cursor-pointer bg-transparent focus:outline-none transition-colors",
31
+ "data-[state=unchecked]:border-2 data-[state=unchecked]:border-grey-400",
32
+ "data-[state=unchecked]:hover:border-grey-500 data-[state=unchecked]:active:border-grey-700",
33
+ "data-[state=unchecked]:disabled:border-grey-300",
34
+ "data-[state=checked]:bg-blue-600 data-[state=checked]:hover:bg-blue-700",
35
+ "data-[state=checked]:active:bg-blue-800 data-[state=checked]:disabled:bg-blue-200",
36
+ "disabled:cursor-not-allowed",
29
37
  className
30
38
  ),
31
- ref,
32
- disabled: disabled || loading,
33
39
  ...props
34
40
  },
35
41
  /* @__PURE__ */ React.createElement(
36
42
  SwitchPrimitives.Thumb,
37
43
  {
38
44
  className: cn(
39
- "pointer-events-none rounded-full shadow-sm transition-all h-4 w-4 data-[state=unchecked]:bg-grey-400 data-[state=unchecked]:translate-x-1 group-hover:data-[state=unchecked]:bg-grey-500 group-focus:ring-8 group-focus:ring-blue-200 group-focus:ring-opacity-50 group-active:group-enabled:h-5 group-active:group-enabled:w-5 group-active:data-[state=unchecked]:bg-grey-700 group-active:group-enabled:data-[state=unchecked]:translate-x-[-2px] group-disabled:data-[state=unchecked]:bg-grey-300 group-disabled:data-[state=unchecked]:bg-opacity-65 data-[state=checked]:bg-white data-[state=checked]:translate-x-6 flex items-center justify-center"
45
+ "pointer-events-none rounded-full shadow-sm transition-all h-4 w-4",
46
+ "data-[state=unchecked]:bg-grey-400 data-[state=unchecked]:translate-x-1",
47
+ "group-hover:data-[state=unchecked]:bg-grey-500",
48
+ "group-focus:ring-8 group-focus:ring-blue-200 group-focus:ring-opacity-50",
49
+ "group-active:group-enabled:h-5 group-active:group-enabled:w-5",
50
+ "group-active:data-[state=unchecked]:bg-grey-700",
51
+ "group-active:group-enabled:data-[state=unchecked]:translate-x-[-2px]",
52
+ "group-disabled:data-[state=unchecked]:bg-grey-300 group-disabled:data-[state=unchecked]:bg-opacity-65",
53
+ "data-[state=checked]:bg-white data-[state=checked]:translate-x-6",
54
+ "flex items-center justify-center"
40
55
  )
41
56
  },
42
57
  loading && /* @__PURE__ */ React.createElement(Spinner, null)
@@ -1,11 +1,11 @@
1
1
  import * as React from 'react';
2
- import { cn } from '../../lib/utils.js';
3
2
  import { X } from 'lucide-react';
4
- import { inputVariants } from '../Input/Input.js';
3
+ import { cn } from '../../lib/utils.js';
5
4
  import { Tag } from '../Tag/Tag.js';
5
+ import { textareaVariants } from '../Textarea/Textarea.js';
6
6
  import { Typography } from '../Typography/Typography.js';
7
7
 
8
- const TagInput = ({
8
+ function TagInput({
9
9
  value,
10
10
  onRemove,
11
11
  placeholder = "Nenhum item selecionado",
@@ -16,71 +16,67 @@ const TagInput = ({
16
16
  variant = "default",
17
17
  radius = "default",
18
18
  ...props
19
- }) => {
20
- const containerRef = React.useRef(null);
21
- const [visibleCount, setVisibleCount] = React.useState(value.length);
19
+ }) {
20
+ const ref = React.useRef(null);
21
+ const [maxVisibleCount, setMaxVisibleCount] = React.useState(
22
+ null
23
+ );
22
24
  const [hiddenCount, setHiddenCount] = React.useState(0);
23
- const tagsToShow = visibleCount === 0 && value.length > 0 ? value : value.slice(0, visibleCount);
24
- React.useEffect(() => {
25
- setVisibleCount(value.length);
26
- setHiddenCount(0);
27
- }, [value.length]);
25
+ const calculateMaxVisible = React.useCallback(() => {
26
+ const container = ref.current;
27
+ if (!container) return;
28
+ const children = Array.from(container.children).filter(
29
+ (el) => el.dataset.tag === "true"
30
+ );
31
+ const lines = [];
32
+ children.forEach((c) => {
33
+ const t = c.offsetTop;
34
+ if (!lines.includes(t)) lines.push(t);
35
+ });
36
+ if (lines.length <= 2) {
37
+ setMaxVisibleCount(children.length);
38
+ setHiddenCount(0);
39
+ return;
40
+ }
41
+ const second = lines[1];
42
+ let count = 0;
43
+ for (const c of children) {
44
+ if (c.offsetTop > second) break;
45
+ count++;
46
+ }
47
+ setMaxVisibleCount(count);
48
+ setHiddenCount(children.length - count);
49
+ }, []);
28
50
  React.useLayoutEffect(() => {
29
- const timer = setTimeout(() => {
30
- if (!containerRef.current) {
31
- setVisibleCount(value.length);
32
- setHiddenCount(0);
33
- return;
34
- }
35
- const children = Array.from(containerRef.current.children).filter(
36
- (el) => el.dataset && el.dataset["tag"] === "true"
37
- );
38
- if (children.length === 0) {
39
- setVisibleCount(value.length);
40
- setHiddenCount(0);
41
- return;
42
- }
43
- const lines = [];
44
- children.forEach((child) => {
45
- const top = child.offsetTop;
46
- if (!lines.includes(top)) lines.push(top);
47
- });
48
- if (lines.length <= 2) {
49
- setVisibleCount(value.length);
50
- setHiddenCount(0);
51
- } else {
52
- const lastLine = lines[1];
53
- let count = 0;
54
- for (let i = 0; i < children.length; i++) {
55
- if (children[i].offsetTop > lastLine) break;
56
- count++;
57
- }
58
- setVisibleCount(count);
59
- setHiddenCount(value.length - count);
60
- }
61
- }, 0);
62
- return () => clearTimeout(timer);
63
- }, [value, size, variant, radius, className]);
64
- const handleRemoveHidden = () => {
65
- const hidden = value.slice(visibleCount);
66
- hidden.forEach((item) => onRemove(item.value));
67
- };
51
+ if (maxVisibleCount === null) {
52
+ const id = window.requestAnimationFrame(calculateMaxVisible);
53
+ return () => window.cancelAnimationFrame(id);
54
+ }
55
+ }, [maxVisibleCount, calculateMaxVisible]);
56
+ const visibleCount = maxVisibleCount === null ? value.length : maxVisibleCount;
57
+ const displayTags = value.slice(0, visibleCount);
58
+ const currentHiddenCount = Math.max(value.length - visibleCount, 0);
59
+ React.useEffect(() => {
60
+ setHiddenCount(currentHiddenCount);
61
+ }, [currentHiddenCount]);
62
+ const textareaRadius = radius === "full" ? "large" : radius;
68
63
  return /* @__PURE__ */ React.createElement(
69
64
  "div",
70
65
  {
71
- ref: containerRef,
66
+ ref,
72
67
  className: cn(
73
- inputVariants({ size, variant, radius }),
68
+ textareaVariants({ variant, radius: textareaRadius }),
74
69
  "flex flex-wrap items-start min-h-10 gap-1 py-2 px-3",
75
70
  disabled && "opacity-50 pointer-events-none",
76
71
  className
77
72
  ),
78
73
  tabIndex: 0,
79
74
  "aria-disabled": disabled,
75
+ style: { resize: "none", cursor: disabled ? "not-allowed" : "text" },
80
76
  ...props
81
77
  },
82
78
  value.length === 0 && /* @__PURE__ */ React.createElement(Typography, { variant: "body-small-400", className: "text-grey-400" }, placeholder),
83
- tagsToShow.map((item) => /* @__PURE__ */ React.createElement(Tag, { key: item.value, color: "blue", "data-tag": "true" }, /* @__PURE__ */ React.createElement(Typography, { variant: "body-small-400", className: "text-blue-600" }, item.label), !readOnly && /* @__PURE__ */ React.createElement(
79
+ displayTags.map((item) => /* @__PURE__ */ React.createElement(Tag, { key: item.value, "data-tag": "true", color: "blue" }, /* @__PURE__ */ React.createElement(Typography, { variant: "body-small-400", className: "text-blue-600" }, item.label), !readOnly && /* @__PURE__ */ React.createElement(
84
80
  X,
85
81
  {
86
82
  className: "w-4 h-4 cursor-pointer",
@@ -92,19 +88,20 @@ const TagInput = ({
92
88
  tabIndex: 0
93
89
  }
94
90
  ))),
95
- hiddenCount > 0 && /* @__PURE__ */ React.createElement(Tag, { color: "blue", "data-tag": "true" }, /* @__PURE__ */ React.createElement(Typography, { variant: "body-small-400", className: "text-blue-600" }, "+", hiddenCount), !readOnly && /* @__PURE__ */ React.createElement(
91
+ hiddenCount > 0 && /* @__PURE__ */ React.createElement(Tag, { color: "grey", "data-tag": "true" }, /* @__PURE__ */ React.createElement(Typography, { variant: "body-small-400", className: "text-grey-600" }, "+", hiddenCount), !readOnly && /* @__PURE__ */ React.createElement(
96
92
  X,
97
93
  {
98
- className: "w-4 h-4 cursor-pointer",
94
+ className: "w-4 h-4 cursor-pointer text-grey-500 hover:text-grey-700",
99
95
  onClick: (e) => {
100
96
  e.stopPropagation();
101
- handleRemoveHidden();
97
+ const next = value[visibleCount]?.value;
98
+ if (next) onRemove(next);
102
99
  },
103
- "aria-label": `Remover tags ocultas`,
100
+ "aria-label": "Remover pr\xF3xima tag oculta",
104
101
  tabIndex: 0
105
102
  }
106
103
  ))
107
104
  );
108
- };
105
+ }
109
106
 
110
107
  export { TagInput };