@lanaco/lnc-react-ui
Version:
React component library
81 lines (80 loc) • 2.25 kB
JavaScript
import { jsxs as M, Fragment as i, jsx as a } from "react/jsx-runtime";
import { forwardRef as x, useState as S, cloneElement as p, Children as w, isValidElement as h } from "react";
import { s as b } from "./emotion-styled.browser.esm-DfbrHHed.js";
import { c as D } from "./utils-BUdHa0nB.js";
import { m as C } from "./motion-Ckekul_K.js";
import { u as P } from "./emotion-element-f0de968e.browser.esm-CkCiQliQ.js";
import { A as j } from "./index-D-c5IxDk.js";
const A = b(C.div)`
margin-left: 0.3rem;
padding-left: 0.3rem;
border-left: ${(t) => `2px solid ${D(
t.theme,
"MenuItem",
t.color,
"focus",
"background"
)}`};
border-radius: 2px;
`, O = x((t, R) => {
const {
item: l,
//------------------
onItemSelected: d = () => {
},
//--------------------
defaultOpen: f = !1,
animation: u = {
animate: { opacity: 1, height: "auto" },
exit: { opacity: 0, height: 0 },
initial: { opacity: 0, height: 0 },
transition: {
type: "tween",
duration: 0.15,
opacity: { duration: 0.15, ease: "easeOut" },
height: { duration: 0.15 }
}
},
className: c = "",
style: E = {},
color: o = "primary",
size: r = "small",
children: N,
...g
} = t, y = P(), [s, _] = S(f), T = p(l, {
isNested: !0,
showNested: s,
toggleNested: () => {
_(!s);
},
color: o,
size: r
}), I = w.map(N, (e, V) => {
var n, m;
return h(e) && (e.props.__TYPE__ == "MENU_ITEM" || ((n = e == null ? void 0 : e.type) == null ? void 0 : n.displayName) === "MENU_ITEM" || e.props.__TYPE__ == "NESTED_ITEM" || ((m = e == null ? void 0 : e.type) == null ? void 0 : m.displayName) === "NESTED_ITEM") ? p(e, {
color: e.props.color ? e.props.color : o,
size: r,
onItemSelected: d
}) : e;
});
return /* @__PURE__ */ M(i, { children: [
/* @__PURE__ */ a(i, { children: T }),
/* @__PURE__ */ a(j, { children: s && /* @__PURE__ */ a(
A,
{
...u,
theme: y,
color: o,
size: r,
className: "nested-item-lnc " + c,
style: E,
...g,
children: I
}
) })
] });
});
O.displayName = "NESTED_ITEM";
export {
O as default
};