@rovula/ui 0.0.57 → 0.0.59
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.
- package/dist/cjs/bundle.js +3 -3
- package/dist/cjs/bundle.js.map +1 -1
- package/dist/cjs/types/components/Tree/type.d.ts +7 -6
- package/dist/components/Tabs/Tabs.js +43 -36
- package/dist/components/Tabs/Tabs.stories.js +38 -2
- package/dist/components/Tree/Tree.js +28 -4
- package/dist/components/Tree/Tree.stories.js +1 -1
- package/dist/components/Tree/TreeItem.js +7 -7
- package/dist/esm/bundle.js +2 -2
- package/dist/esm/bundle.js.map +1 -1
- package/dist/esm/types/components/Tree/type.d.ts +7 -6
- package/dist/index.d.ts +7 -6
- package/package.json +1 -1
- package/src/components/Tabs/Tabs.stories.tsx +60 -3
- package/src/components/Tabs/Tabs.tsx +43 -38
- package/src/components/Tree/Tree.stories.tsx +1 -0
- package/src/components/Tree/Tree.tsx +35 -4
- package/src/components/Tree/TreeItem.tsx +8 -7
- package/src/components/Tree/type.ts +10 -6
|
@@ -5,7 +5,8 @@ export type TreeData<T = {}> = {
|
|
|
5
5
|
icon?: ReactNode;
|
|
6
6
|
disabled?: boolean;
|
|
7
7
|
isLeaf?: boolean;
|
|
8
|
-
|
|
8
|
+
itemData?: any;
|
|
9
|
+
onClickItem?: (id: string, itemData?: any) => void;
|
|
9
10
|
children?: TreeData<T>[];
|
|
10
11
|
renderIcon?: (params: {
|
|
11
12
|
id: string;
|
|
@@ -31,9 +32,9 @@ export interface TreeItemProps extends TreeData {
|
|
|
31
32
|
checkIsChecked: (id: string) => boolean;
|
|
32
33
|
checkAutoDisabled: (id: string) => boolean;
|
|
33
34
|
checkIsLoading?: (id: string) => void;
|
|
34
|
-
onExpandChange?: (id: string, expanded: boolean) => void;
|
|
35
|
+
onExpandChange?: (id: string, expanded: boolean, itemData: any) => void;
|
|
35
36
|
onCheckedChange?: (id: string, checked: boolean) => void;
|
|
36
|
-
notifyClickItem?: (id: string) => void;
|
|
37
|
+
notifyClickItem?: (id: string, itemData: any) => void;
|
|
37
38
|
renderRightSection?: (params: {
|
|
38
39
|
id: string;
|
|
39
40
|
expanded: boolean;
|
|
@@ -82,9 +83,9 @@ export interface TreeProps extends Pick<TreeItemProps, "renderIcon" | "renderRig
|
|
|
82
83
|
defaultCheckedId?: string[];
|
|
83
84
|
checkedId?: string[];
|
|
84
85
|
loadingId?: string[];
|
|
85
|
-
onExpandChange?: (id: string, expanded: boolean) => void;
|
|
86
|
-
onCheckedChange?: (checkedState: Record<string, boolean
|
|
87
|
-
onClickItem?: (id: string) => void;
|
|
86
|
+
onExpandChange?: (id: string, expanded: boolean, itemData: any) => void;
|
|
87
|
+
onCheckedChange?: (checkedState: Record<string, boolean>, id?: string) => void;
|
|
88
|
+
onClickItem?: (id: string, itemData: any) => void;
|
|
88
89
|
onCheckedItem?: (id: string, checked: boolean) => void;
|
|
89
90
|
defaultExpandAll?: boolean;
|
|
90
91
|
defaultCheckAll?: boolean;
|
|
@@ -6,7 +6,7 @@ import ActionButton from "../ActionButton/ActionButton";
|
|
|
6
6
|
import Icon from "../Icon/Icon";
|
|
7
7
|
import { Loading } from "@/index";
|
|
8
8
|
const Tabs = ({ tabs = [], value, initialTab = 0, tabBarSize = 38, enableBorderLine = true, enableAddTabButton = false, keepIconSpace = true, disabled = false, tabMode = "start", className, tabBarClassName, tabBarContainerClassName, tabBarWrapperClassName, tabButtonClassName, tabButtonActiveClassName, tabContentClassName, addTabButtonWrapperClassName, borderSliderClassName, leftAction, rightAction, onAddTab, onTabChange, }) => {
|
|
9
|
-
var _a
|
|
9
|
+
var _a;
|
|
10
10
|
const [activeTab, setActiveTab] = useState(initialTab);
|
|
11
11
|
const [sliderStyle, setSliderStyle] = useState({
|
|
12
12
|
width: "0px",
|
|
@@ -19,40 +19,47 @@ const Tabs = ({ tabs = [], value, initialTab = 0, tabBarSize = 38, enableBorderL
|
|
|
19
19
|
setActiveTab(value);
|
|
20
20
|
}
|
|
21
21
|
}, [value]);
|
|
22
|
-
const updateSliderStyle = () => {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
};
|
|
31
|
-
useEffect(() => {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
22
|
+
// const updateSliderStyle = () => {
|
|
23
|
+
// const activeTabElement = tabRefs.current[activeTab];
|
|
24
|
+
// if (activeTabElement) {
|
|
25
|
+
// setSliderStyle({
|
|
26
|
+
// width: `${activeTabElement.offsetWidth}px`,
|
|
27
|
+
// transform: `translateX(${activeTabElement.offsetLeft}px)`,
|
|
28
|
+
// });
|
|
29
|
+
// }
|
|
30
|
+
// };
|
|
31
|
+
// useEffect(() => {
|
|
32
|
+
// let timer: NodeJS.Timeout;
|
|
33
|
+
// if (isInitialMount.current) {
|
|
34
|
+
// isInitialMount.current = false;
|
|
35
|
+
// // Set initial position without animation
|
|
36
|
+
// const activeTabElement = tabRefs.current[activeTab];
|
|
37
|
+
// if (activeTabElement) {
|
|
38
|
+
// setSliderStyle({
|
|
39
|
+
// width: "0px",
|
|
40
|
+
// transform: `translateX(${
|
|
41
|
+
// activeTabElement.offsetLeft + activeTabElement.offsetWidth / 2
|
|
42
|
+
// }px)`,
|
|
43
|
+
// });
|
|
44
|
+
// // Trigger reflow
|
|
45
|
+
// timer = setTimeout(() => {
|
|
46
|
+
// updateSliderStyle();
|
|
47
|
+
// }, 50);
|
|
48
|
+
// }
|
|
49
|
+
// } else {
|
|
50
|
+
// updateSliderStyle();
|
|
51
|
+
// }
|
|
52
|
+
// const handleResize = () => {
|
|
53
|
+
// updateSliderStyle();
|
|
54
|
+
// };
|
|
55
|
+
// window.addEventListener("resize", handleResize);
|
|
56
|
+
// return () => {
|
|
57
|
+
// window.removeEventListener("resize", handleResize);
|
|
58
|
+
// if (timer) {
|
|
59
|
+
// clearTimeout(timer);
|
|
60
|
+
// }
|
|
61
|
+
// };
|
|
62
|
+
// }, [activeTab, tabs, tabMode, keepIconSpace]);
|
|
56
63
|
return (_jsxs("div", { className: cn("w-full", className), children: [_jsxs("div", { className: cn(" relative flex flex-row w-full", {
|
|
57
64
|
[`border-b-[1px] border-base-stroke`]: enableBorderLine,
|
|
58
65
|
"border-state-disable-outline": disabled,
|
|
@@ -77,6 +84,6 @@ const Tabs = ({ tabs = [], value, initialTab = 0, tabBarSize = 38, enableBorderL
|
|
|
77
84
|
onTabChange === null || onTabChange === void 0 ? void 0 : onTabChange(index);
|
|
78
85
|
}, children: [(keepIconSpace || tab.startTabContent) && (_jsx("div", { className: "h-full w-3 flex items-center justify-center", children: tab.isLoading ? _jsx(Loading, {}) : tab.startTabContent })), tab.label, (keepIconSpace || tab.endTabContent) && (_jsx("div", { className: "h-full w-3 flex items-center justify-center", children: tab.endTabContent }))] }, index))), _jsx("div", { className: cn(`absolute left-0 bottom-0 h-[2px] rounded-full bg-foreground transition-all duration-300 ease-in-out`, {
|
|
79
86
|
"bg-state-disable-solid": disabled,
|
|
80
|
-
}, borderSliderClassName), style: sliderStyle })] }) }), enableAddTabButton && (_jsx("div", { className: cn("sticky right-0 flex content-center items-center mx-4", addTabButtonWrapperClassName), children: _jsx(ActionButton, { variant: "outline", size: "sm", onClick: () => onAddTab === null || onAddTab === void 0 ? void 0 : onAddTab(), disabled: disabled, children: _jsx(Icon, { name: "plus" }) }) })), rightAction] }), _jsx("div", { className: cn("mt-4 text-foreground", tabContentClassName), role: "tabpanel", id: `tab-content-${activeTab}`, "aria-labelledby": `tab-${activeTab}`, children:
|
|
87
|
+
}, borderSliderClassName), style: sliderStyle })] }) }), enableAddTabButton && (_jsx("div", { className: cn("sticky right-0 flex content-center items-center mx-4", addTabButtonWrapperClassName), children: _jsx(ActionButton, { variant: "outline", size: "sm", onClick: () => onAddTab === null || onAddTab === void 0 ? void 0 : onAddTab(), disabled: disabled, children: _jsx(Icon, { name: "plus" }) }) })), rightAction] }), _jsx("div", { className: cn("mt-4 text-foreground", tabContentClassName), role: "tabpanel", id: `tab-content-${activeTab}`, "aria-labelledby": `tab-${activeTab}`, children: (_a = tabs[activeTab]) === null || _a === void 0 ? void 0 : _a.content })] }));
|
|
81
88
|
};
|
|
82
89
|
export default Tabs;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect } from "react";
|
|
2
3
|
import Tabs from "./Tabs";
|
|
3
4
|
import { ChevronDownIcon, ArchiveBoxIcon } from "@heroicons/react/16/solid";
|
|
4
5
|
import ActionButton from "../ActionButton/ActionButton";
|
|
5
6
|
import Icon from "../Icon/Icon";
|
|
6
7
|
import { useArgs } from "@storybook/preview-api";
|
|
7
|
-
import { Button } from "@/index";
|
|
8
|
+
import { Button, Tree } from "@/index";
|
|
9
|
+
import { exampleData } from "../Tree/example-data";
|
|
8
10
|
const meta = {
|
|
9
11
|
title: "Components/Tabs",
|
|
10
12
|
component: Tabs,
|
|
@@ -115,11 +117,45 @@ export const Disabled = {
|
|
|
115
117
|
return (_jsxs("div", { className: "flex flex-row gap-4", children: [_jsx(Tabs, Object.assign({ tabs: tabs }, props)), _jsx(Tabs, Object.assign({ tabs: tabs }, props, { disabled: true }))] }));
|
|
116
118
|
},
|
|
117
119
|
};
|
|
120
|
+
const TabContent = ({ tab }) => {
|
|
121
|
+
useEffect(() => {
|
|
122
|
+
console.log("tab ", tab, " Mount");
|
|
123
|
+
return () => {
|
|
124
|
+
console.log("tab ", tab, " DidMount");
|
|
125
|
+
};
|
|
126
|
+
}, [tab]);
|
|
127
|
+
return (_jsxs("div", { children: [_jsxs("p", { children: ["Tab ", tab, " content"] }), _jsx("input", {}), _jsx(Tree, { data: exampleData })] }));
|
|
128
|
+
};
|
|
118
129
|
export const Controller = {
|
|
119
130
|
args: {
|
|
120
131
|
initialTab: 1,
|
|
121
132
|
value: 0,
|
|
122
|
-
tabs
|
|
133
|
+
tabs: [
|
|
134
|
+
// {
|
|
135
|
+
// label: "Tab1",
|
|
136
|
+
// content: <TabContent tab={1} />,
|
|
137
|
+
// },
|
|
138
|
+
// {
|
|
139
|
+
// label: "Tab2",
|
|
140
|
+
// content: <TabContent tab={2} />,
|
|
141
|
+
// },
|
|
142
|
+
// {
|
|
143
|
+
// label: "Tab3",
|
|
144
|
+
// content: <TabContent tab={3} />,
|
|
145
|
+
// },
|
|
146
|
+
{
|
|
147
|
+
label: "Tab1",
|
|
148
|
+
content: (_jsxs("div", { children: ["fdfsdfdsfsdf ", _jsx("input", {})] }, `tab-content-key-1`)),
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
label: "Tab2",
|
|
152
|
+
content: (_jsxs("div", { children: ["fdfsdfdsfsdf ", _jsx("input", {})] }, `tab-content-key-2`)),
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
label: "Tab3",
|
|
156
|
+
content: (_jsxs("div", { children: ["fdfsdfdsfsdf ", _jsx("input", {})] }, `tab-content-key-3`)),
|
|
157
|
+
},
|
|
158
|
+
],
|
|
123
159
|
enableAddTabButton: true,
|
|
124
160
|
},
|
|
125
161
|
render: (args) => {
|
|
@@ -52,8 +52,32 @@ const Tree = ({ classes, data, defaultExpandedId, defaultCheckedId, checkedId, l
|
|
|
52
52
|
setCheckedState(checkedId.reduce((prev, cur) => (Object.assign(Object.assign({}, prev), { [cur]: true })), {}));
|
|
53
53
|
}
|
|
54
54
|
}, [checkedId]);
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
if (!hierarchicalCheck) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const state = {};
|
|
60
|
+
const updateChildren = (parentId, isChecked) => {
|
|
61
|
+
traverseTree(data, (node) => {
|
|
62
|
+
if (node.id === parentId && node.children) {
|
|
63
|
+
node.children.forEach((child) => {
|
|
64
|
+
state[child.id] = isChecked;
|
|
65
|
+
updateChildren(child.id, isChecked);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
setCheckedState((prev) => {
|
|
71
|
+
Object.keys(prev)
|
|
72
|
+
.filter((key) => prev[key])
|
|
73
|
+
.map((id) => {
|
|
74
|
+
updateChildren(id, true);
|
|
75
|
+
});
|
|
76
|
+
return Object.assign(Object.assign({}, prev), state);
|
|
77
|
+
});
|
|
78
|
+
}, [data, hierarchicalCheck]);
|
|
79
|
+
const handleExpandChange = useCallback((id, expanded, itemData) => {
|
|
80
|
+
onExpandChange === null || onExpandChange === void 0 ? void 0 : onExpandChange(id, expanded, itemData);
|
|
57
81
|
setExpandedState((prev) => (Object.assign(Object.assign({}, prev), { [id]: expanded })));
|
|
58
82
|
}, [onExpandChange]);
|
|
59
83
|
const handleCheckedChange = useCallback((id, checked) => {
|
|
@@ -61,7 +85,7 @@ const Tree = ({ classes, data, defaultExpandedId, defaultCheckedId, checkedId, l
|
|
|
61
85
|
let newState = { [id]: checked };
|
|
62
86
|
onCheckedItem === null || onCheckedItem === void 0 ? void 0 : onCheckedItem(id, checked);
|
|
63
87
|
setCheckedState(newState);
|
|
64
|
-
onCheckedChange === null || onCheckedChange === void 0 ? void 0 : onCheckedChange(newState);
|
|
88
|
+
onCheckedChange === null || onCheckedChange === void 0 ? void 0 : onCheckedChange(newState, id);
|
|
65
89
|
return;
|
|
66
90
|
}
|
|
67
91
|
onCheckedItem === null || onCheckedItem === void 0 ? void 0 : onCheckedItem(id, checked);
|
|
@@ -99,7 +123,7 @@ const Tree = ({ classes, data, defaultExpandedId, defaultCheckedId, checkedId, l
|
|
|
99
123
|
}
|
|
100
124
|
setCheckedState(newState);
|
|
101
125
|
if (onCheckedChange) {
|
|
102
|
-
onCheckedChange === null || onCheckedChange === void 0 ? void 0 : onCheckedChange(newState);
|
|
126
|
+
onCheckedChange === null || onCheckedChange === void 0 ? void 0 : onCheckedChange(newState, id);
|
|
103
127
|
}
|
|
104
128
|
}, [
|
|
105
129
|
checkedState,
|
|
@@ -168,7 +168,7 @@ export const ExpandLoadData = {
|
|
|
168
168
|
}, 1500);
|
|
169
169
|
}
|
|
170
170
|
};
|
|
171
|
-
return (_jsx("div", { className: "flex flex-row gap-4 w-full", children: _jsx(Tree, Object.assign({}, args, { data: data, loadingId: loadingId, onExpandChange: handleOnExpandChange })) }));
|
|
171
|
+
return (_jsx("div", { className: "flex flex-row gap-4 w-full", children: _jsx(Tree, Object.assign({}, args, { data: data, loadingId: loadingId, hierarchicalCheck: true, onExpandChange: handleOnExpandChange })) }));
|
|
172
172
|
},
|
|
173
173
|
};
|
|
174
174
|
export const MaximumLevel = {
|
|
@@ -3,7 +3,7 @@ import { ActionButton, Checkbox, Loading } from "@/index";
|
|
|
3
3
|
import { cn } from "@/utils/cn";
|
|
4
4
|
import { useCallback, useEffect, useMemo } from "react";
|
|
5
5
|
import Icon from "../Icon/Icon";
|
|
6
|
-
const TreeItem = ({ id, title, classes, children, isFirstLevel = false, isLeaf = false, disabled, icon, showIcon, showExpandButton, enableSeparatorLine = true, isLastItem, checkable, checkIsExpanded, checkIsChecked, checkAutoDisabled, checkIsLoading, onExpandChange, onCheckedChange, onClickItem, renderIcon, renderElement, renderTitle, renderRightSection, lineSize = 2, horizontalLineWidth = 4, expandButtonSize = 30, spacing = 2, currentLevel = 1, maxLevel = 10, notifyClickItem, }) => {
|
|
6
|
+
const TreeItem = ({ id, title, classes, children, isFirstLevel = false, isLeaf = false, disabled, icon, showIcon, showExpandButton, enableSeparatorLine = true, isLastItem, checkable, checkIsExpanded, checkIsChecked, checkAutoDisabled, checkIsLoading, onExpandChange, onCheckedChange, onClickItem, renderIcon, renderElement, renderTitle, renderRightSection, lineSize = 2, horizontalLineWidth = 4, expandButtonSize = 30, spacing = 2, currentLevel = 1, maxLevel = 10, notifyClickItem, itemData, }) => {
|
|
7
7
|
const isLoading = useMemo(() => checkIsLoading === null || checkIsLoading === void 0 ? void 0 : checkIsLoading(id), [checkIsLoading, id]);
|
|
8
8
|
const isChecked = useMemo(() => checkIsChecked(id), [checkIsChecked, id]);
|
|
9
9
|
const isExpanded = useMemo(() => checkIsExpanded(id), [checkIsExpanded, id]);
|
|
@@ -46,17 +46,17 @@ const TreeItem = ({ id, title, classes, children, isFirstLevel = false, isLeaf =
|
|
|
46
46
|
checkboxSpace,
|
|
47
47
|
]);
|
|
48
48
|
const handleExpandToggle = useCallback(() => {
|
|
49
|
-
onExpandChange === null || onExpandChange === void 0 ? void 0 : onExpandChange(id, !isExpanded);
|
|
50
|
-
}, [id, isExpanded, onExpandChange]);
|
|
49
|
+
onExpandChange === null || onExpandChange === void 0 ? void 0 : onExpandChange(id, !isExpanded, itemData);
|
|
50
|
+
}, [id, isExpanded, onExpandChange, itemData]);
|
|
51
51
|
useEffect(() => {
|
|
52
52
|
if (isExpanded && !isLoading && !hasChildren) {
|
|
53
53
|
handleExpandToggle();
|
|
54
54
|
}
|
|
55
55
|
}, [isLoading, handleExpandToggle]);
|
|
56
56
|
const handleOnClickItem = useCallback(() => {
|
|
57
|
-
onClickItem === null || onClickItem === void 0 ? void 0 : onClickItem(id);
|
|
58
|
-
notifyClickItem === null || notifyClickItem === void 0 ? void 0 : notifyClickItem(id);
|
|
59
|
-
}, [onClickItem, notifyClickItem,
|
|
57
|
+
onClickItem === null || onClickItem === void 0 ? void 0 : onClickItem(id, itemData);
|
|
58
|
+
notifyClickItem === null || notifyClickItem === void 0 ? void 0 : notifyClickItem(id, itemData);
|
|
59
|
+
}, [id, isExpanded, onClickItem, notifyClickItem, itemData]);
|
|
60
60
|
const defaultIcon = (_jsx(Icon, { name: isExpanded ? "folder-open" : "folder", className: "fill-warning size-[18px]" }));
|
|
61
61
|
const customIcon = icon !== null && icon !== void 0 ? icon : renderIcon === null || renderIcon === void 0 ? void 0 : renderIcon({
|
|
62
62
|
id,
|
|
@@ -85,6 +85,6 @@ const TreeItem = ({ id, title, classes, children, isFirstLevel = false, isLeaf =
|
|
|
85
85
|
!isLastItem &&
|
|
86
86
|
((isExpanded && (hasChildren || isLoading)) || !isExpanded) && (_jsx("div", { className: cn("flex w-[2px] h-1/2 bg-grey-150", classes === null || classes === void 0 ? void 0 : classes.branch), style: styles.branch }))] }), _jsxs("div", { className: cn("flex flex-1 items-center py-2 min-h-10", classes === null || classes === void 0 ? void 0 : classes.itemContainer), children: [!isFirstLevel && (_jsx("div", { className: cn("bg-grey-150", classes === null || classes === void 0 ? void 0 : classes.horizontalLine), style: styles.horizontalLine })), isFirstLevel && !shouldExpandButton && (_jsx("div", { className: cn("flex mr-[2px]", classes === null || classes === void 0 ? void 0 : classes.expandButton), style: styles.expandButton })), shouldExpandButton && (_jsx("div", { className: cn("flex mr-[2px]", classes === null || classes === void 0 ? void 0 : classes.expandButton), style: styles.expandButton, onClick: !isLoading && handleExpandToggle, children: _jsx(ActionButton, { variant: "icon", size: "sm", children: isLoading ? (_jsx(Loading, {})) : (_jsx(Icon, { name: isExpanded ? "chevron-down" : "chevron-right" })) }) })), shouldShowCheckbox ? (_jsx(Checkbox, { id: id, className: cn("size-[16px]", classes === null || classes === void 0 ? void 0 : classes.checkbox), checked: isChecked, disabled: disabled, onCheckedChange: (newChecked) => onCheckedChange === null || onCheckedChange === void 0 ? void 0 : onCheckedChange(id, newChecked) })) : (_jsx("div", { className: isFirstLevel && checkable
|
|
87
87
|
? cn("size-[16px]", classes === null || classes === void 0 ? void 0 : classes.checkbox)
|
|
88
|
-
: "" })), _jsxs("div", { className: cn("ml-2 gap-1 flex flex-1 items-center text-foreground", classes === null || classes === void 0 ? void 0 : classes.item), onClick: handleOnClickItem, children: [showIcon ? customIcon || defaultIcon : null, _jsx("div", { className: cn("flex flex-1 cursor-pointer text-subtitle5 text-ellipsis", classes === null || classes === void 0 ? void 0 : classes.title), children: titleContent })] }), rightIcon] })] }), isExpanded && hasChildren && currentLevel < (maxLevel || Infinity) && (_jsxs("div", { className: cn("flex flex-row overflow-hidden
|
|
88
|
+
: "" })), _jsxs("div", { className: cn("ml-2 gap-1 flex flex-1 items-center text-foreground", classes === null || classes === void 0 ? void 0 : classes.item), onClick: handleOnClickItem, children: [showIcon ? customIcon || defaultIcon : null, _jsx("div", { className: cn("flex flex-1 cursor-pointer text-subtitle5 text-ellipsis", classes === null || classes === void 0 ? void 0 : classes.title), children: titleContent })] }), rightIcon] })] }), isExpanded && hasChildren && currentLevel < (maxLevel || Infinity) && (_jsxs("div", { className: cn("flex flex-row overflow-hidden", classes === null || classes === void 0 ? void 0 : classes.expandedChildrenWrapper), children: [!isFirstLevel && !isLastItem && (_jsx("div", { className: cn("flex w-[2px] h-full bg-grey-150", classes === null || classes === void 0 ? void 0 : classes.branch), style: styles.branch })), _jsx("div", { className: cn("flex flex-col overflow-hidden", classes === null || classes === void 0 ? void 0 : classes.expandedChildrenWrapperInner), style: styles.childPadding, children: children === null || children === void 0 ? void 0 : children.map((child, idx) => (_jsx(TreeItem, Object.assign({ classes: classes, isLastItem: idx === children.length - 1, checkIsExpanded: checkIsExpanded, checkIsChecked: checkIsChecked, checkAutoDisabled: checkAutoDisabled, checkIsLoading: checkIsLoading, onExpandChange: onExpandChange, onCheckedChange: onCheckedChange, renderIcon: renderIcon, renderElement: renderElement, renderTitle: renderTitle, disabled: checkAutoDisabled(child.id), showIcon: showIcon, lineSize: lineSize, horizontalLineWidth: horizontalLineWidth, expandButtonSize: expandButtonSize, spacing: spacing, notifyClickItem: notifyClickItem, maxLevel: maxLevel, currentLevel: currentLevel + 1, checkable: checkable }, child), child.id))) })] })), enableSeparatorLine && isFirstLevel && !isLastItem && (_jsx("div", { className: cn("bg-grey-150 w-full h-[2px] rounded", classes === null || classes === void 0 ? void 0 : classes.separatorLine) }))] }) }));
|
|
89
89
|
};
|
|
90
90
|
export default TreeItem;
|