UNPKG

@progress/kendo-vue-layout

Version:
9 lines (8 loc) 2.45 kB
/** * @license *------------------------------------------------------------------------------------------- * Copyright © 2025 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 f=require("@progress/kendo-vue-common"),g=function(t,{animation:n=!0,keepItemsMounted:e=!1,state:i,expanded:d,handleSelect:r,parentExpanded:c=!0,level:u=0,parentPrivateKey:o=[]}){return t.map(function(s,S){let p,a=l(s,o,S);const F=f.templateRendering.call(this,s.content,f.getListeners.call(this)),h=f.templateRendering.call(this,s.header,f.getListeners.call(this));if(s.items){const q={animation:n,keepItemsMounted:e,state:i,expanded:d,handleSelect:r,parentExpanded:(d||[]).indexOf(a)>-1,level:u+1,parentPrivateKey:[...o,a]};p=g.call(this,s.items,q)}return{...s,animation:s.animation!==void 0?s.animation:n,keepItemsMounted:e,id:s.id||`k-panelbar-item-default-${a}`,uniquePrivateKey:a,parentUniquePrivateKey:o,parentExpanded:c,level:u,expanded:(d||[]).indexOf(a)>-1,focused:i.currentFocused===a&&i.wrapperFocused,selected:i.currentSelected===a,items:p,content:F,header:h}},this)},I=t=>{const n=t.items[0];return n?l(n,[],0):""},E=(t,n,e={currentExpanded:t.expanded||[],currentSelected:t.selected||"",currentFocused:t.focused||"",wrapperFocused:!1},i=!0,d=[])=>(t.items.forEach((r,c)=>{let u=l(r,d,c);!r.disabled&&i&&(r.selected&&(e.currentSelected=u),r.focused&&(e.currentFocused=u),r.expanded&&(n==="multiple"?e.currentExpanded.push(u):n==="single"&&(e.currentExpanded=[u])),r.items&&(e=E(r,n,e,!!r.expanded,[...d,u])))}),e),l=(t,n,e)=>t&&t&&t.id?t.id:n.length?n[n.length-1]+`.${e}`:`.${e}`;function m(t,n=[]){return(t||[]).forEach(e=>{e.disabled||(n.push(e),e.expanded&&e.children&&m(e.children,n))}),n}function x(t,n=[]){return t.forEach(e=>{e&&e&&!e.disabled&&(n.push(e),e.items&&x(e.items,n))}),n}function b(t,n=[]){return t.forEach(e=>{e&&(e.expanded||e.parentExpanded)&&(n.push(e),e.items&&b(e.items,n))}),n}const C=t=>t!=null,y=(t,n)=>t.length!==n.length?!1:t.every((e,i)=>e===n[i]);exports.flatChildren=x;exports.flatVisibleChildren=b;exports.flatVisibleItems=m;exports.getFirstId=I;exports.getInitialState=E;exports.isArrayEqual=y;exports.isPresent=C;exports.renderChildren=g;