@shoplflow/base 0.28.5 → 0.30.0
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/index.cjs +52 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -2
- package/dist/index.d.ts +7 -2
- package/dist/index.js +52 -23
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2839,16 +2839,17 @@ var StyledTreeItem = styled6__default.default(framerMotion.motion.li)`
|
|
|
2839
2839
|
gap: 4px;
|
|
2840
2840
|
align-items: center;
|
|
2841
2841
|
justify-content: space-between;
|
|
2842
|
-
padding: 8px 0;
|
|
2842
|
+
padding: 8px 8px 8px 0;
|
|
2843
2843
|
border-radius: 8px;
|
|
2844
2844
|
background: transparent;
|
|
2845
|
-
cursor: initial;
|
|
2845
|
+
cursor: ${({ onClick }) => onClick ? "pointer" : "initial"};
|
|
2846
2846
|
${({ depth }) => depth && react$1.css`
|
|
2847
2847
|
padding-left: ${depth * 16}px;
|
|
2848
2848
|
`};
|
|
2849
2849
|
&:hover {
|
|
2850
2850
|
background: ${exports.colorTokens.neutral400_5};
|
|
2851
2851
|
}
|
|
2852
|
+
${({ disabled }) => disabled && getDisabledStyle(disabled)}
|
|
2852
2853
|
`;
|
|
2853
2854
|
var LeftElementWrapper = styled6__default.default.div`
|
|
2854
2855
|
display: flex;
|
|
@@ -2894,7 +2895,9 @@ exports.TreeItem = (_a) => {
|
|
|
2894
2895
|
rightSource,
|
|
2895
2896
|
depth = 0,
|
|
2896
2897
|
initialIsOpen,
|
|
2897
|
-
isOpen
|
|
2898
|
+
isOpen,
|
|
2899
|
+
disabled = false,
|
|
2900
|
+
onClick
|
|
2898
2901
|
} = _b, rest = __objRest(_b, [
|
|
2899
2902
|
"children",
|
|
2900
2903
|
"label",
|
|
@@ -2902,7 +2905,9 @@ exports.TreeItem = (_a) => {
|
|
|
2902
2905
|
"rightSource",
|
|
2903
2906
|
"depth",
|
|
2904
2907
|
"initialIsOpen",
|
|
2905
|
-
"isOpen"
|
|
2908
|
+
"isOpen",
|
|
2909
|
+
"disabled",
|
|
2910
|
+
"onClick"
|
|
2906
2911
|
]);
|
|
2907
2912
|
const [isOpened, setIsOpened] = React3__namespace.default.useState(initialIsOpen != null ? initialIsOpen : false);
|
|
2908
2913
|
const CloneChildren = React3__namespace.default.Children.map(children, (child) => {
|
|
@@ -2916,33 +2921,57 @@ exports.TreeItem = (_a) => {
|
|
|
2916
2921
|
}
|
|
2917
2922
|
return child;
|
|
2918
2923
|
});
|
|
2919
|
-
const handleToggle = () => {
|
|
2924
|
+
const handleToggle = (e) => {
|
|
2925
|
+
e.stopPropagation();
|
|
2920
2926
|
setIsOpened((prev) => !prev);
|
|
2921
2927
|
};
|
|
2928
|
+
const handleClickTreeItem = (e) => {
|
|
2929
|
+
if (disabled || !onClick) {
|
|
2930
|
+
return;
|
|
2931
|
+
}
|
|
2932
|
+
return onClick(e);
|
|
2933
|
+
};
|
|
2934
|
+
const LeftSourceClone = leftSource ? React3__namespace.default.cloneElement(leftSource, __spreadValues({
|
|
2935
|
+
disabled,
|
|
2936
|
+
onClick
|
|
2937
|
+
}, rest)) : leftSource;
|
|
2922
2938
|
React3.useEffect(() => {
|
|
2923
2939
|
if (isOpen !== void 0) {
|
|
2924
2940
|
setIsOpened(isOpen);
|
|
2925
2941
|
}
|
|
2926
2942
|
}, [isOpen]);
|
|
2927
2943
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2928
|
-
/* @__PURE__ */ React3.createElement(
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2944
|
+
/* @__PURE__ */ React3.createElement(
|
|
2945
|
+
StyledTreeItem,
|
|
2946
|
+
__spreadValues(__spreadProps(__spreadValues({
|
|
2947
|
+
disabled,
|
|
2948
|
+
depth,
|
|
2949
|
+
variants: fadeInOut
|
|
2950
|
+
}, AnimateKey), {
|
|
2951
|
+
layout: true,
|
|
2952
|
+
key: String(label),
|
|
2953
|
+
onClick: handleClickTreeItem
|
|
2954
|
+
}), rest),
|
|
2955
|
+
/* @__PURE__ */ jsxRuntime.jsxs(LeftElementWrapper, { children: [
|
|
2956
|
+
LeftSourceClone && LeftSourceClone,
|
|
2957
|
+
/* @__PURE__ */ jsxRuntime.jsx(exports.StackContainer, { padding: "0 0 0 4px", children: /* @__PURE__ */ jsxRuntime.jsx(exports.Text, { typography: "body1_400", lineClamp: 1, color: disabled ? "neutral350" : "neutral700", children: label }) })
|
|
2958
|
+
] }),
|
|
2959
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RightElementWrapper, { children: [
|
|
2960
|
+
rightSource,
|
|
2961
|
+
children && /* @__PURE__ */ jsxRuntime.jsx(exports.IconButton, { styleVar: "GHOST", onClick: handleToggle, sizeVar: "S", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2962
|
+
IconWrapper,
|
|
2963
|
+
{
|
|
2964
|
+
animate: {
|
|
2965
|
+
rotate: isOpened ? 180 : 0,
|
|
2966
|
+
transition: {
|
|
2967
|
+
duration: 0.2
|
|
2968
|
+
}
|
|
2969
|
+
},
|
|
2970
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(exports.Icon, { iconSource: ShoplAssets.DownArrowIcon, sizeVar: "S", color: "neutral400" })
|
|
2971
|
+
}
|
|
2972
|
+
) })
|
|
2973
|
+
] })
|
|
2974
|
+
),
|
|
2946
2975
|
/* @__PURE__ */ jsxRuntime.jsx(framerMotion.AnimatePresence, { mode: "sync", children: isOpened && children && /* @__PURE__ */ jsxRuntime.jsx(framerMotion.motion.div, __spreadProps(__spreadValues({ layout: true }, AnimateKey), { variants: fadeInOut, children: CloneChildren }), "children" + String(CloneChildren)) })
|
|
2947
2976
|
] });
|
|
2948
2977
|
};
|