@progress/kendo-react-layout
Version:
React Layout components enable you to create a perceptive and intuitive layout of web projects. KendoReact Layout package
137 lines (136 loc) • 4.48 kB
JavaScript
/**
* @license
*-------------------------------------------------------------------------------------------
* Copyright © 2026 Progress Software Corporation. All rights reserved.
* Licensed under commercial license. See LICENSE.md in the package root for more information
*-------------------------------------------------------------------------------------------
*/
import * as i from "react";
import { PanelBarItem as g } from "./PanelBarItem.mjs";
import { NavigationAction as d } from "./interfaces/NavigationAction.mjs";
const q = (r) => typeof r != "object" || !("type" in r) || r.type !== g, C = ({
animation: r = !0,
keepItemsMounted: n = !1,
state: e,
expanded: p,
handleSelect: t,
children: o,
parentExpanded: f = !0,
level: s = 0,
parentPrivateKey: c = [],
activeDescendantRef: m
}) => {
const y = i.Children.toArray(o).filter(q), v = y.length ? y : o;
return i.Children.map(v, (u, x) => {
if (u && u.type === g) {
let b;
const a = l(u, c, x);
if (u.props.children) {
const F = {
animation: r,
keepItemsMounted: n,
state: e,
expanded: p,
handleSelect: t,
children: u.props.children,
parentExpanded: (p || []).indexOf(a) > -1,
level: s + 1,
parentPrivateKey: [...c, a],
activeDescendantRef: m
};
b = C(F);
}
const E = u.props.id || `k-panelbar-item-default-${a}`;
return m && e.wrapperFocused && e.focused === a && (m.current = E), i.cloneElement(u, {
...u.props,
animation: u.props.animation !== void 0 ? u.props.animation : r,
keepItemsMounted: n,
id: E,
uniquePrivateKey: a,
parentUniquePrivateKey: c,
parentExpanded: f,
level: s,
expanded: (p || []).indexOf(a) > -1,
focused: e.focused === a && e.wrapperFocused,
selected: e.selected === a,
children: b,
onSelect: t
});
}
return /* @__PURE__ */ i.createElement("div", { className: "k-panelbar-content", "aria-hidden": f ? void 0 : "true" }, u);
});
}, K = (r) => {
const n = i.Children.toArray(r.children)[0];
return n ? l(n, [], 0) : "";
}, k = (r, n, e = {
expanded: r.expanded || [],
selected: r.selected || "",
focused: r.focused || "",
wrapperFocused: !1
}, p = !0, t = []) => (i.Children.map(r.children, (o, f) => {
if (o && o.type === g) {
const s = l(o, t, f);
!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 = k(o.props, n, e, !!o.props.expanded, [
...t,
s
])));
}
}), e), l = (r, n, e) => r && r.props && r.props.id ? r.props.id : n.length ? n[n.length - 1] + `.${e}` : `.${e}`;
function w(r, n = []) {
return (r || []).forEach((e) => {
e.disabled || (n.push(e), e.expanded && e.children && w(e.children, n));
}), n;
}
function P(r, n = []) {
return i.Children.forEach(r, (e) => {
e && e.props && !e.props.disabled && (n.push(e), e.props.children && P(e.props.children, n));
}), n;
}
function A(r, n = []) {
return i.Children.forEach(r, (e) => {
e && e.props && (e.props.expanded || e.props.parentExpanded) && (n.push(e), e.props.children && A(e.props.children, n));
}), n;
}
const L = (r) => r != null;
var I;
((r) => {
function n(e) {
return e.map((p, t) => {
let o;
return p.content && (o = p.content), p.children && (o = n(p.children)), /* @__PURE__ */ i.createElement(g, { ...p, children: o, key: p.id || t });
});
}
r.mapItemsToComponents = n;
})(I || (I = {}));
const N = (r, n) => r.length !== n.length ? !1 : r.every((e, p) => e === n[p]), O = (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((f, s) => {
if (f.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 {
I as PanelBarUtils,
P as flatChildren,
A as flatVisibleChildren,
w as flatVisibleItems,
K as getFirstId,
O as getFocusedChild,
k as getInitialState,
N as isArrayEqual,
L as isPresent,
C as renderChildren
};