@lanaco/lnc-react-ui
Version:
React component library
109 lines (108 loc) • 3.59 kB
JavaScript
import { jsxs as C, jsx as N } from "react/jsx-runtime";
import { forwardRef as D, useRef as Y, Children as l, isValidElement as M, cloneElement as u } from "react";
import { P as s } from "./index-S5Cd7WrG.js";
import { n as G } from "./emotion-styled.browser.esm-CjCaF13H.js";
const U = G.div`
padding: 0.25rem;
gap: ${(t) => t.itemsGap};
display: flex;
flex-direction: column;
${(t) => t.widthFitContent == !1 && "min-width: 12.5rem"};
height: 100%;
justify-content: space-between;
& > .start-menu-items-lnc,
> .end-menu-items-lnc {
display: flex;
flex-direction: column;
gap: ${(t) => t.itemsGap};
}
`, b = D((t, r) => {
const {
widthFitContent: I = !1,
itemsGap: S = "0.25rem",
//----------------
onItemSelected: E = () => {
},
//----------------
className: g = "",
style: j = {},
color: n = "primary",
size: o = "small",
children: _,
...w
} = t, f = Y(), x = l.map(_, (e, T) => {
var p, a, m, i, y;
if (M(e) && (e.props.__TYPE__ == "MENU_ITEM" || ((p = e == null ? void 0 : e.type) == null ? void 0 : p.displayName) === "MENU_ITEM" || e.props.__TYPE__ == "NESTED_ITEM" || ((a = e == null ? void 0 : e.type) == null ? void 0 : a.displayName) === "NESTED_ITEM"))
return T == 0 && e.props.justifyToEnd !== !0 ? (e.props.ref && (f.current = r), u(e, {
ref: r || f,
//needed to focus on navigation
color: n,
size: o,
onItemSelected: E
})) : e.props.justifyToEnd !== !0 || e.props.__TYPE__ == "NESTED_ITEM" || ((m = e == null ? void 0 : e.type) == null ? void 0 : m.displayName) === "NESTED_ITEM" ? u(e, {
color: n,
size: o,
onItemSelected: E
}) : void 0;
if (((i = e.props) == null ? void 0 : i.justifyToEnd) == !1 || !((y = e.props) != null && y.justifyToEnd))
return e;
}), P = l.map(_, (e, T) => {
var p, a, m;
if (M(e) && (e.props.__TYPE__ == "MENU_ITEM" || ((p = e == null ? void 0 : e.type) == null ? void 0 : p.displayName) === "MENU_ITEM" || e.props.__TYPE__ == "NESTED_ITEM" || ((a = e == null ? void 0 : e.type) == null ? void 0 : a.displayName) === "NESTED_ITEM") && e.props.justifyToEnd == !0)
return T == 0 ? (e.props.ref && (f.current = r), u(e, {
ref: r || f,
//needed to focus on navigation
color: e.props.color ? e.props.color : n,
size: o,
onItemSelected: E
})) : u(e, {
color: e.props.color ? e.props.color : n,
size: o,
onItemSelected: E
});
if (((m = e.props) == null ? void 0 : m.justifyToEnd) == !0) return e;
});
return /* @__PURE__ */ C(
U,
{
ref: r,
widthFitContent: I,
itemsGap: S,
size: o,
color: n,
className: "lnc-ui-treemenu " + g,
style: j,
...w,
children: [
/* @__PURE__ */ N("div", { className: "nested-item-lnc start-menu-items-lnc", children: x }),
/* @__PURE__ */ N("div", { className: "nested-item-lnc end-menu-items-lnc", children: P })
]
}
);
});
b.propTypes = {
widthFitContent: s.bool,
/**
* Gap between Menu Items
*/
itemsGap: s.string,
//---------------------------------------------------------------
onItemSelected: s.func,
//---------------------------------------------------------------
className: s.string,
style: s.object,
color: s.oneOf([
"primary",
"secondary",
"success",
"warning",
"danger",
"information",
"neutral",
"gray"
]),
size: s.oneOf(["small", "medium", "large"])
};
export {
b as default
};