@progress/kendo-react-layout
Version:
React Layout components enable you to create a perceptive and intuitive layout of web projects. KendoReact Layout package
9 lines (8 loc) • 3.72 kB
JavaScript
/**
* @license
*-------------------------------------------------------------------------------------------
* Copyright © 2025 Progress Software Corporation. All rights reserved.
* Licensed under commercial license. See LICENSE.md in the package root for more information
*-------------------------------------------------------------------------------------------
*/
;Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const B=require("react"),l=require("./PanelBarItem.js"),d=require("./interfaces/NavigationAction.js");function F(n){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const e in n)if(e!=="default"){const o=Object.getOwnPropertyDescriptor(n,e);Object.defineProperty(r,e,o.get?o:{enumerable:!0,get:()=>n[e]})}}return r.default=n,Object.freeze(r)}const i=F(B),O=n=>typeof n!="object"||!("type"in n)||n.type!==l.PanelBarItem,y=({animation:n=!0,keepItemsMounted:r=!1,state:e,expanded:o,handleSelect:a,children:t,parentExpanded:c=!0,level:s=0,parentPrivateKey:f=[]})=>{const b=i.Children.toArray(t).filter(O),q=b.length?b:t;return i.Children.map(q,(p,C)=>{if(p&&p.type===l.PanelBarItem){let m;const u=g(p,f,C);if(p.props.children){const A={animation:n,keepItemsMounted:r,state:e,expanded:o,handleSelect:a,children:p.props.children,parentExpanded:(o||[]).indexOf(u)>-1,level:s+1,parentPrivateKey:[...f,u]};m=y(A)}return i.cloneElement(p,{...p.props,animation:p.props.animation!==void 0?p.props.animation:n,keepItemsMounted:r,id:p.props.id||`k-panelbar-item-default-${u}`,uniquePrivateKey:u,parentUniquePrivateKey:f,parentExpanded:c,level:s,expanded:(o||[]).indexOf(u)>-1,focused:e.focused===u&&e.wrapperFocused,selected:e.selected===u,children:m,onSelect:a})}return i.createElement("div",{className:"k-panelbar-content"},p)})},x=n=>{const r=i.Children.toArray(n.children)[0];return r?g(r,[],0):""},I=(n,r,e={expanded:n.expanded||[],selected:n.selected||"",focused:n.focused||"",wrapperFocused:!1},o=!0,a=[])=>(i.Children.map(n.children,(t,c)=>{if(t&&t.type===l.PanelBarItem){const s=g(t,a,c);!t.props.disabled&&o&&(t.props.selected&&(e.selected=s),t.props.focused&&(e.focused=s),t.props.expanded&&(r==="multiple"?e.expanded.push(s):r==="single"&&(e.expanded=[s])),t.props.children&&(e=I(t.props,r,e,!!t.props.expanded,[...a,s])))}}),e),g=(n,r,e)=>n&&n.props&&n.props.id?n.props.id:r.length?r[r.length-1]+`.${e}`:`.${e}`;function P(n,r=[]){return(n||[]).forEach(e=>{e.disabled||(r.push(e),e.expanded&&e.children&&P(e.children,r))}),r}function v(n,r=[]){return i.Children.forEach(n,e=>{e&&e.props&&!e.props.disabled&&(r.push(e),e.props.children&&v(e.props.children,r))}),r}function E(n,r=[]){return i.Children.forEach(n,e=>{e&&e.props&&(e.props.expanded||e.props.parentExpanded)&&(r.push(e),e.props.children&&E(e.props.children,r))}),r}const N=n=>n!=null;exports.PanelBarUtils=void 0;(n=>{function r(e){return e.map((o,a)=>{let t;return o.content&&(t=o.content),o.children&&(t=r(o.children)),i.createElement(l.PanelBarItem,{...o,children:t,key:o.id||a})})}n.mapItemsToComponents=r})(exports.PanelBarUtils||(exports.PanelBarUtils={}));const S=(n,r)=>n.length!==r.length?!1:n.every((e,o)=>e===r[o]),j=(n,r,e,o,a)=>{let t;if(a===d.NavigationAction.First||a===d.NavigationAction.Last)switch(a){case d.NavigationAction.First:t=n[0];break;case d.NavigationAction.Last:t=n[n.length-1];break}else n.forEach((c,s)=>{if(c.props.uniquePrivateKey===(e.uniquePrivateKey||o)){const f=s+r<0?n.length-1:s+r>n.length-1?0:s+r;t=n[f]}});return t};exports.flatChildren=v;exports.flatVisibleChildren=E;exports.flatVisibleItems=P;exports.getFirstId=x;exports.getFocusedChild=j;exports.getInitialState=I;exports.isArrayEqual=S;exports.isPresent=N;exports.renderChildren=y;