-import Sortable from "sortablejs";
-import {Component} from "./component";
-
-/**
- * @type {Object<string, function(HTMLElement, HTMLElement, HTMLElement)>}
- */
-const itemActions = {
- move_up(item, shelfBooksList, allBooksList) {
- const list = item.parentNode;
- const index = Array.from(list.children).indexOf(item);
- const newIndex = Math.max(index - 1, 0);
- list.insertBefore(item, list.children[newIndex] || null);
- },
- move_down(item, shelfBooksList, allBooksList) {
- const list = item.parentNode;
- const index = Array.from(list.children).indexOf(item);
- const newIndex = Math.min(index + 2, list.children.length);
- list.insertBefore(item, list.children[newIndex] || null);
- },
- remove(item, shelfBooksList, allBooksList) {
- allBooksList.appendChild(item);
- },
- add(item, shelfBooksList, allBooksList) {
- shelfBooksList.appendChild(item);
- },
-};
+import Sortable from 'sortablejs';
+import {Component} from './component';
+import {buildListActions, sortActionClickListener} from '../services/dual-lists.ts';