lecom-ui 4.2.0 → 4.2.2

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.
@@ -5,7 +5,7 @@ const ImgBrand = ({ src }) => /* @__PURE__ */ jsx(
5
5
  "img",
6
6
  {
7
7
  loading: "lazy",
8
- src: src ?? img.src,
8
+ src: src ?? img ?? img.src,
9
9
  alt: "Logo",
10
10
  className: "w-auto h-auto max-w-[102px] max-h-[32px]"
11
11
  }
@@ -1,5 +1,5 @@
1
- /* eslint-disable @typescript-eslint/no-require-imports */
2
-
3
- const buildPlugin = require('./template').buildPlugin;
4
-
5
- module.exports = buildPlugin('~/node_modules/lecom-ui/dist/public');
1
+ /* eslint-disable @typescript-eslint/no-require-imports */
2
+
3
+ const buildPlugin = require('./template').buildPlugin;
4
+
5
+ module.exports = buildPlugin('~/node_modules/lecom-ui/dist/public');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lecom-ui",
3
- "version": "4.2.0",
3
+ "version": "4.2.2",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "module": "dist/index.js",
@@ -101,5 +101,6 @@
101
101
  "extends": [
102
102
  "plugin:storybook/recommended"
103
103
  ]
104
- }
104
+ },
105
+ "packageManager": "yarn@3.8.7+sha256.81bf69deb72c6cfebaca4389444e034c914cc1a90ea40e4ac55a5e2a1d7063d2"
105
106
  }
@@ -1,100 +0,0 @@
1
- import * as React from 'react';
2
- import { clsx } from 'clsx';
3
- import { ArrowUpDown } from 'lucide-react';
4
- import { Checkbox } from '../Checkbox/Checkbox.js';
5
- import { Typography } from '../Typography/Typography.js';
6
-
7
- function buildHeaderSelect({
8
- table,
9
- column,
10
- checkedHeader,
11
- onCheckedHeaderChange
12
- }) {
13
- return /* @__PURE__ */ React.createElement(
14
- Checkbox,
15
- {
16
- checked: !!checkedHeader?.({ table, column }),
17
- onCheckedChange: (value) => onCheckedHeaderChange?.({ table, column, value: !!value })
18
- }
19
- );
20
- }
21
- function buildCellSelect({
22
- row,
23
- checkedCell,
24
- onCheckedCellChange
25
- }) {
26
- return /* @__PURE__ */ React.createElement(
27
- Checkbox,
28
- {
29
- checked: !!checkedCell?.({ row }),
30
- onCheckedChange: (value) => onCheckedCellChange?.({ row, value: !!value })
31
- }
32
- );
33
- }
34
- function buildColumns({
35
- columns
36
- }) {
37
- const mappedColumns = columns.map((externalColumn) => ({
38
- accessorKey: externalColumn.key,
39
- header: ({ table, column }) => {
40
- if (!!externalColumn.enableSelect) {
41
- return buildHeaderSelect({
42
- table,
43
- column,
44
- checkedHeader: externalColumn.checkedHeader,
45
- onCheckedHeaderChange: externalColumn.onCheckedHeaderChange
46
- });
47
- }
48
- if (!externalColumn.title) {
49
- return null;
50
- }
51
- const hasSort = !!externalColumn.onSort;
52
- const title = typeof externalColumn.title === "function" ? externalColumn.title({ table, column }) : externalColumn.title;
53
- return /* @__PURE__ */ React.createElement(
54
- "div",
55
- {
56
- className: clsx(
57
- "group flex items-center gap-1",
58
- hasSort && "hover:cursor-pointer"
59
- ),
60
- onClick: () => externalColumn.onSort?.({ table, column })
61
- },
62
- typeof externalColumn.title === "string" ? /* @__PURE__ */ React.createElement(Typography, { variant: "body-large-500", textColor: "text-grey-950" }, externalColumn.title) : title,
63
- hasSort && /* @__PURE__ */ React.createElement(
64
- ArrowUpDown,
65
- {
66
- size: 16,
67
- className: "text-grey-400 group-hover:text-grey-950"
68
- }
69
- )
70
- );
71
- },
72
- cell: ({ row }) => {
73
- if (!!externalColumn.enableSelect) {
74
- return buildCellSelect({
75
- row,
76
- checkedCell: externalColumn.checkedCell,
77
- onCheckedCellChange: externalColumn.onCheckedCellChange
78
- });
79
- }
80
- if (!!externalColumn.render) {
81
- if (typeof externalColumn.render === "function") {
82
- return externalColumn.render({
83
- value: row.getValue(externalColumn.key),
84
- row
85
- });
86
- }
87
- return externalColumn.render;
88
- }
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,
94
- truncate: !!externalColumn.truncate
95
- }
96
- }));
97
- return mappedColumns;
98
- }
99
-
100
- export { buildColumns };
@@ -1,204 +0,0 @@
1
- import * as React from 'react';
2
- import { useTranslation } from 'react-i18next';
3
- import { Button } from '../Button/Button.js';
4
- import { cn } from '../../lib/utils.js';
5
- import { ChevronFirst, ChevronLast, ChevronLeft, ChevronRight, MoreHorizontal, ChevronDown } from 'lucide-react';
6
- import { initializeI18n } from '../../i18n/index.js';
7
- import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem } from '../DropdownMenu/DropdownMenu.js';
8
- import { Typography } from '../Typography/Typography.js';
9
-
10
- initializeI18n();
11
- const PaginationContent = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React.createElement(
12
- "ul",
13
- {
14
- ref,
15
- className: cn("flex flex-row items-center gap-1", className),
16
- ...props
17
- }
18
- ));
19
- PaginationContent.displayName = "PaginationContent";
20
- const PaginationItem = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React.createElement("li", { ref, className: cn("", className), ...props }));
21
- PaginationItem.displayName = "PaginationItem";
22
- const PaginationFirst = ({
23
- className,
24
- disabled,
25
- isActive,
26
- onClick
27
- }) => /* @__PURE__ */ React.createElement(
28
- Button,
29
- {
30
- disabled,
31
- iconButton: true,
32
- variant: "ghost",
33
- color: "grey",
34
- size: "small",
35
- onClick,
36
- className: cn(isActive && "bg-white", className)
37
- },
38
- /* @__PURE__ */ React.createElement(ChevronFirst, { size: 20 })
39
- );
40
- PaginationFirst.displayName = "PaginationFirst";
41
- const PaginationLast = ({
42
- className,
43
- disabled,
44
- isActive,
45
- onClick
46
- }) => /* @__PURE__ */ React.createElement(
47
- Button,
48
- {
49
- disabled,
50
- iconButton: true,
51
- variant: "ghost",
52
- color: "grey",
53
- size: "small",
54
- onClick,
55
- className: cn(isActive && "bg-white", className)
56
- },
57
- /* @__PURE__ */ React.createElement(ChevronLast, { size: 20 })
58
- );
59
- PaginationLast.displayName = "PaginationLast";
60
- const PaginationPrevious = ({
61
- className,
62
- disabled,
63
- isActive,
64
- onClick
65
- }) => /* @__PURE__ */ React.createElement(
66
- Button,
67
- {
68
- disabled,
69
- iconButton: true,
70
- variant: "ghost",
71
- color: "grey",
72
- size: "small",
73
- onClick,
74
- className: cn(isActive && "bg-white", className)
75
- },
76
- /* @__PURE__ */ React.createElement(ChevronLeft, { size: 20 })
77
- );
78
- PaginationPrevious.displayName = "PaginationPrevious";
79
- const PaginationNext = ({
80
- className,
81
- disabled,
82
- isActive,
83
- onClick
84
- }) => /* @__PURE__ */ React.createElement(
85
- Button,
86
- {
87
- disabled,
88
- iconButton: true,
89
- variant: "ghost",
90
- color: "grey",
91
- size: "small",
92
- onClick,
93
- className: cn(isActive && "bg-white", className)
94
- },
95
- /* @__PURE__ */ React.createElement(ChevronRight, { size: 20 })
96
- );
97
- PaginationNext.displayName = "PaginationNext";
98
- const PaginationEllipsis = ({
99
- className,
100
- disabled,
101
- isActive,
102
- asChild,
103
- onClick
104
- }) => {
105
- if (asChild) {
106
- return /* @__PURE__ */ React.createElement("div", { className: "w-8 h-8 flex items-center justify-center" }, /* @__PURE__ */ React.createElement(MoreHorizontal, { size: 20, className: "text-grey-800" }));
107
- }
108
- return /* @__PURE__ */ React.createElement(
109
- Button,
110
- {
111
- disabled,
112
- iconButton: true,
113
- variant: "ghost",
114
- color: "grey",
115
- size: "small",
116
- onClick,
117
- className: cn(isActive && "bg-white", className)
118
- },
119
- /* @__PURE__ */ React.createElement(MoreHorizontal, { size: 20 })
120
- );
121
- };
122
- PaginationEllipsis.displayName = "PaginationEllipsis";
123
- const PaginationIndex = ({
124
- className,
125
- disabled,
126
- isActive,
127
- onClick,
128
- children
129
- }) => /* @__PURE__ */ React.createElement(
130
- Button,
131
- {
132
- disabled,
133
- iconButton: true,
134
- variant: "ghost",
135
- color: "grey",
136
- size: "small",
137
- onClick,
138
- className: cn(isActive && "bg-white", className)
139
- },
140
- children
141
- );
142
- PaginationIndex.displayName = "PaginationIndex";
143
- const Pagination = ({
144
- currentPage,
145
- itemsPage,
146
- perPage,
147
- totalRowsSelected = 0,
148
- onChangePerPage
149
- }) => {
150
- const { t } = useTranslation();
151
- const perPageOptions = [
152
- {
153
- value: 50
154
- },
155
- {
156
- value: 100
157
- },
158
- {
159
- value: 200
160
- },
161
- {
162
- value: 300
163
- }
164
- ];
165
- const mapPaginationItem = (item) => {
166
- const componentProps = {
167
- onClick: item.onClick,
168
- disabled: item.disabled
169
- };
170
- if (item.type === "page") {
171
- return /* @__PURE__ */ React.createElement(
172
- PaginationIndex,
173
- {
174
- isActive: item.page === currentPage,
175
- ...componentProps
176
- },
177
- item.page
178
- );
179
- }
180
- if (item.type.includes("ellipsis")) {
181
- return /* @__PURE__ */ React.createElement(PaginationEllipsis, { asChild: true });
182
- }
183
- const mappedComponents = {
184
- first: PaginationFirst,
185
- previous: PaginationPrevious,
186
- next: PaginationNext,
187
- last: PaginationLast
188
- };
189
- return React.createElement(mappedComponents[item.type], componentProps);
190
- };
191
- return /* @__PURE__ */ React.createElement("div", { className: "flex items-center justify-between mt-6 gap-4" }, /* @__PURE__ */ React.createElement("div", { className: "flex items-center gap-4" }, /* @__PURE__ */ React.createElement(DropdownMenu, null, /* @__PURE__ */ React.createElement(DropdownMenuTrigger, { asChild: true }, /* @__PURE__ */ React.createElement(Button, { size: "small", color: "grey", variant: "outlined" }, /* @__PURE__ */ React.createElement("span", { className: "max-md:hidden" }, t("pagination.show")), " ", perPage, /* @__PURE__ */ React.createElement(ChevronDown, { size: 20 }))), /* @__PURE__ */ React.createElement(DropdownMenuContent, { side: "top", align: "center" }, perPageOptions.map((option) => /* @__PURE__ */ React.createElement(
192
- DropdownMenuItem,
193
- {
194
- key: option.value,
195
- onSelect: () => {
196
- onChangePerPage?.(option.value);
197
- }
198
- },
199
- option.value.toString()
200
- )))), totalRowsSelected > 0 && /* @__PURE__ */ React.createElement(Typography, { variant: "heading-xxsmall-600", textColor: "text-grey-800" }, totalRowsSelected, " ", t("pagination.selectedProcess"))), /* @__PURE__ */ React.createElement("nav", { role: "navigation", "aria-label": "pagination" }, /* @__PURE__ */ React.createElement(PaginationContent, null, itemsPage.map((item) => /* @__PURE__ */ React.createElement(PaginationItem, { key: item.id }, mapPaginationItem(item))))));
201
- };
202
- Pagination.displayName = "Pagination";
203
-
204
- export { Pagination, PaginationContent, PaginationEllipsis, PaginationFirst, PaginationIndex, PaginationItem, PaginationLast, PaginationNext, PaginationPrevious };
@@ -1,42 +0,0 @@
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 };
@@ -1,40 +0,0 @@
1
- import * as React from 'react';
2
- import { cn } from '../../lib/utils.js';
3
-
4
- const Spin = React.forwardRef(
5
- ({ textColor, size = 24, className, ...props }, ref) => /* @__PURE__ */ React.createElement(
6
- "svg",
7
- {
8
- width: size,
9
- height: size,
10
- viewBox: "0 0 24 24",
11
- fill: "none",
12
- xmlns: "http://www.w3.org/2000/svg",
13
- ref,
14
- className: cn("animate-spin", className, textColor),
15
- ...props
16
- },
17
- /* @__PURE__ */ React.createElement(
18
- "circle",
19
- {
20
- className: "opacity-25",
21
- cx: "12",
22
- cy: "12",
23
- r: "10",
24
- stroke: "currentColor",
25
- strokeWidth: "4"
26
- }
27
- ),
28
- /* @__PURE__ */ React.createElement(
29
- "path",
30
- {
31
- className: "opacity-75",
32
- fill: "currentColor",
33
- d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
34
- }
35
- )
36
- )
37
- );
38
- Spin.displayName = "Spin";
39
-
40
- export { Spin };
@@ -1,26 +0,0 @@
1
- import * as React from 'react';
2
- import { cn } from '../../lib/utils.js';
3
- import * as SwitchPrimitives from '@radix-ui/react-switch';
4
-
5
- const Switch = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React.createElement(
6
- SwitchPrimitives.Root,
7
- {
8
- 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",
10
- className
11
- ),
12
- ref,
13
- ...props
14
- },
15
- /* @__PURE__ */ React.createElement(
16
- SwitchPrimitives.Thumb,
17
- {
18
- 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"
20
- )
21
- }
22
- )
23
- ));
24
- Switch.displayName = "Switch";
25
-
26
- export { Switch };
@@ -1,20 +0,0 @@
1
- import * as React from 'react';
2
-
3
- const MOBILE_BREAKPOINT = 768;
4
- function useIsMobile() {
5
- const [isMobile, setIsMobile] = React.useState(
6
- undefined
7
- );
8
- React.useEffect(() => {
9
- const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
10
- const onChange = () => {
11
- setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
12
- };
13
- mql.addEventListener("change", onChange);
14
- setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
15
- return () => mql.removeEventListener("change", onChange);
16
- }, []);
17
- return !!isMobile;
18
- }
19
-
20
- export { useIsMobile };
@@ -1,97 +0,0 @@
1
- import { useState, useMemo } from 'react';
2
-
3
- const usePagination = ({
4
- count = 1,
5
- defaultPage = 1,
6
- boundaryCount = 1,
7
- siblingCount = 1,
8
- disabled = false,
9
- hideNextButton = false,
10
- hidePrevButton = false,
11
- showFirstButton = true,
12
- showLastButton = true,
13
- onChange
14
- } = {}) => {
15
- const [page, setPage] = useState(defaultPage);
16
- const handleClick = (value) => {
17
- if (!disabled && value >= 1 && value <= count) {
18
- setPage(value);
19
- if (onChange) {
20
- onChange(value);
21
- }
22
- }
23
- };
24
- const range = (start, end) => Array.from({ length: end - start + 1 }, (_, i) => start + i);
25
- const startPages = range(1, Math.min(boundaryCount, count));
26
- const endPages = range(
27
- Math.max(count - boundaryCount + 1, boundaryCount + 1),
28
- count
29
- );
30
- const siblingsStart = Math.max(
31
- Math.min(page - siblingCount, count - boundaryCount - siblingCount * 2 - 1),
32
- boundaryCount + 2
33
- );
34
- const siblingsEnd = Math.min(
35
- Math.max(page + siblingCount, boundaryCount + siblingCount * 2 + 2),
36
- count - boundaryCount - 1
37
- );
38
- const itemList = useMemo(
39
- () => [
40
- ...showFirstButton ? ["first"] : [],
41
- ...hidePrevButton ? [] : ["previous"],
42
- ...startPages,
43
- ...siblingsStart > boundaryCount + 2 ? ["start-ellipsis"] : boundaryCount + 1 < count - boundaryCount ? [boundaryCount + 1] : [],
44
- ...range(siblingsStart, siblingsEnd),
45
- ...siblingsEnd < count - boundaryCount - 1 ? ["end-ellipsis"] : count - boundaryCount > boundaryCount ? [count - boundaryCount] : [],
46
- ...endPages,
47
- ...hideNextButton ? [] : ["next"],
48
- ...showLastButton ? ["last"] : []
49
- ],
50
- // eslint-disable-next-line react-hooks/exhaustive-deps
51
- [
52
- page,
53
- count,
54
- boundaryCount,
55
- siblingCount,
56
- showFirstButton,
57
- showLastButton,
58
- hidePrevButton,
59
- hideNextButton
60
- ]
61
- );
62
- const buttonPage = (type) => {
63
- switch (type) {
64
- case "first":
65
- return 1;
66
- case "previous":
67
- return page - 1;
68
- case "next":
69
- return page + 1;
70
- case "last":
71
- return count;
72
- default:
73
- return null;
74
- }
75
- };
76
- const items = itemList.map(
77
- (item, i) => typeof item === "number" ? {
78
- id: `page_${i}`,
79
- onClick: () => handleClick(item),
80
- type: "page",
81
- page: item,
82
- selected: item === page,
83
- disabled,
84
- "aria-current": item === page ? "page" : undefined
85
- } : {
86
- id: `${item}_${i}`,
87
- onClick: () => handleClick(buttonPage(item)),
88
- type: item,
89
- page: buttonPage(item),
90
- selected: false,
91
- disabled: disabled || !item.includes("ellipsis") && (item === "next" || item === "last" ? page >= count : page <= 1)
92
- }
93
- );
94
- return { page, setPage, items };
95
- };
96
-
97
- export { usePagination };