Build 541864stable
Module 111613
1,065 characters · in no known chunkDependencies
Source Raw
function(e,t,n){"use strict";n.d(t,{Ay:()=>l,E8:()=>o}),n(321073);var i=n(735438),r=n.n(i);let s=new(n(626584)).A("DragAndDropUtils");function a(e){let{oldOrdering:t,newOrdering:n,idGetter:i,existingPositionGetter:r,ascending:a=!0}=e,o=n.length;if(t.length!==o)return s.warn("Arrays are not of the same length!",t,n),[];let l=t.map(i).sort().join(":"),u=n.map(i).sort().join(":");if(l!==u)return s.warn("Object IDs in the old ordering and the new ordering are not the same.",l,u),[];let c={};for(let e=0;e<o;e++)c[i(t[e])]=r(t[e]);let d=[];for(let e=0;e<o;e++){let t=i(n[e]),s=c[t],l=a?e:o-1-e;(s!==l||r(n[e])!==l)&&d.push({id:t,position:l})}return a||d.reverse(),d}function o(e,t,n){let i=e[t],r=[...e];return r.splice(t,1),r.splice(n,0,i),r}let l={moveItemFromTo:o,calculatePositionDeltas:a,getPositionUpdates:function(e){let{objectArray:t,fromPosition:n,toPosition:i,idGetter:s,existingPositionGetter:l,ascending:u=!0}=e;Array.isArray(t)||(t=r().values(t));let c=o(t,n,i);return a({oldOrdering:t,newOrdering:c,idGetter:s,existingPositionGetter:l,ascending:u})}}}