lecom-ui 5.2.81 → 5.2.83

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.
@@ -0,0 +1,207 @@
1
+ import * as React from 'react';
2
+ import { useFormContext, Controller } from 'react-hook-form';
3
+ import { cn } from '../../lib/utils.js';
4
+ import { Button } from '../Button/Button.js';
5
+
6
+ function DividerLine({
7
+ dashed,
8
+ plain,
9
+ isGroupDivider,
10
+ isActive,
11
+ className,
12
+ style
13
+ }) {
14
+ return /* @__PURE__ */ React.createElement(
15
+ "div",
16
+ {
17
+ className: cn(
18
+ "w-full",
19
+ isGroupDivider ? "my-4" : "my-2",
20
+ isActive ? "opacity-100" : "opacity-50",
21
+ className
22
+ ),
23
+ style
24
+ },
25
+ /* @__PURE__ */ React.createElement(
26
+ "div",
27
+ {
28
+ className: cn(
29
+ "w-full border-t",
30
+ dashed ? "border-dashed" : "border-solid",
31
+ plain ? "border-gray-200" : "border-gray-300"
32
+ )
33
+ }
34
+ )
35
+ );
36
+ }
37
+ function OptionButtons({
38
+ value,
39
+ onChange,
40
+ isActive,
41
+ plain,
42
+ optionLabels,
43
+ ButtonComponent,
44
+ buttonSize,
45
+ buttonClassName
46
+ }) {
47
+ const [labelAnd, labelOr] = optionLabels;
48
+ const Btn = ButtonComponent;
49
+ return /* @__PURE__ */ React.createElement(
50
+ "div",
51
+ {
52
+ className: cn(
53
+ "relative z-10 inline-flex overflow-hidden",
54
+ plain ? "bg-white" : "rounded-md border border-gray-300 bg-white shadow-sm"
55
+ )
56
+ },
57
+ /* @__PURE__ */ React.createElement(
58
+ Btn,
59
+ {
60
+ type: "button",
61
+ variant: "ghost",
62
+ color: "grey",
63
+ size: buttonSize,
64
+ onClick: () => onChange("AND"),
65
+ disabled: !isActive,
66
+ className: cn(
67
+ "px-4 py-1 text-sm transition !rounded-none",
68
+ value === "AND" ? "bg-blue-600 text-white hover:bg-blue-500" : "bg-white text-gray-700 hover:bg-blue-50",
69
+ buttonClassName
70
+ )
71
+ },
72
+ labelAnd
73
+ ),
74
+ /* @__PURE__ */ React.createElement(
75
+ Btn,
76
+ {
77
+ type: "button",
78
+ variant: "ghost",
79
+ color: "grey",
80
+ size: buttonSize,
81
+ onClick: () => onChange("OR"),
82
+ disabled: !isActive,
83
+ className: cn(
84
+ "px-4 py-1 text-sm transition !rounded-none",
85
+ value === "OR" ? "bg-blue-600 text-white hover:bg-blue-500" : "bg-white text-gray-700 hover:bg-blue-50",
86
+ buttonClassName
87
+ )
88
+ },
89
+ labelOr
90
+ )
91
+ );
92
+ }
93
+ function CustomDivider({
94
+ name,
95
+ control,
96
+ isActive = true,
97
+ isGroupDivider = false,
98
+ orientation = "center",
99
+ dashed = false,
100
+ plain = false,
101
+ lineOnly = false,
102
+ optionLabels = ["E", "OU"],
103
+ ButtonComponent = Button,
104
+ buttonSize = "medium",
105
+ buttonClassName,
106
+ className,
107
+ style,
108
+ children
109
+ }) {
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) {
118
+ return /* @__PURE__ */ React.createElement(
119
+ DividerLine,
120
+ {
121
+ dashed,
122
+ plain,
123
+ isGroupDivider,
124
+ isActive,
125
+ className,
126
+ style
127
+ }
128
+ );
129
+ }
130
+ if (children) {
131
+ return /* @__PURE__ */ React.createElement(
132
+ "div",
133
+ {
134
+ className: cn(
135
+ "relative w-full flex items-center",
136
+ isGroupDivider ? "my-4" : "my-2",
137
+ isActive ? "opacity-100" : "opacity-50",
138
+ justifyMap[orientation],
139
+ className
140
+ ),
141
+ style
142
+ },
143
+ /* @__PURE__ */ React.createElement(
144
+ "div",
145
+ {
146
+ className: cn(
147
+ "absolute inset-x-0 border-t",
148
+ dashed ? "border-dashed" : "border-solid",
149
+ plain ? "border-gray-200" : "border-gray-300"
150
+ )
151
+ }
152
+ ),
153
+ /* @__PURE__ */ React.createElement("span", { className: "relative z-10 px-2 bg-white" }, children)
154
+ );
155
+ }
156
+ if (!name) {
157
+ throw new Error(
158
+ "CustomDivider: prop `name` \xE9 obrigat\xF3ria se `lineOnly` for false."
159
+ );
160
+ }
161
+ return /* @__PURE__ */ React.createElement(
162
+ "div",
163
+ {
164
+ className: cn(
165
+ "relative w-full flex items-center",
166
+ isGroupDivider ? "my-4" : "my-2",
167
+ isActive ? "opacity-100" : "opacity-50",
168
+ justifyMap[orientation],
169
+ className
170
+ ),
171
+ style
172
+ },
173
+ /* @__PURE__ */ React.createElement(
174
+ "div",
175
+ {
176
+ className: cn(
177
+ "absolute inset-x-0 border-t",
178
+ dashed ? "border-dashed" : "border-solid",
179
+ plain ? "border-gray-200" : "border-gray-300"
180
+ )
181
+ }
182
+ ),
183
+ /* @__PURE__ */ React.createElement(
184
+ Controller,
185
+ {
186
+ name,
187
+ control: controlToUse,
188
+ render: ({ field: { value, onChange } }) => /* @__PURE__ */ React.createElement(
189
+ OptionButtons,
190
+ {
191
+ value,
192
+ onChange,
193
+ isActive,
194
+ plain,
195
+ optionLabels,
196
+ ButtonComponent,
197
+ buttonSize,
198
+ buttonClassName
199
+ }
200
+ )
201
+ }
202
+ )
203
+ );
204
+ }
205
+ CustomDivider.displayName = "CustomDivider";
206
+
207
+ export { CustomDivider };
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { cn } from '../../lib/utils.js';
3
- import { useReactTable, getFilteredRowModel, getSortedRowModel, getCoreRowModel } from '@tanstack/react-table';
3
+ import { useReactTable, getSortedRowModel, getCoreRowModel } from '@tanstack/react-table';
4
4
  import { Pagination } from '../Pagination/Pagination.js';
5
5
  import { ScrollArea, ScrollBar } from '../ScrollArea/ScrollArea.js';
6
6
  import { buildColumns } from './DataTable.utils.js';
@@ -21,39 +21,16 @@ function DataTable({
21
21
  onIsSelected
22
22
  }) {
23
23
  const [sorting, setSorting] = React.useState([]);
24
- const [columnFilters, setColumnFilters] = React.useState(
25
- []
26
- );
27
- const memoizedColumns = React.useMemo(
28
- () => buildColumns({ columns, size }),
29
- [columns, size]
30
- );
31
24
  const table = useReactTable({
32
25
  data,
33
- columns: memoizedColumns,
34
- onColumnFiltersChange: setColumnFilters,
26
+ columns: buildColumns({ columns, size }),
35
27
  getCoreRowModel: getCoreRowModel(),
36
28
  onSortingChange: setSorting,
37
29
  getSortedRowModel: getSortedRowModel(),
38
- getFilteredRowModel: getFilteredRowModel(),
39
30
  state: {
40
- sorting,
41
- columnFilters
31
+ sorting
42
32
  }
43
33
  });
44
- React.useEffect(() => {
45
- if (!table) return;
46
- columns.forEach((column) => {
47
- const value = column.filterProps?.value;
48
- const columnKey = column.key;
49
- if (value !== void 0) {
50
- const column2 = table.getColumn(columnKey);
51
- if (column2) {
52
- column2.setFilterValue(value);
53
- }
54
- }
55
- });
56
- }, [columns, table]);
57
34
  const styleDataTableContainer = () => ({
58
35
  width: vwDiff ? `calc(100vw - ${vwDiff}px)` : "100%",
59
36
  height: vhDiff ? `calc(100vh - ${vhDiff}px)` : "100%"
@@ -1,8 +1,7 @@
1
1
  import * as React from 'react';
2
- import { cn } from '../../lib/utils.js';
2
+ import { clsx } from 'clsx';
3
3
  import { ArrowUpDown } from 'lucide-react';
4
4
  import { Checkbox } from '../Checkbox/Checkbox.js';
5
- import { Input } from '../Input/Input.js';
6
5
  import { Typography } from '../Typography/Typography.js';
7
6
 
8
7
  function buildHeaderSelect({
@@ -54,80 +53,33 @@ function buildColumns({
54
53
  return null;
55
54
  }
56
55
  const hasSort = !!externalColumn.onSort || !!externalColumn.onSortClient;
57
- const isFilterable = !!externalColumn.filterable;
58
- const filterInputValue = column.getFilterValue() ?? "";
59
- const handleFilterInputChange = (event) => {
60
- const updatedValue = event.target.value;
61
- column.setFilterValue(updatedValue);
62
- if (externalColumn?.filterProps?.setFilterValue) {
63
- externalColumn.filterProps.setFilterValue(updatedValue);
64
- }
65
- };
66
56
  const title = typeof externalColumn.title === "function" ? externalColumn.title({ table, column }) : externalColumn.title;
67
- function renderFilterInput() {
68
- if (isFilterable && column.getCanFilter()) {
69
- return /* @__PURE__ */ React.createElement(
70
- "div",
71
- {
72
- className: cn(
73
- "ml-2 w-full flex items-center justify-start",
74
- externalColumn.filterProps?.className
75
- )
76
- },
77
- /* @__PURE__ */ React.createElement(
78
- Input,
79
- {
80
- ...externalColumn.filterProps?.inputProps,
81
- type: "text",
82
- value: filterInputValue,
83
- onChange: handleFilterInputChange,
84
- placeholder: externalColumn.filterProps?.placeholder
85
- }
86
- )
87
- );
88
- }
89
- return null;
90
- }
91
- function renderSortArrow() {
92
- if (hasSort) {
93
- return /* @__PURE__ */ React.createElement(
94
- ArrowUpDown,
95
- {
96
- size: 16,
97
- className: "ml-1 text-grey-400 group-hover:text-grey-950 hover:cursor-pointer",
98
- onClick: (e) => {
99
- e.stopPropagation();
100
- const handler = column.getToggleSortingHandler?.();
101
- if (handler) handler(e);
102
- else if (externalColumn.onSort) {
103
- externalColumn.onSort({ table, column });
104
- }
105
- }
106
- }
107
- );
108
- }
109
- return null;
110
- }
111
57
  return /* @__PURE__ */ React.createElement(
112
58
  "div",
113
59
  {
114
- className: cn(
60
+ className: clsx(
115
61
  "group flex items-center gap-1",
116
62
  hasSort && "hover:cursor-pointer"
117
- )
63
+ ),
64
+ onClick: () => externalColumn.onSort?.({ table, column })
118
65
  },
119
66
  typeof externalColumn.title === "string" ? /* @__PURE__ */ React.createElement(
120
67
  Typography,
121
68
  {
122
69
  variant: size === "small" ? "body-medium-500" : "body-large-500",
123
70
  textColor: "text-grey-950",
124
- className: "whitespace-normal break-words max-sm:truncate",
71
+ className: "truncate",
125
72
  title: externalColumn.title
126
73
  },
127
74
  externalColumn.title
128
75
  ) : title,
129
- renderSortArrow(),
130
- renderFilterInput()
76
+ hasSort && /* @__PURE__ */ React.createElement(
77
+ ArrowUpDown,
78
+ {
79
+ size: 16,
80
+ className: "text-grey-400 group-hover:text-grey-950"
81
+ }
82
+ )
131
83
  );
132
84
  },
133
85
  cell: ({ row }) => {
@@ -157,11 +109,6 @@ function buildColumns({
157
109
  row.getValue(externalColumn.key)
158
110
  );
159
111
  },
160
- filterFn: externalColumn.filterable ? (row, columnId, filterValue) => {
161
- const rawValue = row.getValue(columnId);
162
- const value = typeof rawValue === "string" ? rawValue : String(rawValue ?? "");
163
- return value.toLowerCase().includes(String(filterValue).toLowerCase());
164
- } : void 0,
165
112
  meta: {
166
113
  width: externalColumn.width,
167
114
  fixed: externalColumn.fixed,
@@ -54,7 +54,8 @@ function Table({
54
54
  style: styleColumn(
55
55
  header.column.columnDef.meta,
56
56
  "th"
57
- )
57
+ ),
58
+ onClick: header.column.getToggleSortingHandler()
58
59
  },
59
60
  header.isPlaceholder ? null : flexRender(
60
61
  header.column.columnDef.header,
@@ -0,0 +1,40 @@
1
+ import * as React from 'react';
2
+ import { Button } from '../Button/Button.js';
3
+ import { Calendar } from '../Calendar/Calendar.js';
4
+ import { Popover, PopoverTrigger, PopoverContent } from '../Popover/Popover.js';
5
+ import { cn } from '../../lib/utils.js';
6
+ import { format } from 'date-fns';
7
+ import { CalendarIcon } from 'lucide-react';
8
+
9
+ function DatePicker({
10
+ className,
11
+ variant = "outlined",
12
+ locale
13
+ }) {
14
+ const [date, setDate] = React.useState();
15
+ return /* @__PURE__ */ React.createElement(Popover, null, /* @__PURE__ */ React.createElement(PopoverTrigger, { asChild: true }, /* @__PURE__ */ React.createElement(
16
+ Button,
17
+ {
18
+ variant,
19
+ className: cn(
20
+ "w-[240px] justify-start text-left font-normal",
21
+ !date && "text-muted-foreground",
22
+ className
23
+ )
24
+ },
25
+ /* @__PURE__ */ React.createElement(CalendarIcon, { className: "mr-2 h-4 w-4" }),
26
+ date ? format(date, "PPP", { locale }) : /* @__PURE__ */ React.createElement("span", null, "Pick a date")
27
+ )), /* @__PURE__ */ React.createElement(PopoverContent, { className: "w-auto p-0", align: "start" }, /* @__PURE__ */ React.createElement(
28
+ Calendar,
29
+ {
30
+ mode: "single",
31
+ selected: date,
32
+ onSelect: setDate,
33
+ autoFocus: true,
34
+ locale
35
+ }
36
+ )));
37
+ }
38
+ DatePicker.displayName = "DatePicker";
39
+
40
+ export { DatePicker };
@@ -0,0 +1,102 @@
1
+ import * as React from 'react';
2
+ import { cn } from '../../lib/utils.js';
3
+
4
+ const Steps = ({
5
+ items,
6
+ current = 0,
7
+ className,
8
+ dotSize = "medium",
9
+ color = "blue"
10
+ }) => {
11
+ const getStepStatus = (index, item) => {
12
+ if (item.status) return item.status;
13
+ if (index < current) return "completed";
14
+ if (index === current) return "current";
15
+ return "pending";
16
+ };
17
+ const getDotSizeClasses = () => {
18
+ const outerDotSizeClasses = {
19
+ small: "w-[10px] h-[10px]",
20
+ medium: "w-6 h-6",
21
+ large: "w-8 h-8"
22
+ };
23
+ const innerDotSizeClasses = {
24
+ small: "",
25
+ medium: "w-2 h-2",
26
+ large: "w-3 h-3"
27
+ };
28
+ return {
29
+ outer: outerDotSizeClasses[dotSize],
30
+ inner: innerDotSizeClasses[dotSize]
31
+ };
32
+ };
33
+ const getStepIcon = () => dotSize !== "small" ? /* @__PURE__ */ React.createElement("div", { className: cn("rounded-full", getDotSizeClasses().inner) }) : null;
34
+ const getStepColors = () => {
35
+ const colorOptions = {
36
+ blue: "bg-blue-600 border-blue-600",
37
+ red: "bg-red-600 border-red-600",
38
+ green: "bg-green-600 border-green-600",
39
+ purple: "bg-purple-600 border-purple-600",
40
+ orange: "bg-orange-500 border-orange-500"
41
+ };
42
+ return colorOptions[color] || colorOptions.blue;
43
+ };
44
+ return /* @__PURE__ */ React.createElement("div", { className: cn("relative", className) }, items.map((item, index) => {
45
+ const status = getStepStatus(index, item);
46
+ const isCurrent = index === current;
47
+ const isLast = index === items.length - 1;
48
+ return /* @__PURE__ */ React.createElement("div", { key: index, className: "relative flex items-baseline" }, !isLast && /* @__PURE__ */ React.createElement(
49
+ "div",
50
+ {
51
+ className: cn("absolute border-l border-dashed -z-10", {
52
+ "left-[4.5px]": dotSize === "small",
53
+ "left-3": dotSize === "medium",
54
+ "left-4": dotSize === "large",
55
+ "border-blue-300": color === "blue",
56
+ "border-red-300": color === "red",
57
+ "border-green-300": color === "green",
58
+ "border-purple-300": color === "purple",
59
+ "border-orange-300": color === "orange"
60
+ }),
61
+ style: {
62
+ top: dotSize === "small" ? "10px" : dotSize === "medium" ? "16px" : "24px",
63
+ height: dotSize === "small" ? "calc(100% - 10px)" : dotSize === "medium" ? "calc(100% - 24px)" : "calc(100% - 32px)"
64
+ }
65
+ }
66
+ ), /* @__PURE__ */ React.createElement(
67
+ "div",
68
+ {
69
+ className: cn(
70
+ "relative z-10 flex items-center justify-center rounded-full",
71
+ getDotSizeClasses().outer,
72
+ getStepColors(),
73
+ dotSize === "small" ? "" : "border"
74
+ )
75
+ },
76
+ getStepIcon()
77
+ ), /* @__PURE__ */ React.createElement(
78
+ "div",
79
+ {
80
+ className: cn("pb-6 flex-1 mt-0", {
81
+ "ml-[14px]": dotSize === "small",
82
+ "ml-4": dotSize === "medium",
83
+ "ml-5": dotSize === "large"
84
+ })
85
+ },
86
+ /* @__PURE__ */ React.createElement(
87
+ "div",
88
+ {
89
+ className: cn(
90
+ "text-sm font-medium",
91
+ status === "completed" || isCurrent ? "text-gray-900" : "text-gray-500"
92
+ )
93
+ },
94
+ item.title
95
+ ),
96
+ item.description && /* @__PURE__ */ React.createElement("div", { className: "mt-1" }, typeof item.description === "string" ? /* @__PURE__ */ React.createElement("div", { className: "text-sm text-gray-600" }, item.description) : item.description)
97
+ ));
98
+ }));
99
+ };
100
+ Steps.displayName = "Steps";
101
+
102
+ export { Steps };
@@ -1,24 +1,60 @@
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
- const Switch = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React.createElement(
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
+ "circle",
7
+ {
8
+ className: "opacity-25",
9
+ cx: "12",
10
+ cy: "12",
11
+ r: "10",
12
+ stroke: "currentColor",
13
+ strokeWidth: "4",
14
+ fill: "none"
15
+ }
16
+ ), /* @__PURE__ */ React.createElement(
17
+ "path",
18
+ {
19
+ className: "opacity-75",
20
+ fill: "currentColor",
21
+ d: "M4 12a8 8 0 018-8v4a4 4 0 00-4 4H4z"
22
+ }
23
+ ));
24
+ const Switch = React.forwardRef(({ className, loading = false, disabled, ...props }, ref) => /* @__PURE__ */ React.createElement(
6
25
  SwitchPrimitives.Root,
7
26
  {
27
+ ref,
28
+ disabled: disabled || loading,
8
29
  className: cn(
9
- "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",
10
37
  className
11
38
  ),
12
- ref,
13
39
  ...props
14
40
  },
15
41
  /* @__PURE__ */ React.createElement(
16
42
  SwitchPrimitives.Thumb,
17
43
  {
18
44
  className: cn(
19
- "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"
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"
20
55
  )
21
- }
56
+ },
57
+ loading && /* @__PURE__ */ React.createElement(Spinner, null)
22
58
  )
23
59
  ));
24
60
  Switch.displayName = "Switch";