UNPKG

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