@rovula/ui 0.0.50 → 0.0.52

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 (48) hide show
  1. package/dist/cjs/bundle.css +6 -1
  2. package/dist/cjs/bundle.js +3 -3
  3. package/dist/cjs/bundle.js.map +1 -1
  4. package/dist/cjs/types/components/Tree/type.d.ts +20 -12
  5. package/dist/components/Tree/Tree.js +3 -2
  6. package/dist/components/Tree/Tree.stories.js +1 -1
  7. package/dist/components/Tree/TreeItem.js +16 -15
  8. package/dist/esm/bundle.css +6 -1
  9. package/dist/esm/bundle.js +1 -1
  10. package/dist/esm/bundle.js.map +1 -1
  11. package/dist/esm/types/components/Tree/type.d.ts +20 -12
  12. package/dist/index.d.ts +20 -12
  13. package/dist/src/theme/global.css +8 -1151
  14. package/dist/theme/global.css +0 -1
  15. package/package.json +1 -1
  16. package/src/components/Tree/Tree.stories.tsx +2 -1
  17. package/src/components/Tree/Tree.tsx +10 -1
  18. package/src/components/Tree/TreeItem.tsx +164 -108
  19. package/src/components/Tree/type.ts +23 -11
  20. package/src/theme/global.css +0 -1
  21. package/dist/theme/themes/SKL/baseline.css +0 -12
  22. package/dist/theme/themes/SKL/color.css +0 -78
  23. package/dist/theme/themes/SKL/components/action-button.css +0 -127
  24. package/dist/theme/themes/SKL/components/button.css +0 -512
  25. package/dist/theme/themes/SKL/components/dropdown-menu.css +0 -27
  26. package/dist/theme/themes/SKL/components/loading.css +0 -11
  27. package/dist/theme/themes/SKL/components/navbar.css +0 -8
  28. package/dist/theme/themes/SKL/components/progress-bar.css +0 -8
  29. package/dist/theme/themes/SKL/components/switch.css +0 -30
  30. package/dist/theme/themes/SKL/palette.css +0 -145
  31. package/dist/theme/themes/SKL/state.css +0 -86
  32. package/dist/theme/themes/SKL/transparent.css +0 -68
  33. package/dist/theme/themes/SKL/typography.css +0 -199
  34. package/dist/theme/themes/SKL/variables.css +0 -28
  35. package/src/theme/themes/SKL/baseline.css +0 -12
  36. package/src/theme/themes/SKL/color.css +0 -78
  37. package/src/theme/themes/SKL/components/action-button.css +0 -127
  38. package/src/theme/themes/SKL/components/button.css +0 -512
  39. package/src/theme/themes/SKL/components/dropdown-menu.css +0 -27
  40. package/src/theme/themes/SKL/components/loading.css +0 -11
  41. package/src/theme/themes/SKL/components/navbar.css +0 -8
  42. package/src/theme/themes/SKL/components/progress-bar.css +0 -8
  43. package/src/theme/themes/SKL/components/switch.css +0 -30
  44. package/src/theme/themes/SKL/palette.css +0 -145
  45. package/src/theme/themes/SKL/state.css +0 -86
  46. package/src/theme/themes/SKL/transparent.css +0 -68
  47. package/src/theme/themes/SKL/typography.css +0 -199
  48. package/src/theme/themes/SKL/variables.css +0 -28
@@ -19,6 +19,10 @@ export interface TreeItemProps extends TreeData {
19
19
  showIcon?: boolean;
20
20
  showExpandButton?: boolean;
21
21
  enableSeparatorLine?: boolean;
22
+ lineSize?: number;
23
+ horizontalLineWidth?: number;
24
+ expandButtonSize?: number;
25
+ spacing?: number;
22
26
  checkIsExpanded: (id: string) => boolean;
23
27
  checkIsChecked: (id: string) => boolean;
24
28
  checkIsLoading?: (id: string) => void;
@@ -49,20 +53,24 @@ export interface TreeItemProps extends TreeData {
49
53
  selected: boolean;
50
54
  }) => ReactNode;
51
55
  classes?: Partial<{
52
- elementWrapper: string;
53
- branch: string;
54
- itemWrapper: string;
55
- itemContainer: string;
56
- horizontalLine: string;
57
- expandButton: string;
58
- separatorLine: string;
59
- checkbox: string;
60
- item: string;
61
- title: string;
62
- childrenWrapper: string;
56
+ container?: string;
57
+ elementWrapper?: string;
58
+ branch?: string;
59
+ itemWrapper?: string;
60
+ itemContainer?: string;
61
+ horizontalLine?: string;
62
+ expandButton?: string;
63
+ separatorLine?: string;
64
+ checkbox?: string;
65
+ item?: string;
66
+ title?: string;
67
+ expandedChildrenWrapper?: string;
68
+ expandedChildrenWrapperInner?: string;
69
+ rowWrapperClasses?: string;
70
+ columnWrapperClasses?: string;
63
71
  }>;
64
72
  }
65
- export interface TreeProps extends Pick<TreeItemProps, "renderIcon" | "renderRightSection" | "renderElement" | "renderTitle" | "showIcon" | "disabled" | "enableSeparatorLine" | "classes"> {
73
+ export interface TreeProps extends Pick<TreeItemProps, "renderIcon" | "renderRightSection" | "renderElement" | "renderTitle" | "showIcon" | "disabled" | "enableSeparatorLine" | "classes" | "lineSize" | "horizontalLineWidth" | "expandButtonSize" | "spacing"> {
66
74
  data: TreeData[];
67
75
  defaultExpandedId?: string[];
68
76
  defaultCheckedId?: string[];
@@ -1,7 +1,8 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useCallback, useEffect, useState } from "react";
3
3
  import TreeItem from "./TreeItem";
4
- const Tree = ({ classes, data, defaultExpandedId, defaultCheckedId, checkedId, loadingId, renderIcon, renderRightSection, renderElement, renderTitle, onExpandChange, onCheckedChange, defaultExpandAll = false, defaultCheckAll = false, hierarchicalCheck = false, showIcon = true, disabled, enableSeparatorLine = true, }) => {
4
+ import { cn } from "@/utils/cn";
5
+ const Tree = ({ classes, data, defaultExpandedId, defaultCheckedId, checkedId, loadingId, lineSize, horizontalLineWidth, expandButtonSize, spacing, renderIcon, renderRightSection, renderElement, renderTitle, onExpandChange, onCheckedChange, defaultExpandAll = false, defaultCheckAll = false, hierarchicalCheck = false, showIcon = true, disabled, enableSeparatorLine = true, }) => {
5
6
  const [checkedState, setCheckedState] = useState({});
6
7
  const [expandedState, setExpandedState] = useState({});
7
8
  const traverseTree = (nodes, callback) => {
@@ -101,6 +102,6 @@ const Tree = ({ classes, data, defaultExpandedId, defaultCheckedId, checkedId, l
101
102
  return loadingId.includes(id);
102
103
  }
103
104
  }, [loadingId]);
104
- return (_jsx("div", { className: "w-full", children: data.map((item, idx) => (_jsx(TreeItem, Object.assign({ classes: classes, isFirstLevel: true, isLastItem: idx === data.length - 1, checkIsExpanded: checkIsExpanded, checkIsChecked: checkIsChecked, onExpandChange: handleExpandChange, onCheckedChange: handleCheckedChange, checkIsLoading: checkIsLoading, renderIcon: renderIcon, renderElement: renderElement, renderTitle: renderTitle, renderRightSection: renderRightSection, enableSeparatorLine: enableSeparatorLine, disabled: disabled, showIcon: showIcon }, item), item.id))) }));
105
+ return (_jsx("div", { className: cn("w-full", classes === null || classes === void 0 ? void 0 : classes.container), children: data.map((item, idx) => (_jsx(TreeItem, Object.assign({ classes: classes, isFirstLevel: true, isLastItem: idx === data.length - 1, checkIsExpanded: checkIsExpanded, checkIsChecked: checkIsChecked, onExpandChange: handleExpandChange, onCheckedChange: handleCheckedChange, checkIsLoading: checkIsLoading, renderIcon: renderIcon, renderElement: renderElement, renderTitle: renderTitle, renderRightSection: renderRightSection, enableSeparatorLine: enableSeparatorLine, disabled: disabled, showIcon: showIcon, lineSize: lineSize, horizontalLineWidth: horizontalLineWidth, expandButtonSize: expandButtonSize, spacing: spacing }, item), item.id))) }));
105
106
  };
106
107
  export default Tree;
@@ -5,7 +5,7 @@ import { ActionButton, Icon } from "@/index";
5
5
  const exampleData = [
6
6
  {
7
7
  id: "1",
8
- title: "Parent Folder 1",
8
+ title: "Parent Folder 1 Parent Folder 1 Parent Folder 1 Parent Folder 1 Parent Folder 1 Parent Folder 1 Parent Folder 1 Parent Folder 1",
9
9
  children: [
10
10
  {
11
11
  id: "1.1",
@@ -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, disabled, icon, showIcon, showExpandButton, enableSeparatorLine = true, isLastItem, checkIsExpanded, checkIsChecked, checkIsLoading, onExpandChange, onCheckedChange, onClickItem, renderIcon, renderElement, renderTitle, renderRightSection, }) => {
6
+ const TreeItem = ({ id, title, classes, children, isFirstLevel = false, disabled, icon, showIcon, showExpandButton, enableSeparatorLine = true, isLastItem, checkIsExpanded, checkIsChecked, checkIsLoading, onExpandChange, onCheckedChange, onClickItem, renderIcon, renderElement, renderTitle, renderRightSection, lineSize = 2, horizontalLineWidth = 4, expandButtonSize = 30, spacing = 2, }) => {
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]);
@@ -12,26 +12,17 @@ const TreeItem = ({ id, title, classes, children, isFirstLevel = false, disabled
12
12
  const handleExpandToggle = useCallback(() => {
13
13
  onExpandChange === null || onExpandChange === void 0 ? void 0 : onExpandChange(id, !isExpanded);
14
14
  }, [id, isExpanded, onExpandChange]);
15
- // TODO move to props
16
- const lineSize = 2;
17
- const horizontalLineWidth = 4;
18
- const expandButtonSize = 30;
19
- const spacing = 2;
20
- const styles = {
15
+ const styles = useMemo(() => ({
21
16
  branch: {
22
- height: isLastItem && !(isExpanded && hasChildren)
23
- ? `calc(50% + ${lineSize}px)`
24
- : `calc(100% + ${lineSize}px)`,
25
17
  width: lineSize,
26
- marginTop: -lineSize,
27
- borderBottomLeftRadius: lineSize / 2,
18
+ borderBottomLeftRadius: isLastItem ? lineSize / 2 : 0,
28
19
  },
29
20
  horizontalLine: {
30
21
  height: lineSize,
31
22
  width: lineSize +
32
23
  horizontalLineWidth +
33
24
  (shouldExpandButton ? 0 : expandButtonSize + spacing),
34
- marginLeft: -lineSize + 0.1,
25
+ marginLeft: -lineSize,
35
26
  borderBottomLeftRadius: lineSize / 2,
36
27
  },
37
28
  expandButton: {
@@ -43,7 +34,15 @@ const TreeItem = ({ id, title, classes, children, isFirstLevel = false, disabled
43
34
  ? expandButtonSize / 2 - lineSize / 2
44
35
  : expandButtonSize / 2 + horizontalLineWidth - lineSize / 2,
45
36
  },
46
- };
37
+ }), [
38
+ lineSize,
39
+ horizontalLineWidth,
40
+ expandButtonSize,
41
+ spacing,
42
+ isFirstLevel,
43
+ isLastItem,
44
+ shouldExpandButton,
45
+ ]);
47
46
  useEffect(() => {
48
47
  if (isExpanded && !isLoading && !hasChildren) {
49
48
  handleExpandToggle();
@@ -76,6 +75,8 @@ const TreeItem = ({ id, title, classes, children, isFirstLevel = false, disabled
76
75
  onClick: handleOnClickItem,
77
76
  })
78
77
  : content;
79
- return elementWrapper(_jsxs("div", { className: cn("flex flex-row w-full ", classes === null || classes === void 0 ? void 0 : classes.elementWrapper), children: [_jsx("div", { className: cn("bg-grey-150", classes === null || classes === void 0 ? void 0 : classes.branch), style: styles.branch }), _jsxs("div", { className: cn("flex flex-col w-full", classes === null || classes === void 0 ? void 0 : classes.itemWrapper), children: [_jsxs("div", { className: cn("flex 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" })) }) })), _jsx(Checkbox, { id: id, className: cn("size-[16pt]", 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) }), _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 && (_jsx("div", { className: cn("flex flex-col", classes === null || classes === void 0 ? void 0 : classes.childrenWrapper), 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, checkIsLoading: checkIsLoading, onExpandChange: onExpandChange, onCheckedChange: onCheckedChange, renderIcon: renderIcon, renderElement: renderElement, renderTitle: renderTitle, disabled: disabled, showIcon: showIcon }, 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) }))] })] }));
78
+ return elementWrapper(_jsx("div", { className: cn("flex flex-row w-full", classes === null || classes === void 0 ? void 0 : classes.elementWrapper), children: _jsxs("div", { className: cn("flex flex-col w-full", classes === null || classes === void 0 ? void 0 : classes.itemWrapper), children: [_jsxs("div", { className: cn("flex flex-row flex-1", classes === null || classes === void 0 ? void 0 : classes.rowWrapperClasses), children: [_jsxs("div", { className: cn("flex flex-col h-full", classes === null || classes === void 0 ? void 0 : classes.columnWrapperClasses), children: [!isFirstLevel && (_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 })), !isFirstLevel &&
79
+ !isLastItem &&
80
+ ((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" })) }) })), _jsx(Checkbox, { id: id, className: cn("size-[16pt]", 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) }), _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 && (_jsxs("div", { className: cn("flex flex-row overflow-hidden max-h-screen", 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 max-h-screen", 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, checkIsLoading: checkIsLoading, onExpandChange: onExpandChange, onCheckedChange: onCheckedChange, renderIcon: renderIcon, renderElement: renderElement, renderTitle: renderTitle, disabled: disabled, showIcon: showIcon, lineSize: lineSize, horizontalLineWidth: horizontalLineWidth, expandButtonSize: expandButtonSize, spacing: spacing }, 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) }))] }) }));
80
81
  };
81
82
  export default TreeItem;
@@ -1,7 +1,6 @@
1
1
 
2
2
  @import "./tokens/baseline.css";
3
3
  @import "./themes/xspector/baseline.css";
4
- @import "./themes/SKL/baseline.css";
5
4
 
6
5
  /*
7
6
  ! tailwindcss v3.4.3 | MIT License | https://tailwindcss.com
@@ -796,6 +795,9 @@ input[type=number] {
796
795
  width: 100%;
797
796
  height: 100%;
798
797
  }
798
+ .h-1\/2{
799
+ height: 50%;
800
+ }
799
801
  .h-10{
800
802
  height: 2.5rem;
801
803
  }
@@ -905,6 +907,9 @@ input[type=number] {
905
907
  .w-\[24px\]{
906
908
  width: 24px;
907
909
  }
910
+ .w-\[2px\]{
911
+ width: 2px;
912
+ }
908
913
  .w-\[32px\]{
909
914
  width: 32px;
910
915
  }