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