sortablejs.js 101 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874
  1. import "./chunk-HM4MQYWN.js";
  2. // node_modules/sortablejs/modular/sortable.esm.js
  3. function ownKeys(object, enumerableOnly) {
  4. var keys = Object.keys(object);
  5. if (Object.getOwnPropertySymbols) {
  6. var symbols = Object.getOwnPropertySymbols(object);
  7. if (enumerableOnly) {
  8. symbols = symbols.filter(function(sym) {
  9. return Object.getOwnPropertyDescriptor(object, sym).enumerable;
  10. });
  11. }
  12. keys.push.apply(keys, symbols);
  13. }
  14. return keys;
  15. }
  16. function _objectSpread2(target) {
  17. for (var i = 1; i < arguments.length; i++) {
  18. var source = arguments[i] != null ? arguments[i] : {};
  19. if (i % 2) {
  20. ownKeys(Object(source), true).forEach(function(key) {
  21. _defineProperty(target, key, source[key]);
  22. });
  23. } else if (Object.getOwnPropertyDescriptors) {
  24. Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
  25. } else {
  26. ownKeys(Object(source)).forEach(function(key) {
  27. Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
  28. });
  29. }
  30. }
  31. return target;
  32. }
  33. function _typeof(obj) {
  34. "@babel/helpers - typeof";
  35. if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
  36. _typeof = function(obj2) {
  37. return typeof obj2;
  38. };
  39. } else {
  40. _typeof = function(obj2) {
  41. return obj2 && typeof Symbol === "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
  42. };
  43. }
  44. return _typeof(obj);
  45. }
  46. function _defineProperty(obj, key, value) {
  47. if (key in obj) {
  48. Object.defineProperty(obj, key, {
  49. value,
  50. enumerable: true,
  51. configurable: true,
  52. writable: true
  53. });
  54. } else {
  55. obj[key] = value;
  56. }
  57. return obj;
  58. }
  59. function _extends() {
  60. _extends = Object.assign || function(target) {
  61. for (var i = 1; i < arguments.length; i++) {
  62. var source = arguments[i];
  63. for (var key in source) {
  64. if (Object.prototype.hasOwnProperty.call(source, key)) {
  65. target[key] = source[key];
  66. }
  67. }
  68. }
  69. return target;
  70. };
  71. return _extends.apply(this, arguments);
  72. }
  73. function _objectWithoutPropertiesLoose(source, excluded) {
  74. if (source == null)
  75. return {};
  76. var target = {};
  77. var sourceKeys = Object.keys(source);
  78. var key, i;
  79. for (i = 0; i < sourceKeys.length; i++) {
  80. key = sourceKeys[i];
  81. if (excluded.indexOf(key) >= 0)
  82. continue;
  83. target[key] = source[key];
  84. }
  85. return target;
  86. }
  87. function _objectWithoutProperties(source, excluded) {
  88. if (source == null)
  89. return {};
  90. var target = _objectWithoutPropertiesLoose(source, excluded);
  91. var key, i;
  92. if (Object.getOwnPropertySymbols) {
  93. var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
  94. for (i = 0; i < sourceSymbolKeys.length; i++) {
  95. key = sourceSymbolKeys[i];
  96. if (excluded.indexOf(key) >= 0)
  97. continue;
  98. if (!Object.prototype.propertyIsEnumerable.call(source, key))
  99. continue;
  100. target[key] = source[key];
  101. }
  102. }
  103. return target;
  104. }
  105. function _toConsumableArray(arr) {
  106. return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
  107. }
  108. function _arrayWithoutHoles(arr) {
  109. if (Array.isArray(arr))
  110. return _arrayLikeToArray(arr);
  111. }
  112. function _iterableToArray(iter) {
  113. if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null)
  114. return Array.from(iter);
  115. }
  116. function _unsupportedIterableToArray(o, minLen) {
  117. if (!o)
  118. return;
  119. if (typeof o === "string")
  120. return _arrayLikeToArray(o, minLen);
  121. var n = Object.prototype.toString.call(o).slice(8, -1);
  122. if (n === "Object" && o.constructor)
  123. n = o.constructor.name;
  124. if (n === "Map" || n === "Set")
  125. return Array.from(o);
  126. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
  127. return _arrayLikeToArray(o, minLen);
  128. }
  129. function _arrayLikeToArray(arr, len) {
  130. if (len == null || len > arr.length)
  131. len = arr.length;
  132. for (var i = 0, arr2 = new Array(len); i < len; i++)
  133. arr2[i] = arr[i];
  134. return arr2;
  135. }
  136. function _nonIterableSpread() {
  137. throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  138. }
  139. var version = "1.15.2";
  140. function userAgent(pattern) {
  141. if (typeof window !== "undefined" && window.navigator) {
  142. return !!navigator.userAgent.match(pattern);
  143. }
  144. }
  145. var IE11OrLess = userAgent(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i);
  146. var Edge = userAgent(/Edge/i);
  147. var FireFox = userAgent(/firefox/i);
  148. var Safari = userAgent(/safari/i) && !userAgent(/chrome/i) && !userAgent(/android/i);
  149. var IOS = userAgent(/iP(ad|od|hone)/i);
  150. var ChromeForAndroid = userAgent(/chrome/i) && userAgent(/android/i);
  151. var captureMode = {
  152. capture: false,
  153. passive: false
  154. };
  155. function on(el, event, fn) {
  156. el.addEventListener(event, fn, !IE11OrLess && captureMode);
  157. }
  158. function off(el, event, fn) {
  159. el.removeEventListener(event, fn, !IE11OrLess && captureMode);
  160. }
  161. function matches(el, selector) {
  162. if (!selector)
  163. return;
  164. selector[0] === ">" && (selector = selector.substring(1));
  165. if (el) {
  166. try {
  167. if (el.matches) {
  168. return el.matches(selector);
  169. } else if (el.msMatchesSelector) {
  170. return el.msMatchesSelector(selector);
  171. } else if (el.webkitMatchesSelector) {
  172. return el.webkitMatchesSelector(selector);
  173. }
  174. } catch (_) {
  175. return false;
  176. }
  177. }
  178. return false;
  179. }
  180. function getParentOrHost(el) {
  181. return el.host && el !== document && el.host.nodeType ? el.host : el.parentNode;
  182. }
  183. function closest(el, selector, ctx, includeCTX) {
  184. if (el) {
  185. ctx = ctx || document;
  186. do {
  187. if (selector != null && (selector[0] === ">" ? el.parentNode === ctx && matches(el, selector) : matches(el, selector)) || includeCTX && el === ctx) {
  188. return el;
  189. }
  190. if (el === ctx)
  191. break;
  192. } while (el = getParentOrHost(el));
  193. }
  194. return null;
  195. }
  196. var R_SPACE = /\s+/g;
  197. function toggleClass(el, name, state) {
  198. if (el && name) {
  199. if (el.classList) {
  200. el.classList[state ? "add" : "remove"](name);
  201. } else {
  202. var className = (" " + el.className + " ").replace(R_SPACE, " ").replace(" " + name + " ", " ");
  203. el.className = (className + (state ? " " + name : "")).replace(R_SPACE, " ");
  204. }
  205. }
  206. }
  207. function css(el, prop, val) {
  208. var style = el && el.style;
  209. if (style) {
  210. if (val === void 0) {
  211. if (document.defaultView && document.defaultView.getComputedStyle) {
  212. val = document.defaultView.getComputedStyle(el, "");
  213. } else if (el.currentStyle) {
  214. val = el.currentStyle;
  215. }
  216. return prop === void 0 ? val : val[prop];
  217. } else {
  218. if (!(prop in style) && prop.indexOf("webkit") === -1) {
  219. prop = "-webkit-" + prop;
  220. }
  221. style[prop] = val + (typeof val === "string" ? "" : "px");
  222. }
  223. }
  224. }
  225. function matrix(el, selfOnly) {
  226. var appliedTransforms = "";
  227. if (typeof el === "string") {
  228. appliedTransforms = el;
  229. } else {
  230. do {
  231. var transform = css(el, "transform");
  232. if (transform && transform !== "none") {
  233. appliedTransforms = transform + " " + appliedTransforms;
  234. }
  235. } while (!selfOnly && (el = el.parentNode));
  236. }
  237. var matrixFn = window.DOMMatrix || window.WebKitCSSMatrix || window.CSSMatrix || window.MSCSSMatrix;
  238. return matrixFn && new matrixFn(appliedTransforms);
  239. }
  240. function find(ctx, tagName, iterator) {
  241. if (ctx) {
  242. var list = ctx.getElementsByTagName(tagName), i = 0, n = list.length;
  243. if (iterator) {
  244. for (; i < n; i++) {
  245. iterator(list[i], i);
  246. }
  247. }
  248. return list;
  249. }
  250. return [];
  251. }
  252. function getWindowScrollingElement() {
  253. var scrollingElement = document.scrollingElement;
  254. if (scrollingElement) {
  255. return scrollingElement;
  256. } else {
  257. return document.documentElement;
  258. }
  259. }
  260. function getRect(el, relativeToContainingBlock, relativeToNonStaticParent, undoScale, container) {
  261. if (!el.getBoundingClientRect && el !== window)
  262. return;
  263. var elRect, top, left, bottom, right, height, width;
  264. if (el !== window && el.parentNode && el !== getWindowScrollingElement()) {
  265. elRect = el.getBoundingClientRect();
  266. top = elRect.top;
  267. left = elRect.left;
  268. bottom = elRect.bottom;
  269. right = elRect.right;
  270. height = elRect.height;
  271. width = elRect.width;
  272. } else {
  273. top = 0;
  274. left = 0;
  275. bottom = window.innerHeight;
  276. right = window.innerWidth;
  277. height = window.innerHeight;
  278. width = window.innerWidth;
  279. }
  280. if ((relativeToContainingBlock || relativeToNonStaticParent) && el !== window) {
  281. container = container || el.parentNode;
  282. if (!IE11OrLess) {
  283. do {
  284. if (container && container.getBoundingClientRect && (css(container, "transform") !== "none" || relativeToNonStaticParent && css(container, "position") !== "static")) {
  285. var containerRect = container.getBoundingClientRect();
  286. top -= containerRect.top + parseInt(css(container, "border-top-width"));
  287. left -= containerRect.left + parseInt(css(container, "border-left-width"));
  288. bottom = top + elRect.height;
  289. right = left + elRect.width;
  290. break;
  291. }
  292. } while (container = container.parentNode);
  293. }
  294. }
  295. if (undoScale && el !== window) {
  296. var elMatrix = matrix(container || el), scaleX = elMatrix && elMatrix.a, scaleY = elMatrix && elMatrix.d;
  297. if (elMatrix) {
  298. top /= scaleY;
  299. left /= scaleX;
  300. width /= scaleX;
  301. height /= scaleY;
  302. bottom = top + height;
  303. right = left + width;
  304. }
  305. }
  306. return {
  307. top,
  308. left,
  309. bottom,
  310. right,
  311. width,
  312. height
  313. };
  314. }
  315. function isScrolledPast(el, elSide, parentSide) {
  316. var parent = getParentAutoScrollElement(el, true), elSideVal = getRect(el)[elSide];
  317. while (parent) {
  318. var parentSideVal = getRect(parent)[parentSide], visible = void 0;
  319. if (parentSide === "top" || parentSide === "left") {
  320. visible = elSideVal >= parentSideVal;
  321. } else {
  322. visible = elSideVal <= parentSideVal;
  323. }
  324. if (!visible)
  325. return parent;
  326. if (parent === getWindowScrollingElement())
  327. break;
  328. parent = getParentAutoScrollElement(parent, false);
  329. }
  330. return false;
  331. }
  332. function getChild(el, childNum, options, includeDragEl) {
  333. var currentChild = 0, i = 0, children = el.children;
  334. while (i < children.length) {
  335. if (children[i].style.display !== "none" && children[i] !== Sortable.ghost && (includeDragEl || children[i] !== Sortable.dragged) && closest(children[i], options.draggable, el, false)) {
  336. if (currentChild === childNum) {
  337. return children[i];
  338. }
  339. currentChild++;
  340. }
  341. i++;
  342. }
  343. return null;
  344. }
  345. function lastChild(el, selector) {
  346. var last = el.lastElementChild;
  347. while (last && (last === Sortable.ghost || css(last, "display") === "none" || selector && !matches(last, selector))) {
  348. last = last.previousElementSibling;
  349. }
  350. return last || null;
  351. }
  352. function index(el, selector) {
  353. var index2 = 0;
  354. if (!el || !el.parentNode) {
  355. return -1;
  356. }
  357. while (el = el.previousElementSibling) {
  358. if (el.nodeName.toUpperCase() !== "TEMPLATE" && el !== Sortable.clone && (!selector || matches(el, selector))) {
  359. index2++;
  360. }
  361. }
  362. return index2;
  363. }
  364. function getRelativeScrollOffset(el) {
  365. var offsetLeft = 0, offsetTop = 0, winScroller = getWindowScrollingElement();
  366. if (el) {
  367. do {
  368. var elMatrix = matrix(el), scaleX = elMatrix.a, scaleY = elMatrix.d;
  369. offsetLeft += el.scrollLeft * scaleX;
  370. offsetTop += el.scrollTop * scaleY;
  371. } while (el !== winScroller && (el = el.parentNode));
  372. }
  373. return [offsetLeft, offsetTop];
  374. }
  375. function indexOfObject(arr, obj) {
  376. for (var i in arr) {
  377. if (!arr.hasOwnProperty(i))
  378. continue;
  379. for (var key in obj) {
  380. if (obj.hasOwnProperty(key) && obj[key] === arr[i][key])
  381. return Number(i);
  382. }
  383. }
  384. return -1;
  385. }
  386. function getParentAutoScrollElement(el, includeSelf) {
  387. if (!el || !el.getBoundingClientRect)
  388. return getWindowScrollingElement();
  389. var elem = el;
  390. var gotSelf = false;
  391. do {
  392. if (elem.clientWidth < elem.scrollWidth || elem.clientHeight < elem.scrollHeight) {
  393. var elemCSS = css(elem);
  394. if (elem.clientWidth < elem.scrollWidth && (elemCSS.overflowX == "auto" || elemCSS.overflowX == "scroll") || elem.clientHeight < elem.scrollHeight && (elemCSS.overflowY == "auto" || elemCSS.overflowY == "scroll")) {
  395. if (!elem.getBoundingClientRect || elem === document.body)
  396. return getWindowScrollingElement();
  397. if (gotSelf || includeSelf)
  398. return elem;
  399. gotSelf = true;
  400. }
  401. }
  402. } while (elem = elem.parentNode);
  403. return getWindowScrollingElement();
  404. }
  405. function extend(dst, src) {
  406. if (dst && src) {
  407. for (var key in src) {
  408. if (src.hasOwnProperty(key)) {
  409. dst[key] = src[key];
  410. }
  411. }
  412. }
  413. return dst;
  414. }
  415. function isRectEqual(rect1, rect2) {
  416. return Math.round(rect1.top) === Math.round(rect2.top) && Math.round(rect1.left) === Math.round(rect2.left) && Math.round(rect1.height) === Math.round(rect2.height) && Math.round(rect1.width) === Math.round(rect2.width);
  417. }
  418. var _throttleTimeout;
  419. function throttle(callback, ms) {
  420. return function() {
  421. if (!_throttleTimeout) {
  422. var args = arguments, _this = this;
  423. if (args.length === 1) {
  424. callback.call(_this, args[0]);
  425. } else {
  426. callback.apply(_this, args);
  427. }
  428. _throttleTimeout = setTimeout(function() {
  429. _throttleTimeout = void 0;
  430. }, ms);
  431. }
  432. };
  433. }
  434. function cancelThrottle() {
  435. clearTimeout(_throttleTimeout);
  436. _throttleTimeout = void 0;
  437. }
  438. function scrollBy(el, x, y) {
  439. el.scrollLeft += x;
  440. el.scrollTop += y;
  441. }
  442. function clone(el) {
  443. var Polymer = window.Polymer;
  444. var $ = window.jQuery || window.Zepto;
  445. if (Polymer && Polymer.dom) {
  446. return Polymer.dom(el).cloneNode(true);
  447. } else if ($) {
  448. return $(el).clone(true)[0];
  449. } else {
  450. return el.cloneNode(true);
  451. }
  452. }
  453. function setRect(el, rect) {
  454. css(el, "position", "absolute");
  455. css(el, "top", rect.top);
  456. css(el, "left", rect.left);
  457. css(el, "width", rect.width);
  458. css(el, "height", rect.height);
  459. }
  460. function unsetRect(el) {
  461. css(el, "position", "");
  462. css(el, "top", "");
  463. css(el, "left", "");
  464. css(el, "width", "");
  465. css(el, "height", "");
  466. }
  467. function getChildContainingRectFromElement(container, options, ghostEl2) {
  468. var rect = {};
  469. Array.from(container.children).forEach(function(child) {
  470. var _rect$left, _rect$top, _rect$right, _rect$bottom;
  471. if (!closest(child, options.draggable, container, false) || child.animated || child === ghostEl2)
  472. return;
  473. var childRect = getRect(child);
  474. rect.left = Math.min((_rect$left = rect.left) !== null && _rect$left !== void 0 ? _rect$left : Infinity, childRect.left);
  475. rect.top = Math.min((_rect$top = rect.top) !== null && _rect$top !== void 0 ? _rect$top : Infinity, childRect.top);
  476. rect.right = Math.max((_rect$right = rect.right) !== null && _rect$right !== void 0 ? _rect$right : -Infinity, childRect.right);
  477. rect.bottom = Math.max((_rect$bottom = rect.bottom) !== null && _rect$bottom !== void 0 ? _rect$bottom : -Infinity, childRect.bottom);
  478. });
  479. rect.width = rect.right - rect.left;
  480. rect.height = rect.bottom - rect.top;
  481. rect.x = rect.left;
  482. rect.y = rect.top;
  483. return rect;
  484. }
  485. var expando = "Sortable" + (/* @__PURE__ */ new Date()).getTime();
  486. function AnimationStateManager() {
  487. var animationStates = [], animationCallbackId;
  488. return {
  489. captureAnimationState: function captureAnimationState() {
  490. animationStates = [];
  491. if (!this.options.animation)
  492. return;
  493. var children = [].slice.call(this.el.children);
  494. children.forEach(function(child) {
  495. if (css(child, "display") === "none" || child === Sortable.ghost)
  496. return;
  497. animationStates.push({
  498. target: child,
  499. rect: getRect(child)
  500. });
  501. var fromRect = _objectSpread2({}, animationStates[animationStates.length - 1].rect);
  502. if (child.thisAnimationDuration) {
  503. var childMatrix = matrix(child, true);
  504. if (childMatrix) {
  505. fromRect.top -= childMatrix.f;
  506. fromRect.left -= childMatrix.e;
  507. }
  508. }
  509. child.fromRect = fromRect;
  510. });
  511. },
  512. addAnimationState: function addAnimationState(state) {
  513. animationStates.push(state);
  514. },
  515. removeAnimationState: function removeAnimationState(target) {
  516. animationStates.splice(indexOfObject(animationStates, {
  517. target
  518. }), 1);
  519. },
  520. animateAll: function animateAll(callback) {
  521. var _this = this;
  522. if (!this.options.animation) {
  523. clearTimeout(animationCallbackId);
  524. if (typeof callback === "function")
  525. callback();
  526. return;
  527. }
  528. var animating = false, animationTime = 0;
  529. animationStates.forEach(function(state) {
  530. var time = 0, target = state.target, fromRect = target.fromRect, toRect = getRect(target), prevFromRect = target.prevFromRect, prevToRect = target.prevToRect, animatingRect = state.rect, targetMatrix = matrix(target, true);
  531. if (targetMatrix) {
  532. toRect.top -= targetMatrix.f;
  533. toRect.left -= targetMatrix.e;
  534. }
  535. target.toRect = toRect;
  536. if (target.thisAnimationDuration) {
  537. if (isRectEqual(prevFromRect, toRect) && !isRectEqual(fromRect, toRect) && // Make sure animatingRect is on line between toRect & fromRect
  538. (animatingRect.top - toRect.top) / (animatingRect.left - toRect.left) === (fromRect.top - toRect.top) / (fromRect.left - toRect.left)) {
  539. time = calculateRealTime(animatingRect, prevFromRect, prevToRect, _this.options);
  540. }
  541. }
  542. if (!isRectEqual(toRect, fromRect)) {
  543. target.prevFromRect = fromRect;
  544. target.prevToRect = toRect;
  545. if (!time) {
  546. time = _this.options.animation;
  547. }
  548. _this.animate(target, animatingRect, toRect, time);
  549. }
  550. if (time) {
  551. animating = true;
  552. animationTime = Math.max(animationTime, time);
  553. clearTimeout(target.animationResetTimer);
  554. target.animationResetTimer = setTimeout(function() {
  555. target.animationTime = 0;
  556. target.prevFromRect = null;
  557. target.fromRect = null;
  558. target.prevToRect = null;
  559. target.thisAnimationDuration = null;
  560. }, time);
  561. target.thisAnimationDuration = time;
  562. }
  563. });
  564. clearTimeout(animationCallbackId);
  565. if (!animating) {
  566. if (typeof callback === "function")
  567. callback();
  568. } else {
  569. animationCallbackId = setTimeout(function() {
  570. if (typeof callback === "function")
  571. callback();
  572. }, animationTime);
  573. }
  574. animationStates = [];
  575. },
  576. animate: function animate(target, currentRect, toRect, duration) {
  577. if (duration) {
  578. css(target, "transition", "");
  579. css(target, "transform", "");
  580. var elMatrix = matrix(this.el), scaleX = elMatrix && elMatrix.a, scaleY = elMatrix && elMatrix.d, translateX = (currentRect.left - toRect.left) / (scaleX || 1), translateY = (currentRect.top - toRect.top) / (scaleY || 1);
  581. target.animatingX = !!translateX;
  582. target.animatingY = !!translateY;
  583. css(target, "transform", "translate3d(" + translateX + "px," + translateY + "px,0)");
  584. this.forRepaintDummy = repaint(target);
  585. css(target, "transition", "transform " + duration + "ms" + (this.options.easing ? " " + this.options.easing : ""));
  586. css(target, "transform", "translate3d(0,0,0)");
  587. typeof target.animated === "number" && clearTimeout(target.animated);
  588. target.animated = setTimeout(function() {
  589. css(target, "transition", "");
  590. css(target, "transform", "");
  591. target.animated = false;
  592. target.animatingX = false;
  593. target.animatingY = false;
  594. }, duration);
  595. }
  596. }
  597. };
  598. }
  599. function repaint(target) {
  600. return target.offsetWidth;
  601. }
  602. function calculateRealTime(animatingRect, fromRect, toRect, options) {
  603. return Math.sqrt(Math.pow(fromRect.top - animatingRect.top, 2) + Math.pow(fromRect.left - animatingRect.left, 2)) / Math.sqrt(Math.pow(fromRect.top - toRect.top, 2) + Math.pow(fromRect.left - toRect.left, 2)) * options.animation;
  604. }
  605. var plugins = [];
  606. var defaults = {
  607. initializeByDefault: true
  608. };
  609. var PluginManager = {
  610. mount: function mount(plugin) {
  611. for (var option2 in defaults) {
  612. if (defaults.hasOwnProperty(option2) && !(option2 in plugin)) {
  613. plugin[option2] = defaults[option2];
  614. }
  615. }
  616. plugins.forEach(function(p) {
  617. if (p.pluginName === plugin.pluginName) {
  618. throw "Sortable: Cannot mount plugin ".concat(plugin.pluginName, " more than once");
  619. }
  620. });
  621. plugins.push(plugin);
  622. },
  623. pluginEvent: function pluginEvent(eventName, sortable, evt) {
  624. var _this = this;
  625. this.eventCanceled = false;
  626. evt.cancel = function() {
  627. _this.eventCanceled = true;
  628. };
  629. var eventNameGlobal = eventName + "Global";
  630. plugins.forEach(function(plugin) {
  631. if (!sortable[plugin.pluginName])
  632. return;
  633. if (sortable[plugin.pluginName][eventNameGlobal]) {
  634. sortable[plugin.pluginName][eventNameGlobal](_objectSpread2({
  635. sortable
  636. }, evt));
  637. }
  638. if (sortable.options[plugin.pluginName] && sortable[plugin.pluginName][eventName]) {
  639. sortable[plugin.pluginName][eventName](_objectSpread2({
  640. sortable
  641. }, evt));
  642. }
  643. });
  644. },
  645. initializePlugins: function initializePlugins(sortable, el, defaults2, options) {
  646. plugins.forEach(function(plugin) {
  647. var pluginName = plugin.pluginName;
  648. if (!sortable.options[pluginName] && !plugin.initializeByDefault)
  649. return;
  650. var initialized = new plugin(sortable, el, sortable.options);
  651. initialized.sortable = sortable;
  652. initialized.options = sortable.options;
  653. sortable[pluginName] = initialized;
  654. _extends(defaults2, initialized.defaults);
  655. });
  656. for (var option2 in sortable.options) {
  657. if (!sortable.options.hasOwnProperty(option2))
  658. continue;
  659. var modified = this.modifyOption(sortable, option2, sortable.options[option2]);
  660. if (typeof modified !== "undefined") {
  661. sortable.options[option2] = modified;
  662. }
  663. }
  664. },
  665. getEventProperties: function getEventProperties(name, sortable) {
  666. var eventProperties = {};
  667. plugins.forEach(function(plugin) {
  668. if (typeof plugin.eventProperties !== "function")
  669. return;
  670. _extends(eventProperties, plugin.eventProperties.call(sortable[plugin.pluginName], name));
  671. });
  672. return eventProperties;
  673. },
  674. modifyOption: function modifyOption(sortable, name, value) {
  675. var modifiedValue;
  676. plugins.forEach(function(plugin) {
  677. if (!sortable[plugin.pluginName])
  678. return;
  679. if (plugin.optionListeners && typeof plugin.optionListeners[name] === "function") {
  680. modifiedValue = plugin.optionListeners[name].call(sortable[plugin.pluginName], value);
  681. }
  682. });
  683. return modifiedValue;
  684. }
  685. };
  686. function dispatchEvent(_ref) {
  687. var sortable = _ref.sortable, rootEl2 = _ref.rootEl, name = _ref.name, targetEl = _ref.targetEl, cloneEl2 = _ref.cloneEl, toEl = _ref.toEl, fromEl = _ref.fromEl, oldIndex2 = _ref.oldIndex, newIndex2 = _ref.newIndex, oldDraggableIndex2 = _ref.oldDraggableIndex, newDraggableIndex2 = _ref.newDraggableIndex, originalEvent = _ref.originalEvent, putSortable2 = _ref.putSortable, extraEventProperties = _ref.extraEventProperties;
  688. sortable = sortable || rootEl2 && rootEl2[expando];
  689. if (!sortable)
  690. return;
  691. var evt, options = sortable.options, onName = "on" + name.charAt(0).toUpperCase() + name.substr(1);
  692. if (window.CustomEvent && !IE11OrLess && !Edge) {
  693. evt = new CustomEvent(name, {
  694. bubbles: true,
  695. cancelable: true
  696. });
  697. } else {
  698. evt = document.createEvent("Event");
  699. evt.initEvent(name, true, true);
  700. }
  701. evt.to = toEl || rootEl2;
  702. evt.from = fromEl || rootEl2;
  703. evt.item = targetEl || rootEl2;
  704. evt.clone = cloneEl2;
  705. evt.oldIndex = oldIndex2;
  706. evt.newIndex = newIndex2;
  707. evt.oldDraggableIndex = oldDraggableIndex2;
  708. evt.newDraggableIndex = newDraggableIndex2;
  709. evt.originalEvent = originalEvent;
  710. evt.pullMode = putSortable2 ? putSortable2.lastPutMode : void 0;
  711. var allEventProperties = _objectSpread2(_objectSpread2({}, extraEventProperties), PluginManager.getEventProperties(name, sortable));
  712. for (var option2 in allEventProperties) {
  713. evt[option2] = allEventProperties[option2];
  714. }
  715. if (rootEl2) {
  716. rootEl2.dispatchEvent(evt);
  717. }
  718. if (options[onName]) {
  719. options[onName].call(sortable, evt);
  720. }
  721. }
  722. var _excluded = ["evt"];
  723. var pluginEvent2 = function pluginEvent3(eventName, sortable) {
  724. var _ref = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, originalEvent = _ref.evt, data = _objectWithoutProperties(_ref, _excluded);
  725. PluginManager.pluginEvent.bind(Sortable)(eventName, sortable, _objectSpread2({
  726. dragEl,
  727. parentEl,
  728. ghostEl,
  729. rootEl,
  730. nextEl,
  731. lastDownEl,
  732. cloneEl,
  733. cloneHidden,
  734. dragStarted: moved,
  735. putSortable,
  736. activeSortable: Sortable.active,
  737. originalEvent,
  738. oldIndex,
  739. oldDraggableIndex,
  740. newIndex,
  741. newDraggableIndex,
  742. hideGhostForTarget: _hideGhostForTarget,
  743. unhideGhostForTarget: _unhideGhostForTarget,
  744. cloneNowHidden: function cloneNowHidden() {
  745. cloneHidden = true;
  746. },
  747. cloneNowShown: function cloneNowShown() {
  748. cloneHidden = false;
  749. },
  750. dispatchSortableEvent: function dispatchSortableEvent(name) {
  751. _dispatchEvent({
  752. sortable,
  753. name,
  754. originalEvent
  755. });
  756. }
  757. }, data));
  758. };
  759. function _dispatchEvent(info) {
  760. dispatchEvent(_objectSpread2({
  761. putSortable,
  762. cloneEl,
  763. targetEl: dragEl,
  764. rootEl,
  765. oldIndex,
  766. oldDraggableIndex,
  767. newIndex,
  768. newDraggableIndex
  769. }, info));
  770. }
  771. var dragEl;
  772. var parentEl;
  773. var ghostEl;
  774. var rootEl;
  775. var nextEl;
  776. var lastDownEl;
  777. var cloneEl;
  778. var cloneHidden;
  779. var oldIndex;
  780. var newIndex;
  781. var oldDraggableIndex;
  782. var newDraggableIndex;
  783. var activeGroup;
  784. var putSortable;
  785. var awaitingDragStarted = false;
  786. var ignoreNextClick = false;
  787. var sortables = [];
  788. var tapEvt;
  789. var touchEvt;
  790. var lastDx;
  791. var lastDy;
  792. var tapDistanceLeft;
  793. var tapDistanceTop;
  794. var moved;
  795. var lastTarget;
  796. var lastDirection;
  797. var pastFirstInvertThresh = false;
  798. var isCircumstantialInvert = false;
  799. var targetMoveDistance;
  800. var ghostRelativeParent;
  801. var ghostRelativeParentInitialScroll = [];
  802. var _silent = false;
  803. var savedInputChecked = [];
  804. var documentExists = typeof document !== "undefined";
  805. var PositionGhostAbsolutely = IOS;
  806. var CSSFloatProperty = Edge || IE11OrLess ? "cssFloat" : "float";
  807. var supportDraggable = documentExists && !ChromeForAndroid && !IOS && "draggable" in document.createElement("div");
  808. var supportCssPointerEvents = function() {
  809. if (!documentExists)
  810. return;
  811. if (IE11OrLess) {
  812. return false;
  813. }
  814. var el = document.createElement("x");
  815. el.style.cssText = "pointer-events:auto";
  816. return el.style.pointerEvents === "auto";
  817. }();
  818. var _detectDirection = function _detectDirection2(el, options) {
  819. var elCSS = css(el), elWidth = parseInt(elCSS.width) - parseInt(elCSS.paddingLeft) - parseInt(elCSS.paddingRight) - parseInt(elCSS.borderLeftWidth) - parseInt(elCSS.borderRightWidth), child1 = getChild(el, 0, options), child2 = getChild(el, 1, options), firstChildCSS = child1 && css(child1), secondChildCSS = child2 && css(child2), firstChildWidth = firstChildCSS && parseInt(firstChildCSS.marginLeft) + parseInt(firstChildCSS.marginRight) + getRect(child1).width, secondChildWidth = secondChildCSS && parseInt(secondChildCSS.marginLeft) + parseInt(secondChildCSS.marginRight) + getRect(child2).width;
  820. if (elCSS.display === "flex") {
  821. return elCSS.flexDirection === "column" || elCSS.flexDirection === "column-reverse" ? "vertical" : "horizontal";
  822. }
  823. if (elCSS.display === "grid") {
  824. return elCSS.gridTemplateColumns.split(" ").length <= 1 ? "vertical" : "horizontal";
  825. }
  826. if (child1 && firstChildCSS["float"] && firstChildCSS["float"] !== "none") {
  827. var touchingSideChild2 = firstChildCSS["float"] === "left" ? "left" : "right";
  828. return child2 && (secondChildCSS.clear === "both" || secondChildCSS.clear === touchingSideChild2) ? "vertical" : "horizontal";
  829. }
  830. return child1 && (firstChildCSS.display === "block" || firstChildCSS.display === "flex" || firstChildCSS.display === "table" || firstChildCSS.display === "grid" || firstChildWidth >= elWidth && elCSS[CSSFloatProperty] === "none" || child2 && elCSS[CSSFloatProperty] === "none" && firstChildWidth + secondChildWidth > elWidth) ? "vertical" : "horizontal";
  831. };
  832. var _dragElInRowColumn = function _dragElInRowColumn2(dragRect, targetRect, vertical) {
  833. var dragElS1Opp = vertical ? dragRect.left : dragRect.top, dragElS2Opp = vertical ? dragRect.right : dragRect.bottom, dragElOppLength = vertical ? dragRect.width : dragRect.height, targetS1Opp = vertical ? targetRect.left : targetRect.top, targetS2Opp = vertical ? targetRect.right : targetRect.bottom, targetOppLength = vertical ? targetRect.width : targetRect.height;
  834. return dragElS1Opp === targetS1Opp || dragElS2Opp === targetS2Opp || dragElS1Opp + dragElOppLength / 2 === targetS1Opp + targetOppLength / 2;
  835. };
  836. var _detectNearestEmptySortable = function _detectNearestEmptySortable2(x, y) {
  837. var ret;
  838. sortables.some(function(sortable) {
  839. var threshold = sortable[expando].options.emptyInsertThreshold;
  840. if (!threshold || lastChild(sortable))
  841. return;
  842. var rect = getRect(sortable), insideHorizontally = x >= rect.left - threshold && x <= rect.right + threshold, insideVertically = y >= rect.top - threshold && y <= rect.bottom + threshold;
  843. if (insideHorizontally && insideVertically) {
  844. return ret = sortable;
  845. }
  846. });
  847. return ret;
  848. };
  849. var _prepareGroup = function _prepareGroup2(options) {
  850. function toFn(value, pull) {
  851. return function(to, from, dragEl2, evt) {
  852. var sameGroup = to.options.group.name && from.options.group.name && to.options.group.name === from.options.group.name;
  853. if (value == null && (pull || sameGroup)) {
  854. return true;
  855. } else if (value == null || value === false) {
  856. return false;
  857. } else if (pull && value === "clone") {
  858. return value;
  859. } else if (typeof value === "function") {
  860. return toFn(value(to, from, dragEl2, evt), pull)(to, from, dragEl2, evt);
  861. } else {
  862. var otherGroup = (pull ? to : from).options.group.name;
  863. return value === true || typeof value === "string" && value === otherGroup || value.join && value.indexOf(otherGroup) > -1;
  864. }
  865. };
  866. }
  867. var group = {};
  868. var originalGroup = options.group;
  869. if (!originalGroup || _typeof(originalGroup) != "object") {
  870. originalGroup = {
  871. name: originalGroup
  872. };
  873. }
  874. group.name = originalGroup.name;
  875. group.checkPull = toFn(originalGroup.pull, true);
  876. group.checkPut = toFn(originalGroup.put);
  877. group.revertClone = originalGroup.revertClone;
  878. options.group = group;
  879. };
  880. var _hideGhostForTarget = function _hideGhostForTarget2() {
  881. if (!supportCssPointerEvents && ghostEl) {
  882. css(ghostEl, "display", "none");
  883. }
  884. };
  885. var _unhideGhostForTarget = function _unhideGhostForTarget2() {
  886. if (!supportCssPointerEvents && ghostEl) {
  887. css(ghostEl, "display", "");
  888. }
  889. };
  890. if (documentExists && !ChromeForAndroid) {
  891. document.addEventListener("click", function(evt) {
  892. if (ignoreNextClick) {
  893. evt.preventDefault();
  894. evt.stopPropagation && evt.stopPropagation();
  895. evt.stopImmediatePropagation && evt.stopImmediatePropagation();
  896. ignoreNextClick = false;
  897. return false;
  898. }
  899. }, true);
  900. }
  901. var nearestEmptyInsertDetectEvent = function nearestEmptyInsertDetectEvent2(evt) {
  902. if (dragEl) {
  903. evt = evt.touches ? evt.touches[0] : evt;
  904. var nearest = _detectNearestEmptySortable(evt.clientX, evt.clientY);
  905. if (nearest) {
  906. var event = {};
  907. for (var i in evt) {
  908. if (evt.hasOwnProperty(i)) {
  909. event[i] = evt[i];
  910. }
  911. }
  912. event.target = event.rootEl = nearest;
  913. event.preventDefault = void 0;
  914. event.stopPropagation = void 0;
  915. nearest[expando]._onDragOver(event);
  916. }
  917. }
  918. };
  919. var _checkOutsideTargetEl = function _checkOutsideTargetEl2(evt) {
  920. if (dragEl) {
  921. dragEl.parentNode[expando]._isOutsideThisEl(evt.target);
  922. }
  923. };
  924. function Sortable(el, options) {
  925. if (!(el && el.nodeType && el.nodeType === 1)) {
  926. throw "Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(el));
  927. }
  928. this.el = el;
  929. this.options = options = _extends({}, options);
  930. el[expando] = this;
  931. var defaults2 = {
  932. group: null,
  933. sort: true,
  934. disabled: false,
  935. store: null,
  936. handle: null,
  937. draggable: /^[uo]l$/i.test(el.nodeName) ? ">li" : ">*",
  938. swapThreshold: 1,
  939. // percentage; 0 <= x <= 1
  940. invertSwap: false,
  941. // invert always
  942. invertedSwapThreshold: null,
  943. // will be set to same as swapThreshold if default
  944. removeCloneOnHide: true,
  945. direction: function direction() {
  946. return _detectDirection(el, this.options);
  947. },
  948. ghostClass: "sortable-ghost",
  949. chosenClass: "sortable-chosen",
  950. dragClass: "sortable-drag",
  951. ignore: "a, img",
  952. filter: null,
  953. preventOnFilter: true,
  954. animation: 0,
  955. easing: null,
  956. setData: function setData(dataTransfer, dragEl2) {
  957. dataTransfer.setData("Text", dragEl2.textContent);
  958. },
  959. dropBubble: false,
  960. dragoverBubble: false,
  961. dataIdAttr: "data-id",
  962. delay: 0,
  963. delayOnTouchOnly: false,
  964. touchStartThreshold: (Number.parseInt ? Number : window).parseInt(window.devicePixelRatio, 10) || 1,
  965. forceFallback: false,
  966. fallbackClass: "sortable-fallback",
  967. fallbackOnBody: false,
  968. fallbackTolerance: 0,
  969. fallbackOffset: {
  970. x: 0,
  971. y: 0
  972. },
  973. supportPointer: Sortable.supportPointer !== false && "PointerEvent" in window && !Safari,
  974. emptyInsertThreshold: 5
  975. };
  976. PluginManager.initializePlugins(this, el, defaults2);
  977. for (var name in defaults2) {
  978. !(name in options) && (options[name] = defaults2[name]);
  979. }
  980. _prepareGroup(options);
  981. for (var fn in this) {
  982. if (fn.charAt(0) === "_" && typeof this[fn] === "function") {
  983. this[fn] = this[fn].bind(this);
  984. }
  985. }
  986. this.nativeDraggable = options.forceFallback ? false : supportDraggable;
  987. if (this.nativeDraggable) {
  988. this.options.touchStartThreshold = 1;
  989. }
  990. if (options.supportPointer) {
  991. on(el, "pointerdown", this._onTapStart);
  992. } else {
  993. on(el, "mousedown", this._onTapStart);
  994. on(el, "touchstart", this._onTapStart);
  995. }
  996. if (this.nativeDraggable) {
  997. on(el, "dragover", this);
  998. on(el, "dragenter", this);
  999. }
  1000. sortables.push(this.el);
  1001. options.store && options.store.get && this.sort(options.store.get(this) || []);
  1002. _extends(this, AnimationStateManager());
  1003. }
  1004. Sortable.prototype = /** @lends Sortable.prototype */
  1005. {
  1006. constructor: Sortable,
  1007. _isOutsideThisEl: function _isOutsideThisEl(target) {
  1008. if (!this.el.contains(target) && target !== this.el) {
  1009. lastTarget = null;
  1010. }
  1011. },
  1012. _getDirection: function _getDirection(evt, target) {
  1013. return typeof this.options.direction === "function" ? this.options.direction.call(this, evt, target, dragEl) : this.options.direction;
  1014. },
  1015. _onTapStart: function _onTapStart(evt) {
  1016. if (!evt.cancelable)
  1017. return;
  1018. var _this = this, el = this.el, options = this.options, preventOnFilter = options.preventOnFilter, type = evt.type, touch = evt.touches && evt.touches[0] || evt.pointerType && evt.pointerType === "touch" && evt, target = (touch || evt).target, originalTarget = evt.target.shadowRoot && (evt.path && evt.path[0] || evt.composedPath && evt.composedPath()[0]) || target, filter = options.filter;
  1019. _saveInputCheckedState(el);
  1020. if (dragEl) {
  1021. return;
  1022. }
  1023. if (/mousedown|pointerdown/.test(type) && evt.button !== 0 || options.disabled) {
  1024. return;
  1025. }
  1026. if (originalTarget.isContentEditable) {
  1027. return;
  1028. }
  1029. if (!this.nativeDraggable && Safari && target && target.tagName.toUpperCase() === "SELECT") {
  1030. return;
  1031. }
  1032. target = closest(target, options.draggable, el, false);
  1033. if (target && target.animated) {
  1034. return;
  1035. }
  1036. if (lastDownEl === target) {
  1037. return;
  1038. }
  1039. oldIndex = index(target);
  1040. oldDraggableIndex = index(target, options.draggable);
  1041. if (typeof filter === "function") {
  1042. if (filter.call(this, evt, target, this)) {
  1043. _dispatchEvent({
  1044. sortable: _this,
  1045. rootEl: originalTarget,
  1046. name: "filter",
  1047. targetEl: target,
  1048. toEl: el,
  1049. fromEl: el
  1050. });
  1051. pluginEvent2("filter", _this, {
  1052. evt
  1053. });
  1054. preventOnFilter && evt.cancelable && evt.preventDefault();
  1055. return;
  1056. }
  1057. } else if (filter) {
  1058. filter = filter.split(",").some(function(criteria) {
  1059. criteria = closest(originalTarget, criteria.trim(), el, false);
  1060. if (criteria) {
  1061. _dispatchEvent({
  1062. sortable: _this,
  1063. rootEl: criteria,
  1064. name: "filter",
  1065. targetEl: target,
  1066. fromEl: el,
  1067. toEl: el
  1068. });
  1069. pluginEvent2("filter", _this, {
  1070. evt
  1071. });
  1072. return true;
  1073. }
  1074. });
  1075. if (filter) {
  1076. preventOnFilter && evt.cancelable && evt.preventDefault();
  1077. return;
  1078. }
  1079. }
  1080. if (options.handle && !closest(originalTarget, options.handle, el, false)) {
  1081. return;
  1082. }
  1083. this._prepareDragStart(evt, touch, target);
  1084. },
  1085. _prepareDragStart: function _prepareDragStart(evt, touch, target) {
  1086. var _this = this, el = _this.el, options = _this.options, ownerDocument = el.ownerDocument, dragStartFn;
  1087. if (target && !dragEl && target.parentNode === el) {
  1088. var dragRect = getRect(target);
  1089. rootEl = el;
  1090. dragEl = target;
  1091. parentEl = dragEl.parentNode;
  1092. nextEl = dragEl.nextSibling;
  1093. lastDownEl = target;
  1094. activeGroup = options.group;
  1095. Sortable.dragged = dragEl;
  1096. tapEvt = {
  1097. target: dragEl,
  1098. clientX: (touch || evt).clientX,
  1099. clientY: (touch || evt).clientY
  1100. };
  1101. tapDistanceLeft = tapEvt.clientX - dragRect.left;
  1102. tapDistanceTop = tapEvt.clientY - dragRect.top;
  1103. this._lastX = (touch || evt).clientX;
  1104. this._lastY = (touch || evt).clientY;
  1105. dragEl.style["will-change"] = "all";
  1106. dragStartFn = function dragStartFn2() {
  1107. pluginEvent2("delayEnded", _this, {
  1108. evt
  1109. });
  1110. if (Sortable.eventCanceled) {
  1111. _this._onDrop();
  1112. return;
  1113. }
  1114. _this._disableDelayedDragEvents();
  1115. if (!FireFox && _this.nativeDraggable) {
  1116. dragEl.draggable = true;
  1117. }
  1118. _this._triggerDragStart(evt, touch);
  1119. _dispatchEvent({
  1120. sortable: _this,
  1121. name: "choose",
  1122. originalEvent: evt
  1123. });
  1124. toggleClass(dragEl, options.chosenClass, true);
  1125. };
  1126. options.ignore.split(",").forEach(function(criteria) {
  1127. find(dragEl, criteria.trim(), _disableDraggable);
  1128. });
  1129. on(ownerDocument, "dragover", nearestEmptyInsertDetectEvent);
  1130. on(ownerDocument, "mousemove", nearestEmptyInsertDetectEvent);
  1131. on(ownerDocument, "touchmove", nearestEmptyInsertDetectEvent);
  1132. on(ownerDocument, "mouseup", _this._onDrop);
  1133. on(ownerDocument, "touchend", _this._onDrop);
  1134. on(ownerDocument, "touchcancel", _this._onDrop);
  1135. if (FireFox && this.nativeDraggable) {
  1136. this.options.touchStartThreshold = 4;
  1137. dragEl.draggable = true;
  1138. }
  1139. pluginEvent2("delayStart", this, {
  1140. evt
  1141. });
  1142. if (options.delay && (!options.delayOnTouchOnly || touch) && (!this.nativeDraggable || !(Edge || IE11OrLess))) {
  1143. if (Sortable.eventCanceled) {
  1144. this._onDrop();
  1145. return;
  1146. }
  1147. on(ownerDocument, "mouseup", _this._disableDelayedDrag);
  1148. on(ownerDocument, "touchend", _this._disableDelayedDrag);
  1149. on(ownerDocument, "touchcancel", _this._disableDelayedDrag);
  1150. on(ownerDocument, "mousemove", _this._delayedDragTouchMoveHandler);
  1151. on(ownerDocument, "touchmove", _this._delayedDragTouchMoveHandler);
  1152. options.supportPointer && on(ownerDocument, "pointermove", _this._delayedDragTouchMoveHandler);
  1153. _this._dragStartTimer = setTimeout(dragStartFn, options.delay);
  1154. } else {
  1155. dragStartFn();
  1156. }
  1157. }
  1158. },
  1159. _delayedDragTouchMoveHandler: function _delayedDragTouchMoveHandler(e) {
  1160. var touch = e.touches ? e.touches[0] : e;
  1161. if (Math.max(Math.abs(touch.clientX - this._lastX), Math.abs(touch.clientY - this._lastY)) >= Math.floor(this.options.touchStartThreshold / (this.nativeDraggable && window.devicePixelRatio || 1))) {
  1162. this._disableDelayedDrag();
  1163. }
  1164. },
  1165. _disableDelayedDrag: function _disableDelayedDrag() {
  1166. dragEl && _disableDraggable(dragEl);
  1167. clearTimeout(this._dragStartTimer);
  1168. this._disableDelayedDragEvents();
  1169. },
  1170. _disableDelayedDragEvents: function _disableDelayedDragEvents() {
  1171. var ownerDocument = this.el.ownerDocument;
  1172. off(ownerDocument, "mouseup", this._disableDelayedDrag);
  1173. off(ownerDocument, "touchend", this._disableDelayedDrag);
  1174. off(ownerDocument, "touchcancel", this._disableDelayedDrag);
  1175. off(ownerDocument, "mousemove", this._delayedDragTouchMoveHandler);
  1176. off(ownerDocument, "touchmove", this._delayedDragTouchMoveHandler);
  1177. off(ownerDocument, "pointermove", this._delayedDragTouchMoveHandler);
  1178. },
  1179. _triggerDragStart: function _triggerDragStart(evt, touch) {
  1180. touch = touch || evt.pointerType == "touch" && evt;
  1181. if (!this.nativeDraggable || touch) {
  1182. if (this.options.supportPointer) {
  1183. on(document, "pointermove", this._onTouchMove);
  1184. } else if (touch) {
  1185. on(document, "touchmove", this._onTouchMove);
  1186. } else {
  1187. on(document, "mousemove", this._onTouchMove);
  1188. }
  1189. } else {
  1190. on(dragEl, "dragend", this);
  1191. on(rootEl, "dragstart", this._onDragStart);
  1192. }
  1193. try {
  1194. if (document.selection) {
  1195. _nextTick(function() {
  1196. document.selection.empty();
  1197. });
  1198. } else {
  1199. window.getSelection().removeAllRanges();
  1200. }
  1201. } catch (err) {
  1202. }
  1203. },
  1204. _dragStarted: function _dragStarted(fallback, evt) {
  1205. awaitingDragStarted = false;
  1206. if (rootEl && dragEl) {
  1207. pluginEvent2("dragStarted", this, {
  1208. evt
  1209. });
  1210. if (this.nativeDraggable) {
  1211. on(document, "dragover", _checkOutsideTargetEl);
  1212. }
  1213. var options = this.options;
  1214. !fallback && toggleClass(dragEl, options.dragClass, false);
  1215. toggleClass(dragEl, options.ghostClass, true);
  1216. Sortable.active = this;
  1217. fallback && this._appendGhost();
  1218. _dispatchEvent({
  1219. sortable: this,
  1220. name: "start",
  1221. originalEvent: evt
  1222. });
  1223. } else {
  1224. this._nulling();
  1225. }
  1226. },
  1227. _emulateDragOver: function _emulateDragOver() {
  1228. if (touchEvt) {
  1229. this._lastX = touchEvt.clientX;
  1230. this._lastY = touchEvt.clientY;
  1231. _hideGhostForTarget();
  1232. var target = document.elementFromPoint(touchEvt.clientX, touchEvt.clientY);
  1233. var parent = target;
  1234. while (target && target.shadowRoot) {
  1235. target = target.shadowRoot.elementFromPoint(touchEvt.clientX, touchEvt.clientY);
  1236. if (target === parent)
  1237. break;
  1238. parent = target;
  1239. }
  1240. dragEl.parentNode[expando]._isOutsideThisEl(target);
  1241. if (parent) {
  1242. do {
  1243. if (parent[expando]) {
  1244. var inserted = void 0;
  1245. inserted = parent[expando]._onDragOver({
  1246. clientX: touchEvt.clientX,
  1247. clientY: touchEvt.clientY,
  1248. target,
  1249. rootEl: parent
  1250. });
  1251. if (inserted && !this.options.dragoverBubble) {
  1252. break;
  1253. }
  1254. }
  1255. target = parent;
  1256. } while (parent = parent.parentNode);
  1257. }
  1258. _unhideGhostForTarget();
  1259. }
  1260. },
  1261. _onTouchMove: function _onTouchMove(evt) {
  1262. if (tapEvt) {
  1263. var options = this.options, fallbackTolerance = options.fallbackTolerance, fallbackOffset = options.fallbackOffset, touch = evt.touches ? evt.touches[0] : evt, ghostMatrix = ghostEl && matrix(ghostEl, true), scaleX = ghostEl && ghostMatrix && ghostMatrix.a, scaleY = ghostEl && ghostMatrix && ghostMatrix.d, relativeScrollOffset = PositionGhostAbsolutely && ghostRelativeParent && getRelativeScrollOffset(ghostRelativeParent), dx = (touch.clientX - tapEvt.clientX + fallbackOffset.x) / (scaleX || 1) + (relativeScrollOffset ? relativeScrollOffset[0] - ghostRelativeParentInitialScroll[0] : 0) / (scaleX || 1), dy = (touch.clientY - tapEvt.clientY + fallbackOffset.y) / (scaleY || 1) + (relativeScrollOffset ? relativeScrollOffset[1] - ghostRelativeParentInitialScroll[1] : 0) / (scaleY || 1);
  1264. if (!Sortable.active && !awaitingDragStarted) {
  1265. if (fallbackTolerance && Math.max(Math.abs(touch.clientX - this._lastX), Math.abs(touch.clientY - this._lastY)) < fallbackTolerance) {
  1266. return;
  1267. }
  1268. this._onDragStart(evt, true);
  1269. }
  1270. if (ghostEl) {
  1271. if (ghostMatrix) {
  1272. ghostMatrix.e += dx - (lastDx || 0);
  1273. ghostMatrix.f += dy - (lastDy || 0);
  1274. } else {
  1275. ghostMatrix = {
  1276. a: 1,
  1277. b: 0,
  1278. c: 0,
  1279. d: 1,
  1280. e: dx,
  1281. f: dy
  1282. };
  1283. }
  1284. var cssMatrix = "matrix(".concat(ghostMatrix.a, ",").concat(ghostMatrix.b, ",").concat(ghostMatrix.c, ",").concat(ghostMatrix.d, ",").concat(ghostMatrix.e, ",").concat(ghostMatrix.f, ")");
  1285. css(ghostEl, "webkitTransform", cssMatrix);
  1286. css(ghostEl, "mozTransform", cssMatrix);
  1287. css(ghostEl, "msTransform", cssMatrix);
  1288. css(ghostEl, "transform", cssMatrix);
  1289. lastDx = dx;
  1290. lastDy = dy;
  1291. touchEvt = touch;
  1292. }
  1293. evt.cancelable && evt.preventDefault();
  1294. }
  1295. },
  1296. _appendGhost: function _appendGhost() {
  1297. if (!ghostEl) {
  1298. var container = this.options.fallbackOnBody ? document.body : rootEl, rect = getRect(dragEl, true, PositionGhostAbsolutely, true, container), options = this.options;
  1299. if (PositionGhostAbsolutely) {
  1300. ghostRelativeParent = container;
  1301. while (css(ghostRelativeParent, "position") === "static" && css(ghostRelativeParent, "transform") === "none" && ghostRelativeParent !== document) {
  1302. ghostRelativeParent = ghostRelativeParent.parentNode;
  1303. }
  1304. if (ghostRelativeParent !== document.body && ghostRelativeParent !== document.documentElement) {
  1305. if (ghostRelativeParent === document)
  1306. ghostRelativeParent = getWindowScrollingElement();
  1307. rect.top += ghostRelativeParent.scrollTop;
  1308. rect.left += ghostRelativeParent.scrollLeft;
  1309. } else {
  1310. ghostRelativeParent = getWindowScrollingElement();
  1311. }
  1312. ghostRelativeParentInitialScroll = getRelativeScrollOffset(ghostRelativeParent);
  1313. }
  1314. ghostEl = dragEl.cloneNode(true);
  1315. toggleClass(ghostEl, options.ghostClass, false);
  1316. toggleClass(ghostEl, options.fallbackClass, true);
  1317. toggleClass(ghostEl, options.dragClass, true);
  1318. css(ghostEl, "transition", "");
  1319. css(ghostEl, "transform", "");
  1320. css(ghostEl, "box-sizing", "border-box");
  1321. css(ghostEl, "margin", 0);
  1322. css(ghostEl, "top", rect.top);
  1323. css(ghostEl, "left", rect.left);
  1324. css(ghostEl, "width", rect.width);
  1325. css(ghostEl, "height", rect.height);
  1326. css(ghostEl, "opacity", "0.8");
  1327. css(ghostEl, "position", PositionGhostAbsolutely ? "absolute" : "fixed");
  1328. css(ghostEl, "zIndex", "100000");
  1329. css(ghostEl, "pointerEvents", "none");
  1330. Sortable.ghost = ghostEl;
  1331. container.appendChild(ghostEl);
  1332. css(ghostEl, "transform-origin", tapDistanceLeft / parseInt(ghostEl.style.width) * 100 + "% " + tapDistanceTop / parseInt(ghostEl.style.height) * 100 + "%");
  1333. }
  1334. },
  1335. _onDragStart: function _onDragStart(evt, fallback) {
  1336. var _this = this;
  1337. var dataTransfer = evt.dataTransfer;
  1338. var options = _this.options;
  1339. pluginEvent2("dragStart", this, {
  1340. evt
  1341. });
  1342. if (Sortable.eventCanceled) {
  1343. this._onDrop();
  1344. return;
  1345. }
  1346. pluginEvent2("setupClone", this);
  1347. if (!Sortable.eventCanceled) {
  1348. cloneEl = clone(dragEl);
  1349. cloneEl.removeAttribute("id");
  1350. cloneEl.draggable = false;
  1351. cloneEl.style["will-change"] = "";
  1352. this._hideClone();
  1353. toggleClass(cloneEl, this.options.chosenClass, false);
  1354. Sortable.clone = cloneEl;
  1355. }
  1356. _this.cloneId = _nextTick(function() {
  1357. pluginEvent2("clone", _this);
  1358. if (Sortable.eventCanceled)
  1359. return;
  1360. if (!_this.options.removeCloneOnHide) {
  1361. rootEl.insertBefore(cloneEl, dragEl);
  1362. }
  1363. _this._hideClone();
  1364. _dispatchEvent({
  1365. sortable: _this,
  1366. name: "clone"
  1367. });
  1368. });
  1369. !fallback && toggleClass(dragEl, options.dragClass, true);
  1370. if (fallback) {
  1371. ignoreNextClick = true;
  1372. _this._loopId = setInterval(_this._emulateDragOver, 50);
  1373. } else {
  1374. off(document, "mouseup", _this._onDrop);
  1375. off(document, "touchend", _this._onDrop);
  1376. off(document, "touchcancel", _this._onDrop);
  1377. if (dataTransfer) {
  1378. dataTransfer.effectAllowed = "move";
  1379. options.setData && options.setData.call(_this, dataTransfer, dragEl);
  1380. }
  1381. on(document, "drop", _this);
  1382. css(dragEl, "transform", "translateZ(0)");
  1383. }
  1384. awaitingDragStarted = true;
  1385. _this._dragStartId = _nextTick(_this._dragStarted.bind(_this, fallback, evt));
  1386. on(document, "selectstart", _this);
  1387. moved = true;
  1388. if (Safari) {
  1389. css(document.body, "user-select", "none");
  1390. }
  1391. },
  1392. // Returns true - if no further action is needed (either inserted or another condition)
  1393. _onDragOver: function _onDragOver(evt) {
  1394. var el = this.el, target = evt.target, dragRect, targetRect, revert, options = this.options, group = options.group, activeSortable = Sortable.active, isOwner = activeGroup === group, canSort = options.sort, fromSortable = putSortable || activeSortable, vertical, _this = this, completedFired = false;
  1395. if (_silent)
  1396. return;
  1397. function dragOverEvent(name, extra) {
  1398. pluginEvent2(name, _this, _objectSpread2({
  1399. evt,
  1400. isOwner,
  1401. axis: vertical ? "vertical" : "horizontal",
  1402. revert,
  1403. dragRect,
  1404. targetRect,
  1405. canSort,
  1406. fromSortable,
  1407. target,
  1408. completed,
  1409. onMove: function onMove(target2, after2) {
  1410. return _onMove(rootEl, el, dragEl, dragRect, target2, getRect(target2), evt, after2);
  1411. },
  1412. changed
  1413. }, extra));
  1414. }
  1415. function capture() {
  1416. dragOverEvent("dragOverAnimationCapture");
  1417. _this.captureAnimationState();
  1418. if (_this !== fromSortable) {
  1419. fromSortable.captureAnimationState();
  1420. }
  1421. }
  1422. function completed(insertion) {
  1423. dragOverEvent("dragOverCompleted", {
  1424. insertion
  1425. });
  1426. if (insertion) {
  1427. if (isOwner) {
  1428. activeSortable._hideClone();
  1429. } else {
  1430. activeSortable._showClone(_this);
  1431. }
  1432. if (_this !== fromSortable) {
  1433. toggleClass(dragEl, putSortable ? putSortable.options.ghostClass : activeSortable.options.ghostClass, false);
  1434. toggleClass(dragEl, options.ghostClass, true);
  1435. }
  1436. if (putSortable !== _this && _this !== Sortable.active) {
  1437. putSortable = _this;
  1438. } else if (_this === Sortable.active && putSortable) {
  1439. putSortable = null;
  1440. }
  1441. if (fromSortable === _this) {
  1442. _this._ignoreWhileAnimating = target;
  1443. }
  1444. _this.animateAll(function() {
  1445. dragOverEvent("dragOverAnimationComplete");
  1446. _this._ignoreWhileAnimating = null;
  1447. });
  1448. if (_this !== fromSortable) {
  1449. fromSortable.animateAll();
  1450. fromSortable._ignoreWhileAnimating = null;
  1451. }
  1452. }
  1453. if (target === dragEl && !dragEl.animated || target === el && !target.animated) {
  1454. lastTarget = null;
  1455. }
  1456. if (!options.dragoverBubble && !evt.rootEl && target !== document) {
  1457. dragEl.parentNode[expando]._isOutsideThisEl(evt.target);
  1458. !insertion && nearestEmptyInsertDetectEvent(evt);
  1459. }
  1460. !options.dragoverBubble && evt.stopPropagation && evt.stopPropagation();
  1461. return completedFired = true;
  1462. }
  1463. function changed() {
  1464. newIndex = index(dragEl);
  1465. newDraggableIndex = index(dragEl, options.draggable);
  1466. _dispatchEvent({
  1467. sortable: _this,
  1468. name: "change",
  1469. toEl: el,
  1470. newIndex,
  1471. newDraggableIndex,
  1472. originalEvent: evt
  1473. });
  1474. }
  1475. if (evt.preventDefault !== void 0) {
  1476. evt.cancelable && evt.preventDefault();
  1477. }
  1478. target = closest(target, options.draggable, el, true);
  1479. dragOverEvent("dragOver");
  1480. if (Sortable.eventCanceled)
  1481. return completedFired;
  1482. if (dragEl.contains(evt.target) || target.animated && target.animatingX && target.animatingY || _this._ignoreWhileAnimating === target) {
  1483. return completed(false);
  1484. }
  1485. ignoreNextClick = false;
  1486. if (activeSortable && !options.disabled && (isOwner ? canSort || (revert = parentEl !== rootEl) : putSortable === this || (this.lastPutMode = activeGroup.checkPull(this, activeSortable, dragEl, evt)) && group.checkPut(this, activeSortable, dragEl, evt))) {
  1487. vertical = this._getDirection(evt, target) === "vertical";
  1488. dragRect = getRect(dragEl);
  1489. dragOverEvent("dragOverValid");
  1490. if (Sortable.eventCanceled)
  1491. return completedFired;
  1492. if (revert) {
  1493. parentEl = rootEl;
  1494. capture();
  1495. this._hideClone();
  1496. dragOverEvent("revert");
  1497. if (!Sortable.eventCanceled) {
  1498. if (nextEl) {
  1499. rootEl.insertBefore(dragEl, nextEl);
  1500. } else {
  1501. rootEl.appendChild(dragEl);
  1502. }
  1503. }
  1504. return completed(true);
  1505. }
  1506. var elLastChild = lastChild(el, options.draggable);
  1507. if (!elLastChild || _ghostIsLast(evt, vertical, this) && !elLastChild.animated) {
  1508. if (elLastChild === dragEl) {
  1509. return completed(false);
  1510. }
  1511. if (elLastChild && el === evt.target) {
  1512. target = elLastChild;
  1513. }
  1514. if (target) {
  1515. targetRect = getRect(target);
  1516. }
  1517. if (_onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt, !!target) !== false) {
  1518. capture();
  1519. if (elLastChild && elLastChild.nextSibling) {
  1520. el.insertBefore(dragEl, elLastChild.nextSibling);
  1521. } else {
  1522. el.appendChild(dragEl);
  1523. }
  1524. parentEl = el;
  1525. changed();
  1526. return completed(true);
  1527. }
  1528. } else if (elLastChild && _ghostIsFirst(evt, vertical, this)) {
  1529. var firstChild = getChild(el, 0, options, true);
  1530. if (firstChild === dragEl) {
  1531. return completed(false);
  1532. }
  1533. target = firstChild;
  1534. targetRect = getRect(target);
  1535. if (_onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt, false) !== false) {
  1536. capture();
  1537. el.insertBefore(dragEl, firstChild);
  1538. parentEl = el;
  1539. changed();
  1540. return completed(true);
  1541. }
  1542. } else if (target.parentNode === el) {
  1543. targetRect = getRect(target);
  1544. var direction = 0, targetBeforeFirstSwap, differentLevel = dragEl.parentNode !== el, differentRowCol = !_dragElInRowColumn(dragEl.animated && dragEl.toRect || dragRect, target.animated && target.toRect || targetRect, vertical), side1 = vertical ? "top" : "left", scrolledPastTop = isScrolledPast(target, "top", "top") || isScrolledPast(dragEl, "top", "top"), scrollBefore = scrolledPastTop ? scrolledPastTop.scrollTop : void 0;
  1545. if (lastTarget !== target) {
  1546. targetBeforeFirstSwap = targetRect[side1];
  1547. pastFirstInvertThresh = false;
  1548. isCircumstantialInvert = !differentRowCol && options.invertSwap || differentLevel;
  1549. }
  1550. direction = _getSwapDirection(evt, target, targetRect, vertical, differentRowCol ? 1 : options.swapThreshold, options.invertedSwapThreshold == null ? options.swapThreshold : options.invertedSwapThreshold, isCircumstantialInvert, lastTarget === target);
  1551. var sibling;
  1552. if (direction !== 0) {
  1553. var dragIndex = index(dragEl);
  1554. do {
  1555. dragIndex -= direction;
  1556. sibling = parentEl.children[dragIndex];
  1557. } while (sibling && (css(sibling, "display") === "none" || sibling === ghostEl));
  1558. }
  1559. if (direction === 0 || sibling === target) {
  1560. return completed(false);
  1561. }
  1562. lastTarget = target;
  1563. lastDirection = direction;
  1564. var nextSibling = target.nextElementSibling, after = false;
  1565. after = direction === 1;
  1566. var moveVector = _onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt, after);
  1567. if (moveVector !== false) {
  1568. if (moveVector === 1 || moveVector === -1) {
  1569. after = moveVector === 1;
  1570. }
  1571. _silent = true;
  1572. setTimeout(_unsilent, 30);
  1573. capture();
  1574. if (after && !nextSibling) {
  1575. el.appendChild(dragEl);
  1576. } else {
  1577. target.parentNode.insertBefore(dragEl, after ? nextSibling : target);
  1578. }
  1579. if (scrolledPastTop) {
  1580. scrollBy(scrolledPastTop, 0, scrollBefore - scrolledPastTop.scrollTop);
  1581. }
  1582. parentEl = dragEl.parentNode;
  1583. if (targetBeforeFirstSwap !== void 0 && !isCircumstantialInvert) {
  1584. targetMoveDistance = Math.abs(targetBeforeFirstSwap - getRect(target)[side1]);
  1585. }
  1586. changed();
  1587. return completed(true);
  1588. }
  1589. }
  1590. if (el.contains(dragEl)) {
  1591. return completed(false);
  1592. }
  1593. }
  1594. return false;
  1595. },
  1596. _ignoreWhileAnimating: null,
  1597. _offMoveEvents: function _offMoveEvents() {
  1598. off(document, "mousemove", this._onTouchMove);
  1599. off(document, "touchmove", this._onTouchMove);
  1600. off(document, "pointermove", this._onTouchMove);
  1601. off(document, "dragover", nearestEmptyInsertDetectEvent);
  1602. off(document, "mousemove", nearestEmptyInsertDetectEvent);
  1603. off(document, "touchmove", nearestEmptyInsertDetectEvent);
  1604. },
  1605. _offUpEvents: function _offUpEvents() {
  1606. var ownerDocument = this.el.ownerDocument;
  1607. off(ownerDocument, "mouseup", this._onDrop);
  1608. off(ownerDocument, "touchend", this._onDrop);
  1609. off(ownerDocument, "pointerup", this._onDrop);
  1610. off(ownerDocument, "touchcancel", this._onDrop);
  1611. off(document, "selectstart", this);
  1612. },
  1613. _onDrop: function _onDrop(evt) {
  1614. var el = this.el, options = this.options;
  1615. newIndex = index(dragEl);
  1616. newDraggableIndex = index(dragEl, options.draggable);
  1617. pluginEvent2("drop", this, {
  1618. evt
  1619. });
  1620. parentEl = dragEl && dragEl.parentNode;
  1621. newIndex = index(dragEl);
  1622. newDraggableIndex = index(dragEl, options.draggable);
  1623. if (Sortable.eventCanceled) {
  1624. this._nulling();
  1625. return;
  1626. }
  1627. awaitingDragStarted = false;
  1628. isCircumstantialInvert = false;
  1629. pastFirstInvertThresh = false;
  1630. clearInterval(this._loopId);
  1631. clearTimeout(this._dragStartTimer);
  1632. _cancelNextTick(this.cloneId);
  1633. _cancelNextTick(this._dragStartId);
  1634. if (this.nativeDraggable) {
  1635. off(document, "drop", this);
  1636. off(el, "dragstart", this._onDragStart);
  1637. }
  1638. this._offMoveEvents();
  1639. this._offUpEvents();
  1640. if (Safari) {
  1641. css(document.body, "user-select", "");
  1642. }
  1643. css(dragEl, "transform", "");
  1644. if (evt) {
  1645. if (moved) {
  1646. evt.cancelable && evt.preventDefault();
  1647. !options.dropBubble && evt.stopPropagation();
  1648. }
  1649. ghostEl && ghostEl.parentNode && ghostEl.parentNode.removeChild(ghostEl);
  1650. if (rootEl === parentEl || putSortable && putSortable.lastPutMode !== "clone") {
  1651. cloneEl && cloneEl.parentNode && cloneEl.parentNode.removeChild(cloneEl);
  1652. }
  1653. if (dragEl) {
  1654. if (this.nativeDraggable) {
  1655. off(dragEl, "dragend", this);
  1656. }
  1657. _disableDraggable(dragEl);
  1658. dragEl.style["will-change"] = "";
  1659. if (moved && !awaitingDragStarted) {
  1660. toggleClass(dragEl, putSortable ? putSortable.options.ghostClass : this.options.ghostClass, false);
  1661. }
  1662. toggleClass(dragEl, this.options.chosenClass, false);
  1663. _dispatchEvent({
  1664. sortable: this,
  1665. name: "unchoose",
  1666. toEl: parentEl,
  1667. newIndex: null,
  1668. newDraggableIndex: null,
  1669. originalEvent: evt
  1670. });
  1671. if (rootEl !== parentEl) {
  1672. if (newIndex >= 0) {
  1673. _dispatchEvent({
  1674. rootEl: parentEl,
  1675. name: "add",
  1676. toEl: parentEl,
  1677. fromEl: rootEl,
  1678. originalEvent: evt
  1679. });
  1680. _dispatchEvent({
  1681. sortable: this,
  1682. name: "remove",
  1683. toEl: parentEl,
  1684. originalEvent: evt
  1685. });
  1686. _dispatchEvent({
  1687. rootEl: parentEl,
  1688. name: "sort",
  1689. toEl: parentEl,
  1690. fromEl: rootEl,
  1691. originalEvent: evt
  1692. });
  1693. _dispatchEvent({
  1694. sortable: this,
  1695. name: "sort",
  1696. toEl: parentEl,
  1697. originalEvent: evt
  1698. });
  1699. }
  1700. putSortable && putSortable.save();
  1701. } else {
  1702. if (newIndex !== oldIndex) {
  1703. if (newIndex >= 0) {
  1704. _dispatchEvent({
  1705. sortable: this,
  1706. name: "update",
  1707. toEl: parentEl,
  1708. originalEvent: evt
  1709. });
  1710. _dispatchEvent({
  1711. sortable: this,
  1712. name: "sort",
  1713. toEl: parentEl,
  1714. originalEvent: evt
  1715. });
  1716. }
  1717. }
  1718. }
  1719. if (Sortable.active) {
  1720. if (newIndex == null || newIndex === -1) {
  1721. newIndex = oldIndex;
  1722. newDraggableIndex = oldDraggableIndex;
  1723. }
  1724. _dispatchEvent({
  1725. sortable: this,
  1726. name: "end",
  1727. toEl: parentEl,
  1728. originalEvent: evt
  1729. });
  1730. this.save();
  1731. }
  1732. }
  1733. }
  1734. this._nulling();
  1735. },
  1736. _nulling: function _nulling() {
  1737. pluginEvent2("nulling", this);
  1738. rootEl = dragEl = parentEl = ghostEl = nextEl = cloneEl = lastDownEl = cloneHidden = tapEvt = touchEvt = moved = newIndex = newDraggableIndex = oldIndex = oldDraggableIndex = lastTarget = lastDirection = putSortable = activeGroup = Sortable.dragged = Sortable.ghost = Sortable.clone = Sortable.active = null;
  1739. savedInputChecked.forEach(function(el) {
  1740. el.checked = true;
  1741. });
  1742. savedInputChecked.length = lastDx = lastDy = 0;
  1743. },
  1744. handleEvent: function handleEvent(evt) {
  1745. switch (evt.type) {
  1746. case "drop":
  1747. case "dragend":
  1748. this._onDrop(evt);
  1749. break;
  1750. case "dragenter":
  1751. case "dragover":
  1752. if (dragEl) {
  1753. this._onDragOver(evt);
  1754. _globalDragOver(evt);
  1755. }
  1756. break;
  1757. case "selectstart":
  1758. evt.preventDefault();
  1759. break;
  1760. }
  1761. },
  1762. /**
  1763. * Serializes the item into an array of string.
  1764. * @returns {String[]}
  1765. */
  1766. toArray: function toArray() {
  1767. var order = [], el, children = this.el.children, i = 0, n = children.length, options = this.options;
  1768. for (; i < n; i++) {
  1769. el = children[i];
  1770. if (closest(el, options.draggable, this.el, false)) {
  1771. order.push(el.getAttribute(options.dataIdAttr) || _generateId(el));
  1772. }
  1773. }
  1774. return order;
  1775. },
  1776. /**
  1777. * Sorts the elements according to the array.
  1778. * @param {String[]} order order of the items
  1779. */
  1780. sort: function sort(order, useAnimation) {
  1781. var items = {}, rootEl2 = this.el;
  1782. this.toArray().forEach(function(id, i) {
  1783. var el = rootEl2.children[i];
  1784. if (closest(el, this.options.draggable, rootEl2, false)) {
  1785. items[id] = el;
  1786. }
  1787. }, this);
  1788. useAnimation && this.captureAnimationState();
  1789. order.forEach(function(id) {
  1790. if (items[id]) {
  1791. rootEl2.removeChild(items[id]);
  1792. rootEl2.appendChild(items[id]);
  1793. }
  1794. });
  1795. useAnimation && this.animateAll();
  1796. },
  1797. /**
  1798. * Save the current sorting
  1799. */
  1800. save: function save() {
  1801. var store = this.options.store;
  1802. store && store.set && store.set(this);
  1803. },
  1804. /**
  1805. * For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree.
  1806. * @param {HTMLElement} el
  1807. * @param {String} [selector] default: `options.draggable`
  1808. * @returns {HTMLElement|null}
  1809. */
  1810. closest: function closest$1(el, selector) {
  1811. return closest(el, selector || this.options.draggable, this.el, false);
  1812. },
  1813. /**
  1814. * Set/get option
  1815. * @param {string} name
  1816. * @param {*} [value]
  1817. * @returns {*}
  1818. */
  1819. option: function option(name, value) {
  1820. var options = this.options;
  1821. if (value === void 0) {
  1822. return options[name];
  1823. } else {
  1824. var modifiedValue = PluginManager.modifyOption(this, name, value);
  1825. if (typeof modifiedValue !== "undefined") {
  1826. options[name] = modifiedValue;
  1827. } else {
  1828. options[name] = value;
  1829. }
  1830. if (name === "group") {
  1831. _prepareGroup(options);
  1832. }
  1833. }
  1834. },
  1835. /**
  1836. * Destroy
  1837. */
  1838. destroy: function destroy() {
  1839. pluginEvent2("destroy", this);
  1840. var el = this.el;
  1841. el[expando] = null;
  1842. off(el, "mousedown", this._onTapStart);
  1843. off(el, "touchstart", this._onTapStart);
  1844. off(el, "pointerdown", this._onTapStart);
  1845. if (this.nativeDraggable) {
  1846. off(el, "dragover", this);
  1847. off(el, "dragenter", this);
  1848. }
  1849. Array.prototype.forEach.call(el.querySelectorAll("[draggable]"), function(el2) {
  1850. el2.removeAttribute("draggable");
  1851. });
  1852. this._onDrop();
  1853. this._disableDelayedDragEvents();
  1854. sortables.splice(sortables.indexOf(this.el), 1);
  1855. this.el = el = null;
  1856. },
  1857. _hideClone: function _hideClone() {
  1858. if (!cloneHidden) {
  1859. pluginEvent2("hideClone", this);
  1860. if (Sortable.eventCanceled)
  1861. return;
  1862. css(cloneEl, "display", "none");
  1863. if (this.options.removeCloneOnHide && cloneEl.parentNode) {
  1864. cloneEl.parentNode.removeChild(cloneEl);
  1865. }
  1866. cloneHidden = true;
  1867. }
  1868. },
  1869. _showClone: function _showClone(putSortable2) {
  1870. if (putSortable2.lastPutMode !== "clone") {
  1871. this._hideClone();
  1872. return;
  1873. }
  1874. if (cloneHidden) {
  1875. pluginEvent2("showClone", this);
  1876. if (Sortable.eventCanceled)
  1877. return;
  1878. if (dragEl.parentNode == rootEl && !this.options.group.revertClone) {
  1879. rootEl.insertBefore(cloneEl, dragEl);
  1880. } else if (nextEl) {
  1881. rootEl.insertBefore(cloneEl, nextEl);
  1882. } else {
  1883. rootEl.appendChild(cloneEl);
  1884. }
  1885. if (this.options.group.revertClone) {
  1886. this.animate(dragEl, cloneEl);
  1887. }
  1888. css(cloneEl, "display", "");
  1889. cloneHidden = false;
  1890. }
  1891. }
  1892. };
  1893. function _globalDragOver(evt) {
  1894. if (evt.dataTransfer) {
  1895. evt.dataTransfer.dropEffect = "move";
  1896. }
  1897. evt.cancelable && evt.preventDefault();
  1898. }
  1899. function _onMove(fromEl, toEl, dragEl2, dragRect, targetEl, targetRect, originalEvent, willInsertAfter) {
  1900. var evt, sortable = fromEl[expando], onMoveFn = sortable.options.onMove, retVal;
  1901. if (window.CustomEvent && !IE11OrLess && !Edge) {
  1902. evt = new CustomEvent("move", {
  1903. bubbles: true,
  1904. cancelable: true
  1905. });
  1906. } else {
  1907. evt = document.createEvent("Event");
  1908. evt.initEvent("move", true, true);
  1909. }
  1910. evt.to = toEl;
  1911. evt.from = fromEl;
  1912. evt.dragged = dragEl2;
  1913. evt.draggedRect = dragRect;
  1914. evt.related = targetEl || toEl;
  1915. evt.relatedRect = targetRect || getRect(toEl);
  1916. evt.willInsertAfter = willInsertAfter;
  1917. evt.originalEvent = originalEvent;
  1918. fromEl.dispatchEvent(evt);
  1919. if (onMoveFn) {
  1920. retVal = onMoveFn.call(sortable, evt, originalEvent);
  1921. }
  1922. return retVal;
  1923. }
  1924. function _disableDraggable(el) {
  1925. el.draggable = false;
  1926. }
  1927. function _unsilent() {
  1928. _silent = false;
  1929. }
  1930. function _ghostIsFirst(evt, vertical, sortable) {
  1931. var firstElRect = getRect(getChild(sortable.el, 0, sortable.options, true));
  1932. var childContainingRect = getChildContainingRectFromElement(sortable.el, sortable.options, ghostEl);
  1933. var spacer = 10;
  1934. return vertical ? evt.clientX < childContainingRect.left - spacer || evt.clientY < firstElRect.top && evt.clientX < firstElRect.right : evt.clientY < childContainingRect.top - spacer || evt.clientY < firstElRect.bottom && evt.clientX < firstElRect.left;
  1935. }
  1936. function _ghostIsLast(evt, vertical, sortable) {
  1937. var lastElRect = getRect(lastChild(sortable.el, sortable.options.draggable));
  1938. var childContainingRect = getChildContainingRectFromElement(sortable.el, sortable.options, ghostEl);
  1939. var spacer = 10;
  1940. return vertical ? evt.clientX > childContainingRect.right + spacer || evt.clientY > lastElRect.bottom && evt.clientX > lastElRect.left : evt.clientY > childContainingRect.bottom + spacer || evt.clientX > lastElRect.right && evt.clientY > lastElRect.top;
  1941. }
  1942. function _getSwapDirection(evt, target, targetRect, vertical, swapThreshold, invertedSwapThreshold, invertSwap, isLastTarget) {
  1943. var mouseOnAxis = vertical ? evt.clientY : evt.clientX, targetLength = vertical ? targetRect.height : targetRect.width, targetS1 = vertical ? targetRect.top : targetRect.left, targetS2 = vertical ? targetRect.bottom : targetRect.right, invert = false;
  1944. if (!invertSwap) {
  1945. if (isLastTarget && targetMoveDistance < targetLength * swapThreshold) {
  1946. if (!pastFirstInvertThresh && (lastDirection === 1 ? mouseOnAxis > targetS1 + targetLength * invertedSwapThreshold / 2 : mouseOnAxis < targetS2 - targetLength * invertedSwapThreshold / 2)) {
  1947. pastFirstInvertThresh = true;
  1948. }
  1949. if (!pastFirstInvertThresh) {
  1950. if (lastDirection === 1 ? mouseOnAxis < targetS1 + targetMoveDistance : mouseOnAxis > targetS2 - targetMoveDistance) {
  1951. return -lastDirection;
  1952. }
  1953. } else {
  1954. invert = true;
  1955. }
  1956. } else {
  1957. if (mouseOnAxis > targetS1 + targetLength * (1 - swapThreshold) / 2 && mouseOnAxis < targetS2 - targetLength * (1 - swapThreshold) / 2) {
  1958. return _getInsertDirection(target);
  1959. }
  1960. }
  1961. }
  1962. invert = invert || invertSwap;
  1963. if (invert) {
  1964. if (mouseOnAxis < targetS1 + targetLength * invertedSwapThreshold / 2 || mouseOnAxis > targetS2 - targetLength * invertedSwapThreshold / 2) {
  1965. return mouseOnAxis > targetS1 + targetLength / 2 ? 1 : -1;
  1966. }
  1967. }
  1968. return 0;
  1969. }
  1970. function _getInsertDirection(target) {
  1971. if (index(dragEl) < index(target)) {
  1972. return 1;
  1973. } else {
  1974. return -1;
  1975. }
  1976. }
  1977. function _generateId(el) {
  1978. var str = el.tagName + el.className + el.src + el.href + el.textContent, i = str.length, sum = 0;
  1979. while (i--) {
  1980. sum += str.charCodeAt(i);
  1981. }
  1982. return sum.toString(36);
  1983. }
  1984. function _saveInputCheckedState(root) {
  1985. savedInputChecked.length = 0;
  1986. var inputs = root.getElementsByTagName("input");
  1987. var idx = inputs.length;
  1988. while (idx--) {
  1989. var el = inputs[idx];
  1990. el.checked && savedInputChecked.push(el);
  1991. }
  1992. }
  1993. function _nextTick(fn) {
  1994. return setTimeout(fn, 0);
  1995. }
  1996. function _cancelNextTick(id) {
  1997. return clearTimeout(id);
  1998. }
  1999. if (documentExists) {
  2000. on(document, "touchmove", function(evt) {
  2001. if ((Sortable.active || awaitingDragStarted) && evt.cancelable) {
  2002. evt.preventDefault();
  2003. }
  2004. });
  2005. }
  2006. Sortable.utils = {
  2007. on,
  2008. off,
  2009. css,
  2010. find,
  2011. is: function is(el, selector) {
  2012. return !!closest(el, selector, el, false);
  2013. },
  2014. extend,
  2015. throttle,
  2016. closest,
  2017. toggleClass,
  2018. clone,
  2019. index,
  2020. nextTick: _nextTick,
  2021. cancelNextTick: _cancelNextTick,
  2022. detectDirection: _detectDirection,
  2023. getChild
  2024. };
  2025. Sortable.get = function(element) {
  2026. return element[expando];
  2027. };
  2028. Sortable.mount = function() {
  2029. for (var _len = arguments.length, plugins2 = new Array(_len), _key = 0; _key < _len; _key++) {
  2030. plugins2[_key] = arguments[_key];
  2031. }
  2032. if (plugins2[0].constructor === Array)
  2033. plugins2 = plugins2[0];
  2034. plugins2.forEach(function(plugin) {
  2035. if (!plugin.prototype || !plugin.prototype.constructor) {
  2036. throw "Sortable: Mounted plugin must be a constructor function, not ".concat({}.toString.call(plugin));
  2037. }
  2038. if (plugin.utils)
  2039. Sortable.utils = _objectSpread2(_objectSpread2({}, Sortable.utils), plugin.utils);
  2040. PluginManager.mount(plugin);
  2041. });
  2042. };
  2043. Sortable.create = function(el, options) {
  2044. return new Sortable(el, options);
  2045. };
  2046. Sortable.version = version;
  2047. var autoScrolls = [];
  2048. var scrollEl;
  2049. var scrollRootEl;
  2050. var scrolling = false;
  2051. var lastAutoScrollX;
  2052. var lastAutoScrollY;
  2053. var touchEvt$1;
  2054. var pointerElemChangedInterval;
  2055. function AutoScrollPlugin() {
  2056. function AutoScroll() {
  2057. this.defaults = {
  2058. scroll: true,
  2059. forceAutoScrollFallback: false,
  2060. scrollSensitivity: 30,
  2061. scrollSpeed: 10,
  2062. bubbleScroll: true
  2063. };
  2064. for (var fn in this) {
  2065. if (fn.charAt(0) === "_" && typeof this[fn] === "function") {
  2066. this[fn] = this[fn].bind(this);
  2067. }
  2068. }
  2069. }
  2070. AutoScroll.prototype = {
  2071. dragStarted: function dragStarted2(_ref) {
  2072. var originalEvent = _ref.originalEvent;
  2073. if (this.sortable.nativeDraggable) {
  2074. on(document, "dragover", this._handleAutoScroll);
  2075. } else {
  2076. if (this.options.supportPointer) {
  2077. on(document, "pointermove", this._handleFallbackAutoScroll);
  2078. } else if (originalEvent.touches) {
  2079. on(document, "touchmove", this._handleFallbackAutoScroll);
  2080. } else {
  2081. on(document, "mousemove", this._handleFallbackAutoScroll);
  2082. }
  2083. }
  2084. },
  2085. dragOverCompleted: function dragOverCompleted(_ref2) {
  2086. var originalEvent = _ref2.originalEvent;
  2087. if (!this.options.dragOverBubble && !originalEvent.rootEl) {
  2088. this._handleAutoScroll(originalEvent);
  2089. }
  2090. },
  2091. drop: function drop3() {
  2092. if (this.sortable.nativeDraggable) {
  2093. off(document, "dragover", this._handleAutoScroll);
  2094. } else {
  2095. off(document, "pointermove", this._handleFallbackAutoScroll);
  2096. off(document, "touchmove", this._handleFallbackAutoScroll);
  2097. off(document, "mousemove", this._handleFallbackAutoScroll);
  2098. }
  2099. clearPointerElemChangedInterval();
  2100. clearAutoScrolls();
  2101. cancelThrottle();
  2102. },
  2103. nulling: function nulling() {
  2104. touchEvt$1 = scrollRootEl = scrollEl = scrolling = pointerElemChangedInterval = lastAutoScrollX = lastAutoScrollY = null;
  2105. autoScrolls.length = 0;
  2106. },
  2107. _handleFallbackAutoScroll: function _handleFallbackAutoScroll(evt) {
  2108. this._handleAutoScroll(evt, true);
  2109. },
  2110. _handleAutoScroll: function _handleAutoScroll(evt, fallback) {
  2111. var _this = this;
  2112. var x = (evt.touches ? evt.touches[0] : evt).clientX, y = (evt.touches ? evt.touches[0] : evt).clientY, elem = document.elementFromPoint(x, y);
  2113. touchEvt$1 = evt;
  2114. if (fallback || this.options.forceAutoScrollFallback || Edge || IE11OrLess || Safari) {
  2115. autoScroll(evt, this.options, elem, fallback);
  2116. var ogElemScroller = getParentAutoScrollElement(elem, true);
  2117. if (scrolling && (!pointerElemChangedInterval || x !== lastAutoScrollX || y !== lastAutoScrollY)) {
  2118. pointerElemChangedInterval && clearPointerElemChangedInterval();
  2119. pointerElemChangedInterval = setInterval(function() {
  2120. var newElem = getParentAutoScrollElement(document.elementFromPoint(x, y), true);
  2121. if (newElem !== ogElemScroller) {
  2122. ogElemScroller = newElem;
  2123. clearAutoScrolls();
  2124. }
  2125. autoScroll(evt, _this.options, newElem, fallback);
  2126. }, 10);
  2127. lastAutoScrollX = x;
  2128. lastAutoScrollY = y;
  2129. }
  2130. } else {
  2131. if (!this.options.bubbleScroll || getParentAutoScrollElement(elem, true) === getWindowScrollingElement()) {
  2132. clearAutoScrolls();
  2133. return;
  2134. }
  2135. autoScroll(evt, this.options, getParentAutoScrollElement(elem, false), false);
  2136. }
  2137. }
  2138. };
  2139. return _extends(AutoScroll, {
  2140. pluginName: "scroll",
  2141. initializeByDefault: true
  2142. });
  2143. }
  2144. function clearAutoScrolls() {
  2145. autoScrolls.forEach(function(autoScroll2) {
  2146. clearInterval(autoScroll2.pid);
  2147. });
  2148. autoScrolls = [];
  2149. }
  2150. function clearPointerElemChangedInterval() {
  2151. clearInterval(pointerElemChangedInterval);
  2152. }
  2153. var autoScroll = throttle(function(evt, options, rootEl2, isFallback) {
  2154. if (!options.scroll)
  2155. return;
  2156. var x = (evt.touches ? evt.touches[0] : evt).clientX, y = (evt.touches ? evt.touches[0] : evt).clientY, sens = options.scrollSensitivity, speed = options.scrollSpeed, winScroller = getWindowScrollingElement();
  2157. var scrollThisInstance = false, scrollCustomFn;
  2158. if (scrollRootEl !== rootEl2) {
  2159. scrollRootEl = rootEl2;
  2160. clearAutoScrolls();
  2161. scrollEl = options.scroll;
  2162. scrollCustomFn = options.scrollFn;
  2163. if (scrollEl === true) {
  2164. scrollEl = getParentAutoScrollElement(rootEl2, true);
  2165. }
  2166. }
  2167. var layersOut = 0;
  2168. var currentParent = scrollEl;
  2169. do {
  2170. var el = currentParent, rect = getRect(el), top = rect.top, bottom = rect.bottom, left = rect.left, right = rect.right, width = rect.width, height = rect.height, canScrollX = void 0, canScrollY = void 0, scrollWidth = el.scrollWidth, scrollHeight = el.scrollHeight, elCSS = css(el), scrollPosX = el.scrollLeft, scrollPosY = el.scrollTop;
  2171. if (el === winScroller) {
  2172. canScrollX = width < scrollWidth && (elCSS.overflowX === "auto" || elCSS.overflowX === "scroll" || elCSS.overflowX === "visible");
  2173. canScrollY = height < scrollHeight && (elCSS.overflowY === "auto" || elCSS.overflowY === "scroll" || elCSS.overflowY === "visible");
  2174. } else {
  2175. canScrollX = width < scrollWidth && (elCSS.overflowX === "auto" || elCSS.overflowX === "scroll");
  2176. canScrollY = height < scrollHeight && (elCSS.overflowY === "auto" || elCSS.overflowY === "scroll");
  2177. }
  2178. var vx = canScrollX && (Math.abs(right - x) <= sens && scrollPosX + width < scrollWidth) - (Math.abs(left - x) <= sens && !!scrollPosX);
  2179. var vy = canScrollY && (Math.abs(bottom - y) <= sens && scrollPosY + height < scrollHeight) - (Math.abs(top - y) <= sens && !!scrollPosY);
  2180. if (!autoScrolls[layersOut]) {
  2181. for (var i = 0; i <= layersOut; i++) {
  2182. if (!autoScrolls[i]) {
  2183. autoScrolls[i] = {};
  2184. }
  2185. }
  2186. }
  2187. if (autoScrolls[layersOut].vx != vx || autoScrolls[layersOut].vy != vy || autoScrolls[layersOut].el !== el) {
  2188. autoScrolls[layersOut].el = el;
  2189. autoScrolls[layersOut].vx = vx;
  2190. autoScrolls[layersOut].vy = vy;
  2191. clearInterval(autoScrolls[layersOut].pid);
  2192. if (vx != 0 || vy != 0) {
  2193. scrollThisInstance = true;
  2194. autoScrolls[layersOut].pid = setInterval((function() {
  2195. if (isFallback && this.layer === 0) {
  2196. Sortable.active._onTouchMove(touchEvt$1);
  2197. }
  2198. var scrollOffsetY = autoScrolls[this.layer].vy ? autoScrolls[this.layer].vy * speed : 0;
  2199. var scrollOffsetX = autoScrolls[this.layer].vx ? autoScrolls[this.layer].vx * speed : 0;
  2200. if (typeof scrollCustomFn === "function") {
  2201. if (scrollCustomFn.call(Sortable.dragged.parentNode[expando], scrollOffsetX, scrollOffsetY, evt, touchEvt$1, autoScrolls[this.layer].el) !== "continue") {
  2202. return;
  2203. }
  2204. }
  2205. scrollBy(autoScrolls[this.layer].el, scrollOffsetX, scrollOffsetY);
  2206. }).bind({
  2207. layer: layersOut
  2208. }), 24);
  2209. }
  2210. }
  2211. layersOut++;
  2212. } while (options.bubbleScroll && currentParent !== winScroller && (currentParent = getParentAutoScrollElement(currentParent, false)));
  2213. scrolling = scrollThisInstance;
  2214. }, 30);
  2215. var drop = function drop2(_ref) {
  2216. var originalEvent = _ref.originalEvent, putSortable2 = _ref.putSortable, dragEl2 = _ref.dragEl, activeSortable = _ref.activeSortable, dispatchSortableEvent = _ref.dispatchSortableEvent, hideGhostForTarget = _ref.hideGhostForTarget, unhideGhostForTarget = _ref.unhideGhostForTarget;
  2217. if (!originalEvent)
  2218. return;
  2219. var toSortable = putSortable2 || activeSortable;
  2220. hideGhostForTarget();
  2221. var touch = originalEvent.changedTouches && originalEvent.changedTouches.length ? originalEvent.changedTouches[0] : originalEvent;
  2222. var target = document.elementFromPoint(touch.clientX, touch.clientY);
  2223. unhideGhostForTarget();
  2224. if (toSortable && !toSortable.el.contains(target)) {
  2225. dispatchSortableEvent("spill");
  2226. this.onSpill({
  2227. dragEl: dragEl2,
  2228. putSortable: putSortable2
  2229. });
  2230. }
  2231. };
  2232. function Revert() {
  2233. }
  2234. Revert.prototype = {
  2235. startIndex: null,
  2236. dragStart: function dragStart(_ref2) {
  2237. var oldDraggableIndex2 = _ref2.oldDraggableIndex;
  2238. this.startIndex = oldDraggableIndex2;
  2239. },
  2240. onSpill: function onSpill(_ref3) {
  2241. var dragEl2 = _ref3.dragEl, putSortable2 = _ref3.putSortable;
  2242. this.sortable.captureAnimationState();
  2243. if (putSortable2) {
  2244. putSortable2.captureAnimationState();
  2245. }
  2246. var nextSibling = getChild(this.sortable.el, this.startIndex, this.options);
  2247. if (nextSibling) {
  2248. this.sortable.el.insertBefore(dragEl2, nextSibling);
  2249. } else {
  2250. this.sortable.el.appendChild(dragEl2);
  2251. }
  2252. this.sortable.animateAll();
  2253. if (putSortable2) {
  2254. putSortable2.animateAll();
  2255. }
  2256. },
  2257. drop
  2258. };
  2259. _extends(Revert, {
  2260. pluginName: "revertOnSpill"
  2261. });
  2262. function Remove() {
  2263. }
  2264. Remove.prototype = {
  2265. onSpill: function onSpill2(_ref4) {
  2266. var dragEl2 = _ref4.dragEl, putSortable2 = _ref4.putSortable;
  2267. var parentSortable = putSortable2 || this.sortable;
  2268. parentSortable.captureAnimationState();
  2269. dragEl2.parentNode && dragEl2.parentNode.removeChild(dragEl2);
  2270. parentSortable.animateAll();
  2271. },
  2272. drop
  2273. };
  2274. _extends(Remove, {
  2275. pluginName: "removeOnSpill"
  2276. });
  2277. var lastSwapEl;
  2278. function SwapPlugin() {
  2279. function Swap() {
  2280. this.defaults = {
  2281. swapClass: "sortable-swap-highlight"
  2282. };
  2283. }
  2284. Swap.prototype = {
  2285. dragStart: function dragStart2(_ref) {
  2286. var dragEl2 = _ref.dragEl;
  2287. lastSwapEl = dragEl2;
  2288. },
  2289. dragOverValid: function dragOverValid(_ref2) {
  2290. var completed = _ref2.completed, target = _ref2.target, onMove = _ref2.onMove, activeSortable = _ref2.activeSortable, changed = _ref2.changed, cancel = _ref2.cancel;
  2291. if (!activeSortable.options.swap)
  2292. return;
  2293. var el = this.sortable.el, options = this.options;
  2294. if (target && target !== el) {
  2295. var prevSwapEl = lastSwapEl;
  2296. if (onMove(target) !== false) {
  2297. toggleClass(target, options.swapClass, true);
  2298. lastSwapEl = target;
  2299. } else {
  2300. lastSwapEl = null;
  2301. }
  2302. if (prevSwapEl && prevSwapEl !== lastSwapEl) {
  2303. toggleClass(prevSwapEl, options.swapClass, false);
  2304. }
  2305. }
  2306. changed();
  2307. completed(true);
  2308. cancel();
  2309. },
  2310. drop: function drop3(_ref3) {
  2311. var activeSortable = _ref3.activeSortable, putSortable2 = _ref3.putSortable, dragEl2 = _ref3.dragEl;
  2312. var toSortable = putSortable2 || this.sortable;
  2313. var options = this.options;
  2314. lastSwapEl && toggleClass(lastSwapEl, options.swapClass, false);
  2315. if (lastSwapEl && (options.swap || putSortable2 && putSortable2.options.swap)) {
  2316. if (dragEl2 !== lastSwapEl) {
  2317. toSortable.captureAnimationState();
  2318. if (toSortable !== activeSortable)
  2319. activeSortable.captureAnimationState();
  2320. swapNodes(dragEl2, lastSwapEl);
  2321. toSortable.animateAll();
  2322. if (toSortable !== activeSortable)
  2323. activeSortable.animateAll();
  2324. }
  2325. }
  2326. },
  2327. nulling: function nulling() {
  2328. lastSwapEl = null;
  2329. }
  2330. };
  2331. return _extends(Swap, {
  2332. pluginName: "swap",
  2333. eventProperties: function eventProperties() {
  2334. return {
  2335. swapItem: lastSwapEl
  2336. };
  2337. }
  2338. });
  2339. }
  2340. function swapNodes(n1, n2) {
  2341. var p1 = n1.parentNode, p2 = n2.parentNode, i1, i2;
  2342. if (!p1 || !p2 || p1.isEqualNode(n2) || p2.isEqualNode(n1))
  2343. return;
  2344. i1 = index(n1);
  2345. i2 = index(n2);
  2346. if (p1.isEqualNode(p2) && i1 < i2) {
  2347. i2++;
  2348. }
  2349. p1.insertBefore(n2, p1.children[i1]);
  2350. p2.insertBefore(n1, p2.children[i2]);
  2351. }
  2352. var multiDragElements = [];
  2353. var multiDragClones = [];
  2354. var lastMultiDragSelect;
  2355. var multiDragSortable;
  2356. var initialFolding = false;
  2357. var folding = false;
  2358. var dragStarted = false;
  2359. var dragEl$1;
  2360. var clonesFromRect;
  2361. var clonesHidden;
  2362. function MultiDragPlugin() {
  2363. function MultiDrag(sortable) {
  2364. for (var fn in this) {
  2365. if (fn.charAt(0) === "_" && typeof this[fn] === "function") {
  2366. this[fn] = this[fn].bind(this);
  2367. }
  2368. }
  2369. if (!sortable.options.avoidImplicitDeselect) {
  2370. if (sortable.options.supportPointer) {
  2371. on(document, "pointerup", this._deselectMultiDrag);
  2372. } else {
  2373. on(document, "mouseup", this._deselectMultiDrag);
  2374. on(document, "touchend", this._deselectMultiDrag);
  2375. }
  2376. }
  2377. on(document, "keydown", this._checkKeyDown);
  2378. on(document, "keyup", this._checkKeyUp);
  2379. this.defaults = {
  2380. selectedClass: "sortable-selected",
  2381. multiDragKey: null,
  2382. avoidImplicitDeselect: false,
  2383. setData: function setData(dataTransfer, dragEl2) {
  2384. var data = "";
  2385. if (multiDragElements.length && multiDragSortable === sortable) {
  2386. multiDragElements.forEach(function(multiDragElement, i) {
  2387. data += (!i ? "" : ", ") + multiDragElement.textContent;
  2388. });
  2389. } else {
  2390. data = dragEl2.textContent;
  2391. }
  2392. dataTransfer.setData("Text", data);
  2393. }
  2394. };
  2395. }
  2396. MultiDrag.prototype = {
  2397. multiDragKeyDown: false,
  2398. isMultiDrag: false,
  2399. delayStartGlobal: function delayStartGlobal(_ref) {
  2400. var dragged = _ref.dragEl;
  2401. dragEl$1 = dragged;
  2402. },
  2403. delayEnded: function delayEnded() {
  2404. this.isMultiDrag = ~multiDragElements.indexOf(dragEl$1);
  2405. },
  2406. setupClone: function setupClone(_ref2) {
  2407. var sortable = _ref2.sortable, cancel = _ref2.cancel;
  2408. if (!this.isMultiDrag)
  2409. return;
  2410. for (var i = 0; i < multiDragElements.length; i++) {
  2411. multiDragClones.push(clone(multiDragElements[i]));
  2412. multiDragClones[i].sortableIndex = multiDragElements[i].sortableIndex;
  2413. multiDragClones[i].draggable = false;
  2414. multiDragClones[i].style["will-change"] = "";
  2415. toggleClass(multiDragClones[i], this.options.selectedClass, false);
  2416. multiDragElements[i] === dragEl$1 && toggleClass(multiDragClones[i], this.options.chosenClass, false);
  2417. }
  2418. sortable._hideClone();
  2419. cancel();
  2420. },
  2421. clone: function clone2(_ref3) {
  2422. var sortable = _ref3.sortable, rootEl2 = _ref3.rootEl, dispatchSortableEvent = _ref3.dispatchSortableEvent, cancel = _ref3.cancel;
  2423. if (!this.isMultiDrag)
  2424. return;
  2425. if (!this.options.removeCloneOnHide) {
  2426. if (multiDragElements.length && multiDragSortable === sortable) {
  2427. insertMultiDragClones(true, rootEl2);
  2428. dispatchSortableEvent("clone");
  2429. cancel();
  2430. }
  2431. }
  2432. },
  2433. showClone: function showClone(_ref4) {
  2434. var cloneNowShown = _ref4.cloneNowShown, rootEl2 = _ref4.rootEl, cancel = _ref4.cancel;
  2435. if (!this.isMultiDrag)
  2436. return;
  2437. insertMultiDragClones(false, rootEl2);
  2438. multiDragClones.forEach(function(clone2) {
  2439. css(clone2, "display", "");
  2440. });
  2441. cloneNowShown();
  2442. clonesHidden = false;
  2443. cancel();
  2444. },
  2445. hideClone: function hideClone(_ref5) {
  2446. var _this = this;
  2447. var sortable = _ref5.sortable, cloneNowHidden = _ref5.cloneNowHidden, cancel = _ref5.cancel;
  2448. if (!this.isMultiDrag)
  2449. return;
  2450. multiDragClones.forEach(function(clone2) {
  2451. css(clone2, "display", "none");
  2452. if (_this.options.removeCloneOnHide && clone2.parentNode) {
  2453. clone2.parentNode.removeChild(clone2);
  2454. }
  2455. });
  2456. cloneNowHidden();
  2457. clonesHidden = true;
  2458. cancel();
  2459. },
  2460. dragStartGlobal: function dragStartGlobal(_ref6) {
  2461. var sortable = _ref6.sortable;
  2462. if (!this.isMultiDrag && multiDragSortable) {
  2463. multiDragSortable.multiDrag._deselectMultiDrag();
  2464. }
  2465. multiDragElements.forEach(function(multiDragElement) {
  2466. multiDragElement.sortableIndex = index(multiDragElement);
  2467. });
  2468. multiDragElements = multiDragElements.sort(function(a, b) {
  2469. return a.sortableIndex - b.sortableIndex;
  2470. });
  2471. dragStarted = true;
  2472. },
  2473. dragStarted: function dragStarted2(_ref7) {
  2474. var _this2 = this;
  2475. var sortable = _ref7.sortable;
  2476. if (!this.isMultiDrag)
  2477. return;
  2478. if (this.options.sort) {
  2479. sortable.captureAnimationState();
  2480. if (this.options.animation) {
  2481. multiDragElements.forEach(function(multiDragElement) {
  2482. if (multiDragElement === dragEl$1)
  2483. return;
  2484. css(multiDragElement, "position", "absolute");
  2485. });
  2486. var dragRect = getRect(dragEl$1, false, true, true);
  2487. multiDragElements.forEach(function(multiDragElement) {
  2488. if (multiDragElement === dragEl$1)
  2489. return;
  2490. setRect(multiDragElement, dragRect);
  2491. });
  2492. folding = true;
  2493. initialFolding = true;
  2494. }
  2495. }
  2496. sortable.animateAll(function() {
  2497. folding = false;
  2498. initialFolding = false;
  2499. if (_this2.options.animation) {
  2500. multiDragElements.forEach(function(multiDragElement) {
  2501. unsetRect(multiDragElement);
  2502. });
  2503. }
  2504. if (_this2.options.sort) {
  2505. removeMultiDragElements();
  2506. }
  2507. });
  2508. },
  2509. dragOver: function dragOver(_ref8) {
  2510. var target = _ref8.target, completed = _ref8.completed, cancel = _ref8.cancel;
  2511. if (folding && ~multiDragElements.indexOf(target)) {
  2512. completed(false);
  2513. cancel();
  2514. }
  2515. },
  2516. revert: function revert(_ref9) {
  2517. var fromSortable = _ref9.fromSortable, rootEl2 = _ref9.rootEl, sortable = _ref9.sortable, dragRect = _ref9.dragRect;
  2518. if (multiDragElements.length > 1) {
  2519. multiDragElements.forEach(function(multiDragElement) {
  2520. sortable.addAnimationState({
  2521. target: multiDragElement,
  2522. rect: folding ? getRect(multiDragElement) : dragRect
  2523. });
  2524. unsetRect(multiDragElement);
  2525. multiDragElement.fromRect = dragRect;
  2526. fromSortable.removeAnimationState(multiDragElement);
  2527. });
  2528. folding = false;
  2529. insertMultiDragElements(!this.options.removeCloneOnHide, rootEl2);
  2530. }
  2531. },
  2532. dragOverCompleted: function dragOverCompleted(_ref10) {
  2533. var sortable = _ref10.sortable, isOwner = _ref10.isOwner, insertion = _ref10.insertion, activeSortable = _ref10.activeSortable, parentEl2 = _ref10.parentEl, putSortable2 = _ref10.putSortable;
  2534. var options = this.options;
  2535. if (insertion) {
  2536. if (isOwner) {
  2537. activeSortable._hideClone();
  2538. }
  2539. initialFolding = false;
  2540. if (options.animation && multiDragElements.length > 1 && (folding || !isOwner && !activeSortable.options.sort && !putSortable2)) {
  2541. var dragRectAbsolute = getRect(dragEl$1, false, true, true);
  2542. multiDragElements.forEach(function(multiDragElement) {
  2543. if (multiDragElement === dragEl$1)
  2544. return;
  2545. setRect(multiDragElement, dragRectAbsolute);
  2546. parentEl2.appendChild(multiDragElement);
  2547. });
  2548. folding = true;
  2549. }
  2550. if (!isOwner) {
  2551. if (!folding) {
  2552. removeMultiDragElements();
  2553. }
  2554. if (multiDragElements.length > 1) {
  2555. var clonesHiddenBefore = clonesHidden;
  2556. activeSortable._showClone(sortable);
  2557. if (activeSortable.options.animation && !clonesHidden && clonesHiddenBefore) {
  2558. multiDragClones.forEach(function(clone2) {
  2559. activeSortable.addAnimationState({
  2560. target: clone2,
  2561. rect: clonesFromRect
  2562. });
  2563. clone2.fromRect = clonesFromRect;
  2564. clone2.thisAnimationDuration = null;
  2565. });
  2566. }
  2567. } else {
  2568. activeSortable._showClone(sortable);
  2569. }
  2570. }
  2571. }
  2572. },
  2573. dragOverAnimationCapture: function dragOverAnimationCapture(_ref11) {
  2574. var dragRect = _ref11.dragRect, isOwner = _ref11.isOwner, activeSortable = _ref11.activeSortable;
  2575. multiDragElements.forEach(function(multiDragElement) {
  2576. multiDragElement.thisAnimationDuration = null;
  2577. });
  2578. if (activeSortable.options.animation && !isOwner && activeSortable.multiDrag.isMultiDrag) {
  2579. clonesFromRect = _extends({}, dragRect);
  2580. var dragMatrix = matrix(dragEl$1, true);
  2581. clonesFromRect.top -= dragMatrix.f;
  2582. clonesFromRect.left -= dragMatrix.e;
  2583. }
  2584. },
  2585. dragOverAnimationComplete: function dragOverAnimationComplete() {
  2586. if (folding) {
  2587. folding = false;
  2588. removeMultiDragElements();
  2589. }
  2590. },
  2591. drop: function drop3(_ref12) {
  2592. var evt = _ref12.originalEvent, rootEl2 = _ref12.rootEl, parentEl2 = _ref12.parentEl, sortable = _ref12.sortable, dispatchSortableEvent = _ref12.dispatchSortableEvent, oldIndex2 = _ref12.oldIndex, putSortable2 = _ref12.putSortable;
  2593. var toSortable = putSortable2 || this.sortable;
  2594. if (!evt)
  2595. return;
  2596. var options = this.options, children = parentEl2.children;
  2597. if (!dragStarted) {
  2598. if (options.multiDragKey && !this.multiDragKeyDown) {
  2599. this._deselectMultiDrag();
  2600. }
  2601. toggleClass(dragEl$1, options.selectedClass, !~multiDragElements.indexOf(dragEl$1));
  2602. if (!~multiDragElements.indexOf(dragEl$1)) {
  2603. multiDragElements.push(dragEl$1);
  2604. dispatchEvent({
  2605. sortable,
  2606. rootEl: rootEl2,
  2607. name: "select",
  2608. targetEl: dragEl$1,
  2609. originalEvent: evt
  2610. });
  2611. if (evt.shiftKey && lastMultiDragSelect && sortable.el.contains(lastMultiDragSelect)) {
  2612. var lastIndex = index(lastMultiDragSelect), currentIndex = index(dragEl$1);
  2613. if (~lastIndex && ~currentIndex && lastIndex !== currentIndex) {
  2614. var n, i;
  2615. if (currentIndex > lastIndex) {
  2616. i = lastIndex;
  2617. n = currentIndex;
  2618. } else {
  2619. i = currentIndex;
  2620. n = lastIndex + 1;
  2621. }
  2622. for (; i < n; i++) {
  2623. if (~multiDragElements.indexOf(children[i]))
  2624. continue;
  2625. toggleClass(children[i], options.selectedClass, true);
  2626. multiDragElements.push(children[i]);
  2627. dispatchEvent({
  2628. sortable,
  2629. rootEl: rootEl2,
  2630. name: "select",
  2631. targetEl: children[i],
  2632. originalEvent: evt
  2633. });
  2634. }
  2635. }
  2636. } else {
  2637. lastMultiDragSelect = dragEl$1;
  2638. }
  2639. multiDragSortable = toSortable;
  2640. } else {
  2641. multiDragElements.splice(multiDragElements.indexOf(dragEl$1), 1);
  2642. lastMultiDragSelect = null;
  2643. dispatchEvent({
  2644. sortable,
  2645. rootEl: rootEl2,
  2646. name: "deselect",
  2647. targetEl: dragEl$1,
  2648. originalEvent: evt
  2649. });
  2650. }
  2651. }
  2652. if (dragStarted && this.isMultiDrag) {
  2653. folding = false;
  2654. if ((parentEl2[expando].options.sort || parentEl2 !== rootEl2) && multiDragElements.length > 1) {
  2655. var dragRect = getRect(dragEl$1), multiDragIndex = index(dragEl$1, ":not(." + this.options.selectedClass + ")");
  2656. if (!initialFolding && options.animation)
  2657. dragEl$1.thisAnimationDuration = null;
  2658. toSortable.captureAnimationState();
  2659. if (!initialFolding) {
  2660. if (options.animation) {
  2661. dragEl$1.fromRect = dragRect;
  2662. multiDragElements.forEach(function(multiDragElement) {
  2663. multiDragElement.thisAnimationDuration = null;
  2664. if (multiDragElement !== dragEl$1) {
  2665. var rect = folding ? getRect(multiDragElement) : dragRect;
  2666. multiDragElement.fromRect = rect;
  2667. toSortable.addAnimationState({
  2668. target: multiDragElement,
  2669. rect
  2670. });
  2671. }
  2672. });
  2673. }
  2674. removeMultiDragElements();
  2675. multiDragElements.forEach(function(multiDragElement) {
  2676. if (children[multiDragIndex]) {
  2677. parentEl2.insertBefore(multiDragElement, children[multiDragIndex]);
  2678. } else {
  2679. parentEl2.appendChild(multiDragElement);
  2680. }
  2681. multiDragIndex++;
  2682. });
  2683. if (oldIndex2 === index(dragEl$1)) {
  2684. var update = false;
  2685. multiDragElements.forEach(function(multiDragElement) {
  2686. if (multiDragElement.sortableIndex !== index(multiDragElement)) {
  2687. update = true;
  2688. return;
  2689. }
  2690. });
  2691. if (update) {
  2692. dispatchSortableEvent("update");
  2693. dispatchSortableEvent("sort");
  2694. }
  2695. }
  2696. }
  2697. multiDragElements.forEach(function(multiDragElement) {
  2698. unsetRect(multiDragElement);
  2699. });
  2700. toSortable.animateAll();
  2701. }
  2702. multiDragSortable = toSortable;
  2703. }
  2704. if (rootEl2 === parentEl2 || putSortable2 && putSortable2.lastPutMode !== "clone") {
  2705. multiDragClones.forEach(function(clone2) {
  2706. clone2.parentNode && clone2.parentNode.removeChild(clone2);
  2707. });
  2708. }
  2709. },
  2710. nullingGlobal: function nullingGlobal() {
  2711. this.isMultiDrag = dragStarted = false;
  2712. multiDragClones.length = 0;
  2713. },
  2714. destroyGlobal: function destroyGlobal() {
  2715. this._deselectMultiDrag();
  2716. off(document, "pointerup", this._deselectMultiDrag);
  2717. off(document, "mouseup", this._deselectMultiDrag);
  2718. off(document, "touchend", this._deselectMultiDrag);
  2719. off(document, "keydown", this._checkKeyDown);
  2720. off(document, "keyup", this._checkKeyUp);
  2721. },
  2722. _deselectMultiDrag: function _deselectMultiDrag(evt) {
  2723. if (typeof dragStarted !== "undefined" && dragStarted)
  2724. return;
  2725. if (multiDragSortable !== this.sortable)
  2726. return;
  2727. if (evt && closest(evt.target, this.options.draggable, this.sortable.el, false))
  2728. return;
  2729. if (evt && evt.button !== 0)
  2730. return;
  2731. while (multiDragElements.length) {
  2732. var el = multiDragElements[0];
  2733. toggleClass(el, this.options.selectedClass, false);
  2734. multiDragElements.shift();
  2735. dispatchEvent({
  2736. sortable: this.sortable,
  2737. rootEl: this.sortable.el,
  2738. name: "deselect",
  2739. targetEl: el,
  2740. originalEvent: evt
  2741. });
  2742. }
  2743. },
  2744. _checkKeyDown: function _checkKeyDown(evt) {
  2745. if (evt.key === this.options.multiDragKey) {
  2746. this.multiDragKeyDown = true;
  2747. }
  2748. },
  2749. _checkKeyUp: function _checkKeyUp(evt) {
  2750. if (evt.key === this.options.multiDragKey) {
  2751. this.multiDragKeyDown = false;
  2752. }
  2753. }
  2754. };
  2755. return _extends(MultiDrag, {
  2756. // Static methods & properties
  2757. pluginName: "multiDrag",
  2758. utils: {
  2759. /**
  2760. * Selects the provided multi-drag item
  2761. * @param {HTMLElement} el The element to be selected
  2762. */
  2763. select: function select(el) {
  2764. var sortable = el.parentNode[expando];
  2765. if (!sortable || !sortable.options.multiDrag || ~multiDragElements.indexOf(el))
  2766. return;
  2767. if (multiDragSortable && multiDragSortable !== sortable) {
  2768. multiDragSortable.multiDrag._deselectMultiDrag();
  2769. multiDragSortable = sortable;
  2770. }
  2771. toggleClass(el, sortable.options.selectedClass, true);
  2772. multiDragElements.push(el);
  2773. },
  2774. /**
  2775. * Deselects the provided multi-drag item
  2776. * @param {HTMLElement} el The element to be deselected
  2777. */
  2778. deselect: function deselect(el) {
  2779. var sortable = el.parentNode[expando], index2 = multiDragElements.indexOf(el);
  2780. if (!sortable || !sortable.options.multiDrag || !~index2)
  2781. return;
  2782. toggleClass(el, sortable.options.selectedClass, false);
  2783. multiDragElements.splice(index2, 1);
  2784. }
  2785. },
  2786. eventProperties: function eventProperties() {
  2787. var _this3 = this;
  2788. var oldIndicies = [], newIndicies = [];
  2789. multiDragElements.forEach(function(multiDragElement) {
  2790. oldIndicies.push({
  2791. multiDragElement,
  2792. index: multiDragElement.sortableIndex
  2793. });
  2794. var newIndex2;
  2795. if (folding && multiDragElement !== dragEl$1) {
  2796. newIndex2 = -1;
  2797. } else if (folding) {
  2798. newIndex2 = index(multiDragElement, ":not(." + _this3.options.selectedClass + ")");
  2799. } else {
  2800. newIndex2 = index(multiDragElement);
  2801. }
  2802. newIndicies.push({
  2803. multiDragElement,
  2804. index: newIndex2
  2805. });
  2806. });
  2807. return {
  2808. items: _toConsumableArray(multiDragElements),
  2809. clones: [].concat(multiDragClones),
  2810. oldIndicies,
  2811. newIndicies
  2812. };
  2813. },
  2814. optionListeners: {
  2815. multiDragKey: function multiDragKey(key) {
  2816. key = key.toLowerCase();
  2817. if (key === "ctrl") {
  2818. key = "Control";
  2819. } else if (key.length > 1) {
  2820. key = key.charAt(0).toUpperCase() + key.substr(1);
  2821. }
  2822. return key;
  2823. }
  2824. }
  2825. });
  2826. }
  2827. function insertMultiDragElements(clonesInserted, rootEl2) {
  2828. multiDragElements.forEach(function(multiDragElement, i) {
  2829. var target = rootEl2.children[multiDragElement.sortableIndex + (clonesInserted ? Number(i) : 0)];
  2830. if (target) {
  2831. rootEl2.insertBefore(multiDragElement, target);
  2832. } else {
  2833. rootEl2.appendChild(multiDragElement);
  2834. }
  2835. });
  2836. }
  2837. function insertMultiDragClones(elementsInserted, rootEl2) {
  2838. multiDragClones.forEach(function(clone2, i) {
  2839. var target = rootEl2.children[clone2.sortableIndex + (elementsInserted ? Number(i) : 0)];
  2840. if (target) {
  2841. rootEl2.insertBefore(clone2, target);
  2842. } else {
  2843. rootEl2.appendChild(clone2);
  2844. }
  2845. });
  2846. }
  2847. function removeMultiDragElements() {
  2848. multiDragElements.forEach(function(multiDragElement) {
  2849. if (multiDragElement === dragEl$1)
  2850. return;
  2851. multiDragElement.parentNode && multiDragElement.parentNode.removeChild(multiDragElement);
  2852. });
  2853. }
  2854. Sortable.mount(new AutoScrollPlugin());
  2855. Sortable.mount(Remove, Revert);
  2856. var sortable_esm_default = Sortable;
  2857. export {
  2858. MultiDragPlugin as MultiDrag,
  2859. Sortable,
  2860. SwapPlugin as Swap,
  2861. sortable_esm_default as default
  2862. };
  2863. /*! Bundled license information:
  2864. sortablejs/modular/sortable.esm.js:
  2865. (**!
  2866. * Sortable 1.15.2
  2867. * @author RubaXa <trash@rubaxa.org>
  2868. * @author owenm <owen23355@gmail.com>
  2869. * @license MIT
  2870. *)
  2871. */
  2872. //# sourceMappingURL=sortablejs.js.map