@rovula/ui 0.0.46 → 0.0.48
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.css +49 -28
- package/dist/cjs/bundle.js +3 -3
- package/dist/cjs/bundle.js.map +1 -1
- package/dist/cjs/types/components/Switch/Switch.stories.d.ts +1 -6
- package/dist/cjs/types/components/Table/Table.d.ts +1 -0
- package/dist/cjs/types/components/Table/Table.stories.d.ts +2 -0
- package/dist/cjs/types/components/Tree/Tree.d.ts +45 -0
- package/dist/cjs/types/components/Tree/Tree.stories.d.ts +5 -0
- package/dist/components/Switch/Switch.js +15 -1
- package/dist/components/Switch/Switch.stories.js +2 -7
- package/dist/components/Table/Table.js +2 -2
- package/dist/components/Tree/Tree.js +138 -0
- package/dist/components/Tree/Tree.stories.js +53 -0
- package/dist/esm/bundle.css +49 -28
- package/dist/esm/bundle.js +2 -2
- package/dist/esm/bundle.js.map +1 -1
- package/dist/esm/types/components/Switch/Switch.stories.d.ts +1 -6
- package/dist/esm/types/components/Table/Table.d.ts +1 -0
- package/dist/esm/types/components/Table/Table.stories.d.ts +2 -0
- package/dist/esm/types/components/Tree/Tree.d.ts +45 -0
- package/dist/esm/types/components/Tree/Tree.stories.d.ts +5 -0
- package/dist/index.d.ts +1 -0
- package/dist/src/theme/global.css +1264 -37
- package/dist/theme/global.css +1 -0
- package/dist/theme/themes/SKL/baseline.css +12 -0
- package/dist/theme/themes/SKL/color.css +78 -0
- package/dist/theme/themes/SKL/components/action-button.css +127 -0
- package/dist/theme/themes/SKL/components/button.css +512 -0
- package/dist/theme/themes/SKL/components/dropdown-menu.css +27 -0
- package/dist/theme/themes/SKL/components/loading.css +11 -0
- package/dist/theme/themes/SKL/components/navbar.css +8 -0
- package/dist/theme/themes/SKL/components/progress-bar.css +8 -0
- package/dist/theme/themes/SKL/components/switch.css +30 -0
- package/dist/theme/themes/SKL/palette.css +145 -0
- package/dist/theme/themes/SKL/state.css +86 -0
- package/dist/theme/themes/SKL/transparent.css +68 -0
- package/dist/theme/themes/SKL/typography.css +199 -0
- package/dist/theme/themes/SKL/variables.css +28 -0
- package/dist/theme/themes/xspector/baseline.css +1 -0
- package/dist/theme/themes/xspector/components/switch.css +30 -0
- package/dist/theme/tokens/baseline.css +2 -1
- package/dist/theme/tokens/components/switch.css +30 -0
- package/package.json +1 -1
- package/src/components/Switch/Switch.stories.tsx +2 -7
- package/src/components/Switch/Switch.tsx +37 -9
- package/src/components/Table/Table.tsx +7 -2
- package/src/components/Tree/Tree.stories.tsx +66 -0
- package/src/components/Tree/Tree.tsx +331 -0
- package/src/theme/global.css +1 -0
- package/src/theme/themes/SKL/baseline.css +12 -0
- package/src/theme/themes/SKL/color.css +78 -0
- package/src/theme/themes/SKL/components/action-button.css +127 -0
- package/src/theme/themes/SKL/components/button.css +512 -0
- package/src/theme/themes/SKL/components/dropdown-menu.css +27 -0
- package/src/theme/themes/SKL/components/loading.css +11 -0
- package/src/theme/themes/SKL/components/navbar.css +8 -0
- package/src/theme/themes/SKL/components/progress-bar.css +8 -0
- package/src/theme/themes/SKL/components/switch.css +30 -0
- package/src/theme/themes/SKL/palette.css +145 -0
- package/src/theme/themes/SKL/state.css +86 -0
- package/src/theme/themes/SKL/transparent.css +68 -0
- package/src/theme/themes/SKL/typography.css +199 -0
- package/src/theme/themes/SKL/variables.css +28 -0
- package/src/theme/themes/xspector/baseline.css +1 -0
- package/src/theme/themes/xspector/components/switch.css +30 -0
- package/src/theme/tokens/baseline.css +2 -1
- package/src/theme/tokens/components/switch.css +30 -0
|
@@ -293,13 +293,8 @@ declare const meta: {
|
|
|
293
293
|
export default meta;
|
|
294
294
|
export declare const Default: {
|
|
295
295
|
args: {
|
|
296
|
-
|
|
297
|
-
max: number;
|
|
298
|
-
step: number;
|
|
299
|
-
name: string;
|
|
300
|
-
minStepsBetweenThumbs: number;
|
|
296
|
+
checked: boolean;
|
|
301
297
|
disabled: boolean;
|
|
302
|
-
inverted: boolean;
|
|
303
298
|
};
|
|
304
299
|
render: (args: {}) => import("react/jsx-runtime").JSX.Element;
|
|
305
300
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
declare const Table: React.ForwardRefExoticComponent<{
|
|
3
|
+
rootClassName?: string | undefined;
|
|
3
4
|
rootRef?: React.LegacyRef<HTMLDivElement> | undefined;
|
|
4
5
|
} & React.HTMLAttributes<HTMLTableElement> & React.RefAttributes<HTMLTableElement>>;
|
|
5
6
|
declare const TableHeader: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLTableSectionElement> & React.RefAttributes<HTMLTableSectionElement>>;
|
|
@@ -2,6 +2,7 @@ import React from "react";
|
|
|
2
2
|
declare const meta: {
|
|
3
3
|
title: string;
|
|
4
4
|
component: React.ForwardRefExoticComponent<{
|
|
5
|
+
rootClassName?: string | undefined;
|
|
5
6
|
rootRef?: React.LegacyRef<HTMLDivElement> | undefined;
|
|
6
7
|
} & React.HTMLAttributes<HTMLTableElement> & React.RefAttributes<HTMLTableElement>>;
|
|
7
8
|
tags: string[];
|
|
@@ -9,6 +10,7 @@ declare const meta: {
|
|
|
9
10
|
layout: string;
|
|
10
11
|
};
|
|
11
12
|
decorators: ((Story: import("@storybook/types").PartialStoryFn<import("@storybook/react").ReactRenderer, {
|
|
13
|
+
rootClassName?: string | undefined;
|
|
12
14
|
rootRef?: React.LegacyRef<HTMLDivElement> | undefined;
|
|
13
15
|
defaultChecked?: boolean | undefined;
|
|
14
16
|
defaultValue?: string | number | readonly string[] | undefined;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { FC, ReactNode } from "react";
|
|
2
|
+
export type TreeData = {
|
|
3
|
+
id: string;
|
|
4
|
+
title: string;
|
|
5
|
+
icon?: ReactNode;
|
|
6
|
+
children?: TreeData[];
|
|
7
|
+
};
|
|
8
|
+
export interface TreeItemProps extends TreeData {
|
|
9
|
+
isFirstLevel?: boolean;
|
|
10
|
+
isLastItem: boolean;
|
|
11
|
+
checkIsExpanded: (id: string) => boolean;
|
|
12
|
+
checkIsChecked: (id: string) => boolean;
|
|
13
|
+
onExpandChange?: (id: string, expanded: boolean) => void;
|
|
14
|
+
onCheckedChange?: (id: string, checked: boolean) => void;
|
|
15
|
+
}
|
|
16
|
+
export type TreeProps = {
|
|
17
|
+
data: TreeData[];
|
|
18
|
+
defaultExpandedId?: string[];
|
|
19
|
+
defaultCheckedId?: string[];
|
|
20
|
+
checkedId?: string[];
|
|
21
|
+
onCheckedChange?: (checkedId: string[]) => void;
|
|
22
|
+
defaultExpandAll?: boolean;
|
|
23
|
+
defaultCheckAll?: boolean;
|
|
24
|
+
hierarchicalCheck?: boolean;
|
|
25
|
+
};
|
|
26
|
+
export declare const Tree: FC<TreeProps>;
|
|
27
|
+
/**
|
|
28
|
+
* TODO
|
|
29
|
+
* -----
|
|
30
|
+
* - Custom style
|
|
31
|
+
* - Custom icon, elm and render props -> callback with selected*expanded
|
|
32
|
+
* - OnClick item
|
|
33
|
+
* - OnClick expandButton
|
|
34
|
+
* - disabled props
|
|
35
|
+
* - right section icon
|
|
36
|
+
* - props for show icon, line
|
|
37
|
+
* - props for render item
|
|
38
|
+
* - OnLoad mode
|
|
39
|
+
* -----
|
|
40
|
+
* - props onLoad item
|
|
41
|
+
* - props for hasChildren * for check to trigger on load
|
|
42
|
+
* - animate expand
|
|
43
|
+
* - check duplicate reversive on updateChildren
|
|
44
|
+
* - write storybook
|
|
45
|
+
*/
|
|
@@ -14,9 +14,23 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
14
14
|
import * as React from "react";
|
|
15
15
|
import * as SwitchPrimitives from "@radix-ui/react-switch";
|
|
16
16
|
import { cn } from "@/utils/cn";
|
|
17
|
+
const switchBaseClasses = "group inline-flex h-3 w-[32px] shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors";
|
|
18
|
+
const switchStateClasses = {
|
|
19
|
+
unchecked: "data-[state=unchecked]:bg-[var(--switch-default-color)] hover:data-[state=unchecked]:bg-[var(--switch-hover-color)]",
|
|
20
|
+
checked: "data-[state=checked]:bg-[var(--switch-active-color)] hover:data-[state=checked]:bg-[var(--switch-active-hover-color)]",
|
|
21
|
+
disabled: "data-[disabled]:cursor-not-allowed data-[disabled]:!bg-[var(--switch-disabled-color)] data-[disabled]:pointer-events-none",
|
|
22
|
+
};
|
|
23
|
+
const thumbBaseClasses = "block size-4 rounded-full shadow-lg transition-transform";
|
|
24
|
+
const thumbStateClasses = {
|
|
25
|
+
unchecked: "data-[state=unchecked]:bg-[var(--switch-thumb-default-color)] data-[state=unchecked]:-translate-x-[2px]",
|
|
26
|
+
checked: "data-[state=checked]:bg-[var(--switch-thumb-active-color)] data-[state=checked]:translate-x-4",
|
|
27
|
+
hover: "group-hover:ring group-hover:data-[state=checked]:ring-[var(--switch-thumb-active-hover-ring)] group-hover:data-[state=unchecked]:ring-[var(--switch-thumb-hover-ring)]",
|
|
28
|
+
hoverColor: "group-hover:data-[state=checked]:bg-[var(--switch-thumb-active-hover-color)] group-hover:data-[state=unchecked]:bg-[var(--switch-thumb-hover-color)]",
|
|
29
|
+
disabled: "group-disabled:!bg-[--switch-thumb-disabled-color]",
|
|
30
|
+
};
|
|
17
31
|
const Switch = React.forwardRef((_a, ref) => {
|
|
18
32
|
var { className } = _a, props = __rest(_a, ["className"]);
|
|
19
|
-
return (_jsx(SwitchPrimitives.Root, Object.assign({ className: cn(
|
|
33
|
+
return (_jsx(SwitchPrimitives.Root, Object.assign({ className: cn(switchBaseClasses, switchStateClasses.unchecked, switchStateClasses.checked, switchStateClasses.disabled, className) }, props, { ref: ref, children: _jsx(SwitchPrimitives.Thumb, { className: cn(thumbBaseClasses, thumbStateClasses.unchecked, thumbStateClasses.checked, thumbStateClasses.hover, thumbStateClasses.hoverColor, thumbStateClasses.disabled) }) })));
|
|
20
34
|
});
|
|
21
35
|
Switch.displayName = SwitchPrimitives.Root.displayName;
|
|
22
36
|
export { Switch };
|
|
@@ -10,19 +10,14 @@ const meta = {
|
|
|
10
10
|
layout: "fullscreen",
|
|
11
11
|
},
|
|
12
12
|
decorators: [
|
|
13
|
-
(Story) => (_jsx("div", { className: "p-5 flex w-full", children: _jsx(Story, {}) })),
|
|
13
|
+
(Story) => (_jsx("div", { className: "p-5 flex w-full bg-base-bg2", children: _jsx(Story, {}) })),
|
|
14
14
|
],
|
|
15
15
|
};
|
|
16
16
|
export default meta;
|
|
17
17
|
export const Default = {
|
|
18
18
|
args: {
|
|
19
|
-
|
|
20
|
-
max: 100,
|
|
21
|
-
step: 1,
|
|
22
|
-
name: "test",
|
|
23
|
-
minStepsBetweenThumbs: 1,
|
|
19
|
+
checked: false,
|
|
24
20
|
disabled: false,
|
|
25
|
-
inverted: false,
|
|
26
21
|
},
|
|
27
22
|
render: (args) => {
|
|
28
23
|
console.log("args ", args);
|
|
@@ -13,8 +13,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
13
13
|
import * as React from "react";
|
|
14
14
|
import { cn } from "@/utils/cn";
|
|
15
15
|
const Table = React.forwardRef((_a, ref) => {
|
|
16
|
-
var { className, rootRef } = _a, props = __rest(_a, ["className", "rootRef"]);
|
|
17
|
-
return (_jsx("div", { className: "relative h-full w-full overflow-auto", ref: rootRef, children: _jsx("table", Object.assign({ ref: ref, className: cn("w-full caption-bottom text-sm border-collapse", className) }, props)) }));
|
|
16
|
+
var { rootClassName, className, rootRef } = _a, props = __rest(_a, ["rootClassName", "className", "rootRef"]);
|
|
17
|
+
return (_jsx("div", { className: cn("relative h-full w-full overflow-auto", rootClassName), ref: rootRef, children: _jsx("table", Object.assign({ ref: ref, className: cn("w-full caption-bottom text-sm border-collapse", className) }, props)) }));
|
|
18
18
|
});
|
|
19
19
|
Table.displayName = "Table";
|
|
20
20
|
const TableHeader = React.forwardRef((_a, ref) => {
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ActionButton, Checkbox, Icon, cn } from "@/index";
|
|
3
|
+
import { useCallback, useMemo, useState, useEffect, } from "react";
|
|
4
|
+
const TreeItem = ({ id, title, children, isFirstLevel = false, isLastItem, checkIsExpanded, checkIsChecked, onExpandChange, onCheckedChange, }) => {
|
|
5
|
+
const isChecked = useMemo(() => checkIsChecked(id), [checkIsChecked, id]);
|
|
6
|
+
const isExpanded = useMemo(() => checkIsExpanded(id), [checkIsExpanded, id]);
|
|
7
|
+
const hasChildren = useMemo(() => !!(children === null || children === void 0 ? void 0 : children.length), [children]);
|
|
8
|
+
const handleExpandToggle = useCallback(() => {
|
|
9
|
+
onExpandChange === null || onExpandChange === void 0 ? void 0 : onExpandChange(id, !isExpanded);
|
|
10
|
+
}, [id, isExpanded, onExpandChange]);
|
|
11
|
+
// TODO move to props
|
|
12
|
+
const lineSize = 2;
|
|
13
|
+
const horizontalLineWidth = 4;
|
|
14
|
+
const expandButtonSize = 30;
|
|
15
|
+
const spacing = 2;
|
|
16
|
+
const styles = {
|
|
17
|
+
branch: {
|
|
18
|
+
height: isLastItem
|
|
19
|
+
? `calc(50% + ${lineSize}px)`
|
|
20
|
+
: `calc(100% + ${lineSize}px)`,
|
|
21
|
+
width: lineSize,
|
|
22
|
+
marginTop: -lineSize,
|
|
23
|
+
borderBottomLeftRadius: lineSize / 2,
|
|
24
|
+
},
|
|
25
|
+
horizontalLine: {
|
|
26
|
+
height: lineSize,
|
|
27
|
+
width: lineSize +
|
|
28
|
+
horizontalLineWidth +
|
|
29
|
+
(hasChildren ? 0 : expandButtonSize + spacing),
|
|
30
|
+
marginLeft: -lineSize + 0.1,
|
|
31
|
+
borderBottomLeftRadius: lineSize / 2,
|
|
32
|
+
},
|
|
33
|
+
expandButton: {
|
|
34
|
+
width: expandButtonSize,
|
|
35
|
+
height: expandButtonSize,
|
|
36
|
+
},
|
|
37
|
+
childPadding: {
|
|
38
|
+
paddingLeft: isFirstLevel
|
|
39
|
+
? expandButtonSize / 2 - lineSize / 2
|
|
40
|
+
: expandButtonSize / 2 + horizontalLineWidth - lineSize / 2,
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
return (_jsxs("div", { className: "flex flex-row w-full", children: [_jsx("div", { className: cn("bg-grey-150", { "h-1/2": isLastItem }), style: styles.branch }), _jsxs("div", { className: "flex flex-col w-full", children: [_jsxs("div", { className: "flex items-center py-2 min-h-10", children: [!isFirstLevel && (_jsx("div", { className: "bg-grey-150", style: styles.horizontalLine })), isFirstLevel && !hasChildren && (_jsx("div", { className: "flex mr-[2px]", style: styles.expandButton })), hasChildren && (_jsx("div", { className: "flex mr-[2px]", style: styles.expandButton, children: _jsx(ActionButton, { variant: "icon", size: "sm", onClick: handleExpandToggle, children: _jsx(Icon, { name: isExpanded ? "chevron-down" : "chevron-right" }) }) })), _jsx(Checkbox, { id: id, className: "size-[16pt]", checked: isChecked, onCheckedChange: (newChecked) => onCheckedChange === null || onCheckedChange === void 0 ? void 0 : onCheckedChange(id, newChecked) }), _jsxs("div", { className: "ml-2 gap-1 flex items-center text-foreground", children: [_jsx(Icon, { name: isExpanded ? "folder-open" : "folder", className: "fill-warning" }), _jsx("label", { htmlFor: id, className: "flex-1 cursor-pointer text-subtitle5 text-ellipsis", children: title })] })] }), isExpanded && hasChildren && (_jsx("div", { className: "flex flex-col", style: styles.childPadding, children: children === null || children === void 0 ? void 0 : children.map((child, idx) => (_jsx(TreeItem, Object.assign({}, child, { isLastItem: idx === children.length - 1, checkIsExpanded: checkIsExpanded, checkIsChecked: checkIsChecked, onExpandChange: onExpandChange, onCheckedChange: onCheckedChange }), child.id))) }))] })] }));
|
|
44
|
+
};
|
|
45
|
+
export const Tree = ({ data, defaultExpandedId = [], defaultCheckedId = [], checkedId, onCheckedChange, defaultExpandAll = false, defaultCheckAll = false, hierarchicalCheck = false, }) => {
|
|
46
|
+
const [checkedState, setCheckedState] = useState({});
|
|
47
|
+
const [expandedState, setExpandedState] = useState({});
|
|
48
|
+
const traverseTree = (nodes, callback) => {
|
|
49
|
+
nodes.forEach((node) => {
|
|
50
|
+
callback(node);
|
|
51
|
+
if (node.children) {
|
|
52
|
+
traverseTree(node.children, callback);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
if (defaultExpandAll) {
|
|
58
|
+
const allExpanded = {};
|
|
59
|
+
traverseTree(data, (node) => {
|
|
60
|
+
allExpanded[node.id] = true;
|
|
61
|
+
});
|
|
62
|
+
setExpandedState(allExpanded);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
const initialExpandedState = defaultExpandedId.reduce((acc, id) => {
|
|
66
|
+
acc[id] = true;
|
|
67
|
+
return acc;
|
|
68
|
+
}, {});
|
|
69
|
+
setExpandedState(initialExpandedState);
|
|
70
|
+
}
|
|
71
|
+
}, [data, defaultExpandedId, defaultExpandAll]);
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
if (defaultCheckAll) {
|
|
74
|
+
const allChecked = {};
|
|
75
|
+
traverseTree(data, (node) => {
|
|
76
|
+
allChecked[node.id] = true;
|
|
77
|
+
});
|
|
78
|
+
setCheckedState(allChecked);
|
|
79
|
+
}
|
|
80
|
+
else if (!checkedId) {
|
|
81
|
+
const initialCheckedState = defaultCheckedId.reduce((acc, id) => {
|
|
82
|
+
acc[id] = true;
|
|
83
|
+
return acc;
|
|
84
|
+
}, {});
|
|
85
|
+
setCheckedState(initialCheckedState);
|
|
86
|
+
}
|
|
87
|
+
}, [data, defaultCheckedId, checkedId, defaultCheckAll]);
|
|
88
|
+
const handleExpandChange = useCallback((id, expanded) => {
|
|
89
|
+
setExpandedState((prev) => (Object.assign(Object.assign({}, prev), { [id]: expanded })));
|
|
90
|
+
}, []);
|
|
91
|
+
const handleCheckedChange = useCallback((id, checked) => {
|
|
92
|
+
let newState = Object.assign(Object.assign({}, checkedState), { [id]: checked });
|
|
93
|
+
if (hierarchicalCheck) {
|
|
94
|
+
const updateCheckedState = (nodeId, isChecked, state) => {
|
|
95
|
+
state[nodeId] = isChecked;
|
|
96
|
+
// Update children recursively
|
|
97
|
+
const updateChildren = (parentId, isChecked) => {
|
|
98
|
+
traverseTree(data, (node) => {
|
|
99
|
+
if (node.id === parentId && node.children) {
|
|
100
|
+
node.children.forEach((child) => {
|
|
101
|
+
state[child.id] = isChecked;
|
|
102
|
+
updateChildren(child.id, isChecked);
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
// Update parents recursively
|
|
108
|
+
const updateParents = (childId, state) => {
|
|
109
|
+
traverseTree(data, (node) => {
|
|
110
|
+
var _a;
|
|
111
|
+
if ((_a = node.children) === null || _a === void 0 ? void 0 : _a.some((child) => child.id === childId)) {
|
|
112
|
+
const allChildrenChecked = node.children.every((child) => state[child.id]);
|
|
113
|
+
state[node.id] = allChildrenChecked;
|
|
114
|
+
updateParents(node.id, state);
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
};
|
|
118
|
+
updateChildren(nodeId, isChecked);
|
|
119
|
+
updateParents(nodeId, state);
|
|
120
|
+
return state;
|
|
121
|
+
};
|
|
122
|
+
newState = updateCheckedState(id, checked, newState);
|
|
123
|
+
}
|
|
124
|
+
setCheckedState(newState);
|
|
125
|
+
if (onCheckedChange) {
|
|
126
|
+
const checkedIds = Object.keys(newState).filter((key) => newState[key]);
|
|
127
|
+
onCheckedChange(checkedIds);
|
|
128
|
+
}
|
|
129
|
+
}, [checkedState, data, onCheckedChange, hierarchicalCheck]);
|
|
130
|
+
const checkIsExpanded = useCallback((id) => !!expandedState[id], [expandedState]);
|
|
131
|
+
const checkIsChecked = useCallback((id) => {
|
|
132
|
+
if (checkedId) {
|
|
133
|
+
return checkedId.includes(id);
|
|
134
|
+
}
|
|
135
|
+
return !!checkedState[id];
|
|
136
|
+
}, [checkedId, checkedState]);
|
|
137
|
+
return (_jsx("div", { className: "w-full", children: data.map((item, idx) => (_jsx(TreeItem, Object.assign({}, item, { isFirstLevel: true, isLastItem: idx === data.length - 1, checkIsExpanded: checkIsExpanded, checkIsChecked: checkIsChecked, onExpandChange: handleExpandChange, onCheckedChange: handleCheckedChange }), item.id))) }));
|
|
138
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Tree } from "./Tree";
|
|
3
|
+
// Example data for testing the Tree component (as plain objects)
|
|
4
|
+
const exampleData = [
|
|
5
|
+
{
|
|
6
|
+
id: "1",
|
|
7
|
+
title: "Parent Folder 1",
|
|
8
|
+
children: [
|
|
9
|
+
{
|
|
10
|
+
id: "1.1",
|
|
11
|
+
title: "Child Folder 1.1",
|
|
12
|
+
children: [
|
|
13
|
+
{ id: "1.1.1", title: "Sub Folder 1.1.1" },
|
|
14
|
+
{ id: "1.1.2", title: "Sub Folder 1.1.2" },
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
{ id: "1.2", title: "Child Folder 1.2" },
|
|
18
|
+
],
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
id: "2",
|
|
22
|
+
title: "Parent Folder 2",
|
|
23
|
+
children: [{ id: "2.1", title: "Child Folder 2.1" }],
|
|
24
|
+
},
|
|
25
|
+
{ id: "3", title: "Parent Folder 3" },
|
|
26
|
+
];
|
|
27
|
+
// Storybook metadata
|
|
28
|
+
const meta = {
|
|
29
|
+
title: "Components/Tree",
|
|
30
|
+
component: Tree,
|
|
31
|
+
tags: ["autodocs"],
|
|
32
|
+
parameters: {
|
|
33
|
+
layout: "fullscreen",
|
|
34
|
+
},
|
|
35
|
+
decorators: [
|
|
36
|
+
(Story) => (_jsx("div", { className: "p-5 flex w-full bg-base-bg", children: _jsx(Story, {}) })),
|
|
37
|
+
],
|
|
38
|
+
};
|
|
39
|
+
export default meta;
|
|
40
|
+
// Default story
|
|
41
|
+
export const Default = {
|
|
42
|
+
args: {
|
|
43
|
+
data: exampleData,
|
|
44
|
+
defaultExpandedId: ["1", "1.1"],
|
|
45
|
+
defaultCheckedId: ["1.1"],
|
|
46
|
+
defaultExpandAll: true,
|
|
47
|
+
defaultCheckAll: true,
|
|
48
|
+
hierarchicalCheck: true,
|
|
49
|
+
},
|
|
50
|
+
render: (args) => {
|
|
51
|
+
return (_jsx("div", { className: "flex flex-row gap-4 w-full", children: _jsx(Tree, Object.assign({}, args)) }));
|
|
52
|
+
},
|
|
53
|
+
};
|
package/dist/esm/bundle.css
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
@import "./tokens/baseline.css";
|
|
3
3
|
@import "./themes/xspector/baseline.css";
|
|
4
|
+
@import "./themes/SKL/baseline.css";
|
|
4
5
|
|
|
5
6
|
/*
|
|
6
7
|
! tailwindcss v3.4.3 | MIT License | https://tailwindcss.com
|
|
@@ -698,6 +699,9 @@ input[type=number] {
|
|
|
698
699
|
.mr-4{
|
|
699
700
|
margin-right: 1rem;
|
|
700
701
|
}
|
|
702
|
+
.mr-\[2px\]{
|
|
703
|
+
margin-right: 2px;
|
|
704
|
+
}
|
|
701
705
|
.mt-1{
|
|
702
706
|
margin-top: 0.25rem;
|
|
703
707
|
}
|
|
@@ -776,6 +780,10 @@ input[type=number] {
|
|
|
776
780
|
width: 14px;
|
|
777
781
|
height: 14px;
|
|
778
782
|
}
|
|
783
|
+
.size-\[16pt\]{
|
|
784
|
+
width: 16pt;
|
|
785
|
+
height: 16pt;
|
|
786
|
+
}
|
|
779
787
|
.size-\[30px\]{
|
|
780
788
|
width: 30px;
|
|
781
789
|
height: 30px;
|
|
@@ -788,6 +796,9 @@ input[type=number] {
|
|
|
788
796
|
width: 100%;
|
|
789
797
|
height: 100%;
|
|
790
798
|
}
|
|
799
|
+
.h-1\/2{
|
|
800
|
+
height: 50%;
|
|
801
|
+
}
|
|
791
802
|
.h-10{
|
|
792
803
|
height: 2.5rem;
|
|
793
804
|
}
|
|
@@ -858,6 +869,9 @@ input[type=number] {
|
|
|
858
869
|
.max-h-screen{
|
|
859
870
|
max-height: 100vh;
|
|
860
871
|
}
|
|
872
|
+
.min-h-10{
|
|
873
|
+
min-height: 2.5rem;
|
|
874
|
+
}
|
|
861
875
|
.w-1\/2{
|
|
862
876
|
width: 50%;
|
|
863
877
|
}
|
|
@@ -1131,6 +1145,9 @@ input[type=number] {
|
|
|
1131
1145
|
text-overflow: ellipsis;
|
|
1132
1146
|
white-space: nowrap;
|
|
1133
1147
|
}
|
|
1148
|
+
.text-ellipsis{
|
|
1149
|
+
text-overflow: ellipsis;
|
|
1150
|
+
}
|
|
1134
1151
|
.rounded{
|
|
1135
1152
|
border-radius: 0.25rem;
|
|
1136
1153
|
}
|
|
@@ -2201,10 +2218,6 @@ input[type=number] {
|
|
|
2201
2218
|
--tw-bg-opacity: 1;
|
|
2202
2219
|
background-color: color-mix(in srgb, var(--secondary-ramps-secondary-90) calc(100% * var(--tw-bg-opacity)), transparent);
|
|
2203
2220
|
}
|
|
2204
|
-
.bg-secondary-active{
|
|
2205
|
-
--tw-bg-opacity: 1;
|
|
2206
|
-
background-color: color-mix(in srgb, var(--state-color-secondary-active) calc(100% * var(--tw-bg-opacity)), transparent);
|
|
2207
|
-
}
|
|
2208
2221
|
.bg-secondary-default{
|
|
2209
2222
|
--tw-bg-opacity: 1;
|
|
2210
2223
|
background-color: color-mix(in srgb, var(--state-color-secondary-default) calc(100% * var(--tw-bg-opacity)), transparent);
|
|
@@ -2722,6 +2735,9 @@ input[type=number] {
|
|
|
2722
2735
|
.fill-primary-default{
|
|
2723
2736
|
fill: color-mix(in srgb, var(--state-color-primary-default) calc(100% * 1), transparent);
|
|
2724
2737
|
}
|
|
2738
|
+
.fill-warning{
|
|
2739
|
+
fill: color-mix(in srgb, var(--state-color-warning-default) calc(100% * 1), transparent);
|
|
2740
|
+
}
|
|
2725
2741
|
.stroke-input-default-stroke{
|
|
2726
2742
|
stroke: color-mix(in srgb, var(--input-color-default-stroke) calc(100% * 1), transparent);
|
|
2727
2743
|
}
|
|
@@ -4977,9 +4993,8 @@ input[type=number] {
|
|
|
4977
4993
|
--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(3px + var(--tw-ring-offset-width)) var(--tw-ring-color);
|
|
4978
4994
|
box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000);
|
|
4979
4995
|
}
|
|
4980
|
-
.group:disabled .group-disabled
|
|
4981
|
-
--
|
|
4982
|
-
background-color: color-mix(in srgb, var(--state-color-disable-solid) calc(100% * var(--tw-bg-opacity)), transparent);
|
|
4996
|
+
.group:disabled .group-disabled\:\!bg-\[--switch-thumb-disabled-color\]{
|
|
4997
|
+
background-color: var(--switch-thumb-disabled-color) !important;
|
|
4983
4998
|
}
|
|
4984
4999
|
.peer:-moz-placeholder-shown ~ .peer-placeholder-shown\:top-2{
|
|
4985
5000
|
top: 0.5rem;
|
|
@@ -5241,8 +5256,8 @@ input[type=number] {
|
|
|
5241
5256
|
.data-\[disabled\]\:\!bg-\[var\(--dropdown-menu-disabled-bg\)\][data-disabled]{
|
|
5242
5257
|
background-color: var(--dropdown-menu-disabled-bg) !important;
|
|
5243
5258
|
}
|
|
5244
|
-
.data-\[disabled\]
|
|
5245
|
-
background-color:
|
|
5259
|
+
.data-\[disabled\]\:\!bg-\[var\(--switch-disabled-color\)\][data-disabled]{
|
|
5260
|
+
background-color: var(--switch-disabled-color) !important;
|
|
5246
5261
|
}
|
|
5247
5262
|
.data-\[loading\=true\]\:bg-button-error-flat-active[data-loading=true]{
|
|
5248
5263
|
--tw-bg-opacity: 1;
|
|
@@ -5331,13 +5346,16 @@ input[type=number] {
|
|
|
5331
5346
|
.data-\[state\=\'checked\'\]\:bg-\[var\(--dropdown-menu-selected-bg\)\][data-state='checked']{
|
|
5332
5347
|
background-color: var(--dropdown-menu-selected-bg);
|
|
5333
5348
|
}
|
|
5349
|
+
.data-\[state\=checked\]\:bg-\[var\(--switch-active-color\)\][data-state=checked]{
|
|
5350
|
+
background-color: var(--switch-active-color);
|
|
5351
|
+
}
|
|
5352
|
+
.data-\[state\=checked\]\:bg-\[var\(--switch-thumb-active-color\)\][data-state=checked]{
|
|
5353
|
+
background-color: var(--switch-thumb-active-color);
|
|
5354
|
+
}
|
|
5334
5355
|
.data-\[state\=checked\]\:bg-function-active-solid[data-state=checked]{
|
|
5335
5356
|
--tw-bg-opacity: 1;
|
|
5336
5357
|
background-color: color-mix(in srgb, var(--function-active-solid) calc(100% * var(--tw-bg-opacity)), transparent);
|
|
5337
5358
|
}
|
|
5338
|
-
.data-\[state\=checked\]\:bg-secondary-active\/\[0\.32\][data-state=checked]{
|
|
5339
|
-
background-color: color-mix(in srgb, var(--state-color-secondary-active) calc(100% * 0.32), transparent);
|
|
5340
|
-
}
|
|
5341
5359
|
.data-\[state\=open\]\:bg-primary[data-state=open]{
|
|
5342
5360
|
--tw-bg-opacity: 1;
|
|
5343
5361
|
background-color: color-mix(in srgb, var(--state-color-primary-default) calc(100% * var(--tw-bg-opacity)), transparent);
|
|
@@ -5346,12 +5364,11 @@ input[type=number] {
|
|
|
5346
5364
|
--tw-bg-opacity: 1;
|
|
5347
5365
|
background-color: color-mix(in srgb, var(--grey-grey-20) calc(100% * var(--tw-bg-opacity)), transparent);
|
|
5348
5366
|
}
|
|
5349
|
-
.data-\[state\=unchecked\]\:bg-
|
|
5350
|
-
--
|
|
5351
|
-
background-color: color-mix(in srgb, var(--state-color-tertiary-active) calc(100% * var(--tw-bg-opacity)), transparent);
|
|
5367
|
+
.data-\[state\=unchecked\]\:bg-\[var\(--switch-default-color\)\][data-state=unchecked]{
|
|
5368
|
+
background-color: var(--switch-default-color);
|
|
5352
5369
|
}
|
|
5353
|
-
.data-\[state\=unchecked\]\:bg-
|
|
5354
|
-
background-color:
|
|
5370
|
+
.data-\[state\=unchecked\]\:bg-\[var\(--switch-thumb-default-color\)\][data-state=unchecked]{
|
|
5371
|
+
background-color: var(--switch-thumb-default-color);
|
|
5355
5372
|
}
|
|
5356
5373
|
.data-\[disabled\]\:\!fill-state-disable-solid[data-disabled]{
|
|
5357
5374
|
fill: color-mix(in srgb, var(--state-color-disable-solid) calc(100% * 1), transparent) !important;
|
|
@@ -5537,27 +5554,31 @@ input[type=number] {
|
|
|
5537
5554
|
--tw-border-opacity: 1;
|
|
5538
5555
|
border-color: color-mix(in srgb, var(--function-active-hover) calc(100% * var(--tw-border-opacity)), transparent);
|
|
5539
5556
|
}
|
|
5557
|
+
.hover\:data-\[state\=checked\]\:bg-\[var\(--switch-active-hover-color\)\][data-state=checked]:hover{
|
|
5558
|
+
background-color: var(--switch-active-hover-color);
|
|
5559
|
+
}
|
|
5540
5560
|
.hover\:data-\[state\=checked\]\:bg-function-active-hover[data-state=checked]:hover{
|
|
5541
5561
|
--tw-bg-opacity: 1;
|
|
5542
5562
|
background-color: color-mix(in srgb, var(--function-active-hover) calc(100% * var(--tw-bg-opacity)), transparent);
|
|
5543
5563
|
}
|
|
5544
|
-
.hover\:data-\[state\=
|
|
5545
|
-
background-color:
|
|
5546
|
-
}
|
|
5547
|
-
.hover\:data-\[state\=unchecked\]\:bg-tertiary-active\/\[0\.48\][data-state=unchecked]:hover{
|
|
5548
|
-
background-color: color-mix(in srgb, var(--state-color-tertiary-active) calc(100% * 0.48), transparent);
|
|
5564
|
+
.hover\:data-\[state\=unchecked\]\:bg-\[var\(--switch-hover-color\)\][data-state=unchecked]:hover{
|
|
5565
|
+
background-color: var(--switch-hover-color);
|
|
5549
5566
|
}
|
|
5550
5567
|
.hover\:data-\[state\=checked\]\:text-function-active-hover[data-state=checked]:hover{
|
|
5551
5568
|
--tw-text-opacity: 1;
|
|
5552
5569
|
color: color-mix(in srgb, var(--function-active-hover) calc(100% * var(--tw-text-opacity)), transparent);
|
|
5553
5570
|
}
|
|
5554
|
-
.group:hover .group-hover\:data-\[state\=checked\]\:
|
|
5555
|
-
--
|
|
5556
|
-
--tw-ring-color: color-mix(in srgb, var(--state-color-secondary-hover-bg) calc(100% * var(--tw-ring-opacity)), transparent);
|
|
5571
|
+
.group:hover .group-hover\:data-\[state\=checked\]\:bg-\[var\(--switch-thumb-active-hover-color\)\][data-state=checked]{
|
|
5572
|
+
background-color: var(--switch-thumb-active-hover-color);
|
|
5557
5573
|
}
|
|
5558
|
-
.group:hover .group-hover\:data-\[state\=unchecked\]\:
|
|
5559
|
-
--
|
|
5560
|
-
|
|
5574
|
+
.group:hover .group-hover\:data-\[state\=unchecked\]\:bg-\[var\(--switch-thumb-hover-color\)\][data-state=unchecked]{
|
|
5575
|
+
background-color: var(--switch-thumb-hover-color);
|
|
5576
|
+
}
|
|
5577
|
+
.group:hover .group-hover\:data-\[state\=checked\]\:ring-\[var\(--switch-thumb-active-hover-ring\)\][data-state=checked]{
|
|
5578
|
+
--tw-ring-color: var(--switch-thumb-active-hover-ring);
|
|
5579
|
+
}
|
|
5580
|
+
.group:hover .group-hover\:data-\[state\=unchecked\]\:ring-\[var\(--switch-thumb-hover-ring\)\][data-state=unchecked]{
|
|
5581
|
+
--tw-ring-color: var(--switch-thumb-hover-ring);
|
|
5561
5582
|
}
|
|
5562
5583
|
@media (min-width: 640px){
|
|
5563
5584
|
|