1export async function createSortable(el, opts = {}) {
2 const {Sortable} = await import(/* webpackChunkName: "sortablejs" */'sortablejs');
3
4 return new Sortable(el, {
5 animation: 150,
6 ghostClass: 'card-ghost',
7 onChoose: (e) => {
8 const handle = opts.handle ? e.item.querySelector(opts.handle) : e.item;
9 handle.classList.add('tw-cursor-grabbing');
10 opts.onChoose?.(e);
11 },
12 onUnchoose: (e) => {
13 const handle = opts.handle ? e.item.querySelector(opts.handle) : e.item;
14 handle.classList.remove('tw-cursor-grabbing');
15 opts.onUnchoose?.(e);
16 },
17 ...opts,
18 });
19}