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