lecom-ui 5.3.13 → 5.3.15
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,23 +6,37 @@ const CustomButton = React.forwardRef(
|
|
|
6
6
|
({ customStyles, isActive, children, ...props }, ref) => {
|
|
7
7
|
const { normal, hover, focus } = customStyles;
|
|
8
8
|
const [backgroundColor, setBackgroundColor] = React.useState(
|
|
9
|
-
opacity(normal.bgColor, normal.opacity)
|
|
9
|
+
() => opacity(normal.bgColor, normal.opacity)
|
|
10
10
|
);
|
|
11
11
|
const [color, setColor] = React.useState(normal.textColor);
|
|
12
|
-
|
|
12
|
+
React.useEffect(() => {
|
|
13
|
+
setBackgroundColor(opacity(normal.bgColor, normal.opacity));
|
|
14
|
+
setColor(normal.textColor);
|
|
15
|
+
}, [normal.bgColor, normal.opacity, normal.textColor]);
|
|
16
|
+
const handleOver = React.useCallback(() => {
|
|
13
17
|
setBackgroundColor(opacity(hover.bgColor, hover.opacity));
|
|
14
18
|
setColor(hover.textColor);
|
|
15
|
-
};
|
|
16
|
-
const handleOut = () => {
|
|
19
|
+
}, [hover.bgColor, hover.opacity, hover.textColor]);
|
|
20
|
+
const handleOut = React.useCallback(() => {
|
|
17
21
|
setBackgroundColor(opacity(normal.bgColor, normal.opacity));
|
|
18
22
|
setColor(normal.textColor);
|
|
19
|
-
};
|
|
23
|
+
}, [normal.bgColor, normal.opacity, normal.textColor]);
|
|
20
24
|
const shadowSmTailwind = "0 0 #0000, 0 0 #0000, 0 1px 2px 0 rgb(0, 0, 0, 0.05)";
|
|
21
|
-
const mappedCustomStyles =
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
const mappedCustomStyles = React.useMemo(
|
|
26
|
+
() => ({
|
|
27
|
+
backgroundColor: isActive ? opacity(focus.bgColor, focus.opacity) : backgroundColor,
|
|
28
|
+
color: isActive ? focus.textColor : color,
|
|
29
|
+
boxShadow: shadowSmTailwind
|
|
30
|
+
}),
|
|
31
|
+
[
|
|
32
|
+
isActive,
|
|
33
|
+
focus.bgColor,
|
|
34
|
+
focus.opacity,
|
|
35
|
+
focus.textColor,
|
|
36
|
+
backgroundColor,
|
|
37
|
+
color
|
|
38
|
+
]
|
|
39
|
+
);
|
|
26
40
|
return /* @__PURE__ */ React.createElement(
|
|
27
41
|
Button,
|
|
28
42
|
{
|
|
@@ -35,6 +35,32 @@ function buildColumns({
|
|
|
35
35
|
columns,
|
|
36
36
|
size = "middle"
|
|
37
37
|
}) {
|
|
38
|
+
function renderSortArrow({
|
|
39
|
+
hasSort,
|
|
40
|
+
column,
|
|
41
|
+
externalColumn,
|
|
42
|
+
table
|
|
43
|
+
}) {
|
|
44
|
+
if (!hasSort) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
return /* @__PURE__ */ React.createElement(
|
|
48
|
+
ArrowUpDown,
|
|
49
|
+
{
|
|
50
|
+
size: 16,
|
|
51
|
+
className: "ml-1 text-grey-400 group-hover:text-grey-950 hover:cursor-pointer",
|
|
52
|
+
onClick: (event) => {
|
|
53
|
+
event.stopPropagation();
|
|
54
|
+
const sortingHandler = column.getToggleSortingHandler?.();
|
|
55
|
+
if (externalColumn.onSort) {
|
|
56
|
+
externalColumn.onSort({ table, column });
|
|
57
|
+
} else if (sortingHandler) {
|
|
58
|
+
sortingHandler(event);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
}
|
|
38
64
|
const mappedColumns = columns.map((externalColumn) => ({
|
|
39
65
|
accessorKey: externalColumn.key,
|
|
40
66
|
header: ({ table, column }) => {
|
|
@@ -54,27 +80,6 @@ function buildColumns({
|
|
|
54
80
|
}
|
|
55
81
|
const hasSort = !!externalColumn.onSort || !!externalColumn.onSortClient;
|
|
56
82
|
const title = typeof externalColumn.title === "function" ? externalColumn.title({ table, column }) : externalColumn.title;
|
|
57
|
-
function renderSortArrow() {
|
|
58
|
-
if (!hasSort) {
|
|
59
|
-
return null;
|
|
60
|
-
}
|
|
61
|
-
return /* @__PURE__ */ React.createElement(
|
|
62
|
-
ArrowUpDown,
|
|
63
|
-
{
|
|
64
|
-
size: 16,
|
|
65
|
-
className: "ml-1 text-grey-400 group-hover:text-grey-950 hover:cursor-pointer",
|
|
66
|
-
onClick: (event) => {
|
|
67
|
-
event.stopPropagation();
|
|
68
|
-
const sortingHandler = column.getToggleSortingHandler?.();
|
|
69
|
-
if (externalColumn.onSort) {
|
|
70
|
-
externalColumn.onSort({ table, column });
|
|
71
|
-
} else if (sortingHandler) {
|
|
72
|
-
sortingHandler(event);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
);
|
|
77
|
-
}
|
|
78
83
|
return /* @__PURE__ */ React.createElement(
|
|
79
84
|
"div",
|
|
80
85
|
{
|
|
@@ -93,7 +98,12 @@ function buildColumns({
|
|
|
93
98
|
},
|
|
94
99
|
externalColumn.title
|
|
95
100
|
) : title,
|
|
96
|
-
renderSortArrow(
|
|
101
|
+
renderSortArrow({
|
|
102
|
+
hasSort,
|
|
103
|
+
column,
|
|
104
|
+
externalColumn,
|
|
105
|
+
table
|
|
106
|
+
})
|
|
97
107
|
);
|
|
98
108
|
},
|
|
99
109
|
cell: ({ row }) => {
|
|
@@ -11,33 +11,50 @@ const SelectTrigger = React.forwardRef(({ className, children, customStyles, ...
|
|
|
11
11
|
const normal = customStyles?.normal;
|
|
12
12
|
const hover = customStyles?.hover;
|
|
13
13
|
const focus = customStyles?.focus;
|
|
14
|
-
const [
|
|
15
|
-
normal
|
|
14
|
+
const [state, setState] = React.useState(
|
|
15
|
+
"normal"
|
|
16
16
|
);
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
React.useEffect(() => {
|
|
18
|
+
setState("normal");
|
|
19
|
+
}, [customStyles]);
|
|
20
|
+
const getCurrentStyles = React.useCallback(() => {
|
|
21
|
+
const shadowSmTailwind = "0 0 #0000, 0 0 #0000, 0 1px 2px 0 rgb(0, 0, 0, 0.05)";
|
|
22
|
+
if (!customStyles) return {};
|
|
23
|
+
if (state === "hover" && hover) {
|
|
24
|
+
return {
|
|
25
|
+
backgroundColor: opacity(hover.bgColor, hover.opacity),
|
|
26
|
+
color: hover.textColor,
|
|
27
|
+
boxShadow: shadowSmTailwind
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
if (state === "focus" && focus) {
|
|
31
|
+
return {
|
|
32
|
+
backgroundColor: opacity(focus.bgColor, focus.opacity),
|
|
33
|
+
color: focus.textColor,
|
|
34
|
+
boxShadow: shadowSmTailwind
|
|
35
|
+
};
|
|
23
36
|
}
|
|
24
|
-
}, [hover]);
|
|
25
|
-
const handleOut = React.useCallback(() => {
|
|
26
37
|
if (normal) {
|
|
27
|
-
|
|
28
|
-
|
|
38
|
+
return {
|
|
39
|
+
backgroundColor: opacity(normal.bgColor, normal.opacity),
|
|
40
|
+
color: normal.textColor,
|
|
41
|
+
boxShadow: shadowSmTailwind
|
|
42
|
+
};
|
|
29
43
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}, [
|
|
44
|
+
return {};
|
|
45
|
+
}, [customStyles, state, normal, hover, focus]);
|
|
46
|
+
const handleOver = React.useCallback(() => {
|
|
47
|
+
if (hover) setState("hover");
|
|
48
|
+
}, [hover]);
|
|
49
|
+
const handleOut = React.useCallback(() => {
|
|
50
|
+
setState("normal");
|
|
51
|
+
}, []);
|
|
52
|
+
const handleFocus = React.useCallback(() => {
|
|
53
|
+
if (focus) setState("focus");
|
|
54
|
+
}, [focus]);
|
|
55
|
+
const handleBlur = React.useCallback(() => {
|
|
56
|
+
setState("normal");
|
|
57
|
+
}, []);
|
|
41
58
|
return /* @__PURE__ */ React.createElement(
|
|
42
59
|
SelectPrimitive.Trigger,
|
|
43
60
|
{
|
|
@@ -55,7 +72,7 @@ const SelectTrigger = React.forwardRef(({ className, children, customStyles, ...
|
|
|
55
72
|
onMouseOut: handleOut,
|
|
56
73
|
onFocus: handleFocus,
|
|
57
74
|
onBlur: handleBlur,
|
|
58
|
-
style:
|
|
75
|
+
style: getCurrentStyles(),
|
|
59
76
|
...props
|
|
60
77
|
},
|
|
61
78
|
children,
|
package/dist/index.d.ts
CHANGED
|
@@ -69,7 +69,7 @@ declare const AccordionContent: React$1.ForwardRefExoticComponent<Omit<Accordion
|
|
|
69
69
|
} & React$1.RefAttributes<HTMLDivElement>>;
|
|
70
70
|
|
|
71
71
|
declare const buttonVariants: (props?: ({
|
|
72
|
-
variant?: "
|
|
72
|
+
variant?: "ghost" | "filled" | "outlined" | "tonal" | null | undefined;
|
|
73
73
|
size?: "small" | "medium" | "large" | "extraLarge" | null | undefined;
|
|
74
74
|
color?: "blue" | "grey" | "destructive" | null | undefined;
|
|
75
75
|
iconButton?: boolean | null | undefined;
|
|
@@ -898,7 +898,7 @@ declare const RadioGroup: React$1.ForwardRefExoticComponent<Omit<RadioGroupPrimi
|
|
|
898
898
|
declare const RadioGroupItem: React$1.ForwardRefExoticComponent<Omit<RadioGroupPrimitive.RadioGroupItemProps & React$1.RefAttributes<HTMLButtonElement>, "ref"> & React$1.RefAttributes<HTMLButtonElement>>;
|
|
899
899
|
|
|
900
900
|
declare const ResizablePanelGroup: ({ className, ...props }: React$1.ComponentProps<typeof ResizablePrimitive.PanelGroup>) => React$1.JSX.Element;
|
|
901
|
-
declare const ResizablePanel: React$1.ForwardRefExoticComponent<Omit<React$1.HTMLAttributes<
|
|
901
|
+
declare const ResizablePanel: React$1.ForwardRefExoticComponent<Omit<React$1.HTMLAttributes<HTMLElement | HTMLOListElement | HTMLLIElement | HTMLAnchorElement | HTMLSpanElement | HTMLDivElement | HTMLButtonElement | HTMLLabelElement | HTMLParagraphElement | HTMLHeadingElement | HTMLInputElement | HTMLUListElement | HTMLObjectElement | HTMLAreaElement | HTMLAudioElement | HTMLBaseElement | HTMLQuoteElement | HTMLBodyElement | HTMLBRElement | HTMLCanvasElement | HTMLTableCaptionElement | HTMLTableColElement | HTMLDataElement | HTMLDataListElement | HTMLModElement | HTMLDetailsElement | HTMLDialogElement | HTMLDListElement | HTMLEmbedElement | HTMLFieldSetElement | HTMLFormElement | HTMLHeadElement | HTMLHRElement | HTMLHtmlElement | HTMLIFrameElement | HTMLImageElement | HTMLLegendElement | HTMLLinkElement | HTMLMapElement | HTMLMenuElement | HTMLMetaElement | HTMLMeterElement | HTMLOptGroupElement | HTMLOptionElement | HTMLOutputElement | HTMLPictureElement | HTMLPreElement | HTMLProgressElement | HTMLScriptElement | HTMLSelectElement | HTMLSlotElement | HTMLSourceElement | HTMLStyleElement | HTMLTableElement | HTMLTableSectionElement | HTMLTableCellElement | HTMLTemplateElement | HTMLTextAreaElement | HTMLTimeElement | HTMLTitleElement | HTMLTableRowElement | HTMLTrackElement | HTMLVideoElement>, "id" | "onResize"> & {
|
|
902
902
|
className?: string;
|
|
903
903
|
collapsedSize?: number | undefined;
|
|
904
904
|
collapsible?: boolean | undefined;
|