UNPKG

@lanaco/lnc-react-ui

Version:

React component library

85 lines (84 loc) 3.04 kB
import { jsxs as C, jsx as N } from "react/jsx-runtime"; import { forwardRef as P, useRef as Y, Children as i, isValidElement as M, cloneElement as u } from "react"; import { s as g } from "./emotion-styled.browser.esm-DfbrHHed.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}; } `, $ = P((t, r) => { const { widthFitContent: I = !1, itemsGap: j = "0.25rem", //---------------- onItemSelected: a = () => { }, //---------------- className: S = "", style: l = {}, color: s = "primary", size: n = "small", children: _, ...x } = t, E = Y(), D = i.map(_, (e, f) => { var o, p, m, T, y; if (M(e) && (e.props.__TYPE__ == "MENU_ITEM" || ((o = e == null ? void 0 : e.type) == null ? void 0 : o.displayName) === "MENU_ITEM" || e.props.__TYPE__ == "NESTED_ITEM" || ((p = e == null ? void 0 : e.type) == null ? void 0 : p.displayName) === "NESTED_ITEM")) return f == 0 && e.props.justifyToEnd !== !0 ? (e.props.ref && (E.current = r), u(e, { ref: r || E, //needed to focus on navigation color: s, size: n, onItemSelected: a })) : 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: s, size: n, onItemSelected: a }) : void 0; if (((T = e.props) == null ? void 0 : T.justifyToEnd) == !1 || !((y = e.props) != null && y.justifyToEnd)) return e; }), w = i.map(_, (e, f) => { var o, p, m; if (M(e) && (e.props.__TYPE__ == "MENU_ITEM" || ((o = e == null ? void 0 : e.type) == null ? void 0 : o.displayName) === "MENU_ITEM" || e.props.__TYPE__ == "NESTED_ITEM" || ((p = e == null ? void 0 : e.type) == null ? void 0 : p.displayName) === "NESTED_ITEM") && e.props.justifyToEnd == !0) return f == 0 ? (e.props.ref && (E.current = r), u(e, { ref: r || E, //needed to focus on navigation color: e.props.color ? e.props.color : s, size: n, onItemSelected: a })) : u(e, { color: e.props.color ? e.props.color : s, size: n, onItemSelected: a }); if (((m = e.props) == null ? void 0 : m.justifyToEnd) == !0) return e; }); return /* @__PURE__ */ C( U, { ref: r, widthFitContent: I, itemsGap: j, size: n, color: s, className: "lnc-ui-treemenu " + S, style: l, ...x, children: [ /* @__PURE__ */ N("div", { className: "nested-item-lnc start-menu-items-lnc", children: D }), /* @__PURE__ */ N("div", { className: "nested-item-lnc end-menu-items-lnc", children: w }) ] } ); }); export { $ as default };