UNPKG

@progress/kendo-react-layout

Version:

React Layout components enable you to create a perceptive and intuitive layout of web projects. KendoReact Layout package

74 lines (73 loc) 2.3 kB
/** * @license *------------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the package root for more information *------------------------------------------------------------------------------------------- */ import * as C from "react"; import { createId as g, ZERO_LEVEL_ZERO_ITEM_ID as y } from "./itemsIdsUtils.mjs"; import { MenuItem as x } from "../components/MenuItem.mjs"; function L(e, n) { if (e && e.length > 0) return { items: c(e), inputItems: e }; if (s(n).length > 0) { const t = R(s(n)); return { items: c(t), inputItems: t }; } return { items: [], inputItems: [] }; } function h(e, n) { const t = {}, { text: i, url: o, icon: r, svgIcon: d, disabled: u, cssClass: f, cssStyle: a, render: l, linkRender: p, contentRender: m, data: I, separator: v } = e || n.props; return i !== void 0 && (t.text = i), o !== void 0 && (t.url = o), r !== void 0 && (t.icon = r), d !== void 0 && (t.svgIcon = d), u !== void 0 && (t.disabled = u), f !== void 0 && (t.cssClass = f), a !== void 0 && (t.cssStyle = a), l !== void 0 && (t.render = l), p !== void 0 && (t.linkRender = p), m !== void 0 && (t.contentRender = m), I !== void 0 && (t.data = I), v !== void 0 && (t.separator = v), t; } function s(e) { return C.Children.toArray(e).filter((n) => n && n.type === x); } function R(e) { const n = []; for (let t = 0; t < e.length; t++) { const i = e[t], o = h(void 0, i), r = R(s(i.props.children)); r.length > 0 && (o.items = r), n.push(o); } return n; } function c(e, n) { const t = []; for (let i = 0; i < e.length; i++) { const o = e[i], r = h(o); r.id = g(i.toString(), n), r.isLastFromSiblings = i === e.length - 1, r.separator = o.separator === !0, r.items = E(o, r), t.push(r); } return t; } function E(e, n) { return e.contentRender ? [ { contentParentItemId: n.id, id: g(y, n.id), isLastFromSiblings: !0, separator: !1, contentRender: e.contentRender, items: [] } ] : e.items ? c(e.items, n.id) : []; } export { L as prepareInputItemsForInternalWork };