UNPKG

@progress/kendo-react-layout

Version:

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

134 lines (133 loc) 4.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 f from "react"; import { PanelBarItem as g } from "./PanelBarItem.mjs"; import { NavigationAction as d } from "./interfaces/NavigationAction.mjs"; const I = (r) => typeof r != "object" || !("type" in r) || r.type !== g, F = ({ animation: r = !0, keepItemsMounted: n = !1, state: e, expanded: p, handleSelect: t, children: o, parentExpanded: i = !0, level: s = 0, parentPrivateKey: c = [] }) => { const l = f.Children.toArray(o).filter(I), b = l.length ? l : o; return f.Children.map(b, (a, x) => { if (a && a.type === g) { let y; const u = m(a, c, x); if (a.props.children) { const v = { animation: r, keepItemsMounted: n, state: e, expanded: p, handleSelect: t, children: a.props.children, parentExpanded: (p || []).indexOf(u) > -1, level: s + 1, parentPrivateKey: [...c, u] }; y = F(v); } return f.cloneElement(a, { ...a.props, animation: a.props.animation !== void 0 ? a.props.animation : r, keepItemsMounted: n, id: a.props.id || `k-panelbar-item-default-${u}`, uniquePrivateKey: u, parentUniquePrivateKey: c, parentExpanded: i, level: s, expanded: (p || []).indexOf(u) > -1, focused: e.focused === u && e.wrapperFocused, selected: e.selected === u, children: y, onSelect: t }); } return /* @__PURE__ */ f.createElement("div", { className: "k-panelbar-content" }, a); }); }, $ = (r) => { const n = f.Children.toArray(r.children)[0]; return n ? m(n, [], 0) : ""; }, q = (r, n, e = { expanded: r.expanded || [], selected: r.selected || "", focused: r.focused || "", wrapperFocused: !1 }, p = !0, t = []) => (f.Children.map(r.children, (o, i) => { if (o && o.type === g) { const s = m(o, t, i); !o.props.disabled && p && (o.props.selected && (e.selected = s), o.props.focused && (e.focused = s), o.props.expanded && (n === "multiple" ? e.expanded.push(s) : n === "single" && (e.expanded = [s])), o.props.children && (e = q(o.props, n, e, !!o.props.expanded, [ ...t, s ]))); } }), e), m = (r, n, e) => r && r.props && r.props.id ? r.props.id : n.length ? n[n.length - 1] + `.${e}` : `.${e}`; function C(r, n = []) { return (r || []).forEach((e) => { e.disabled || (n.push(e), e.expanded && e.children && C(e.children, n)); }), n; } function k(r, n = []) { return f.Children.forEach(r, (e) => { e && e.props && !e.props.disabled && (n.push(e), e.props.children && k(e.props.children, n)); }), n; } function P(r, n = []) { return f.Children.forEach(r, (e) => { e && e.props && (e.props.expanded || e.props.parentExpanded) && (n.push(e), e.props.children && P(e.props.children, n)); }), n; } const B = (r) => r != null; var E; ((r) => { function n(e) { return e.map((p, t) => { let o; return p.content && (o = p.content), p.children && (o = n(p.children)), /* @__PURE__ */ f.createElement(g, { ...p, children: o, key: p.id || t }); }); } r.mapItemsToComponents = n; })(E || (E = {})); const K = (r, n) => r.length !== n.length ? !1 : r.every((e, p) => e === n[p]), L = (r, n, e, p, t) => { let o; if (t === d.First || t === d.Last) switch (t) { case d.First: o = r[0]; break; case d.Last: o = r[r.length - 1]; break; } else r.forEach((i, s) => { if (i.props.uniquePrivateKey === (e.uniquePrivateKey || p)) { const c = s + n < 0 ? r.length - 1 : s + n > r.length - 1 ? 0 : s + n; o = r[c]; } }); return o; }; export { E as PanelBarUtils, k as flatChildren, P as flatVisibleChildren, C as flatVisibleItems, $ as getFirstId, L as getFocusedChild, q as getInitialState, K as isArrayEqual, B as isPresent, F as renderChildren };