UNPKG

@progress/kendo-vue-listbox

Version:
9 lines (8 loc) 2.13 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 S=(t=[],f=[],a,n)=>{let r=[],i=[],s=[],c={listBoxOneData:t,listBoxTwoData:f};switch(a){case"moveUp":r=[...t],r.forEach((e,o)=>{e[n]&&(r=u(o,o-1,r))}),s=[...f],s.forEach((e,o)=>{e[n]&&(s=u(o,o-1,s))}),c.listBoxOneData=r,c.listBoxTwoData=s;break;case"moveDown":r=t.reverse(),r.forEach((e,o)=>{e[n]&&(r=u(o,o-1,r))}),s=f.reverse(),s.forEach((e,o)=>{e[n]&&(s=u(o,o-1,s))}),c.listBoxOneData=[...r].reverse(),c.listBoxTwoData=[...s].reverse();break;case"transferTo":r=t.filter(e=>!e[n]),i=t.filter(e=>e[n]),s=f.concat(i),c.listBoxOneData=r,c.listBoxTwoData=s;break;case"transferFrom":s=f.filter(e=>!e[n]),i=f.filter(e=>e[n]),r=t.concat(i),c.listBoxOneData=r,c.listBoxTwoData=s;break;case"transferAllTo":c.listBoxOneData=[],c.listBoxTwoData=f.concat(t);break;case"transferAllFrom":c.listBoxOneData=f.concat(t),c.listBoxTwoData=[];break;case"remove":s=f.filter(e=>!e[n]),r=t.filter(e=>!e[n]),c.listBoxOneData=r,c.listBoxTwoData=s;break}return c},u=(t,f,a)=>{let n=a.splice(t,1)[0];return a.splice(f,0,n),a},g=(t=[],f=[],a,n,r)=>{let i=t.findIndex(I=>I[r]===a[r]),s=f.findIndex(I=>I[r]===a[r]),c=n!==null?t.findIndex(I=>I[r]===n[r]):-1,e=n!==null?f.findIndex(I=>I[r]===n[r]):-1,o=i>=0,l=s>=0,m=c>=0,b=e>=0,p=[...t],L=[...f];return o&&m?{listBoxOneData:u(i,c,t),listBoxTwoData:f}:l&&b?{listBoxOneData:t,listBoxTwoData:u(s,e,f)}:o&&(b||n===null)?(n===null?L.push(t[i]):L.splice(e+1,0,t[i]),p.splice(i,1),{listBoxOneData:p,listBoxTwoData:L}):l&&(m||n===null)?(n===null?p.push(f[s]):p.splice(c+1,0,f[s]),L.splice(s,1),{listBoxOneData:p,listBoxTwoData:L}):{listBoxOneData:t,listBoxTwoData:f}};exports.moveItem=u;exports.processListBoxData=S;exports.processListBoxDragAndDrop=g;