|
3 | 3 | import { invoke, SeelenCommand } from "@seelen-ui/lib"; |
4 | 4 | import { FileIcon } from "libs/ui/svelte/components/Icon"; |
5 | 5 | import { globalState } from "../state/mod.svelte"; |
6 | | - import { createDroppable, createDraggable } from "@dnd-kit/svelte"; |
| 6 | + import { createSortable } from "@dnd-kit/svelte/sortable"; |
7 | 7 |
|
8 | 8 | interface Props { |
9 | 9 | item: StartMenuItem; |
|
30 | 30 | globalState.preselectedItem === itemId || (idx === 0 && !globalState.preselectedItem), |
31 | 31 | ); |
32 | 32 |
|
33 | | - const draggable = $derived( |
34 | | - createDraggable({ |
35 | | - id: itemId, |
36 | | - disabled: !isDraggable, |
37 | | - type: isInsideFolder ? "grouped-app" : "app", |
38 | | - }), |
39 | | - ); |
40 | | -
|
41 | | - const droppable = $derived( |
42 | | - createDroppable({ |
43 | | - id: itemId, |
44 | | - disabled: !isDraggable, |
45 | | - accept: isInsideFolder ? "grouped-app" : ["folder", "app"], |
46 | | - type: isInsideFolder ? "grouped-app" : "app", |
47 | | - }), |
48 | | - ); |
| 33 | + const sortable = createSortable({ |
| 34 | + get id() { |
| 35 | + return itemId; |
| 36 | + }, |
| 37 | + get disabled() { |
| 38 | + return !isDraggable; |
| 39 | + }, |
| 40 | + get index() { |
| 41 | + return idx; |
| 42 | + }, |
| 43 | + get type() { |
| 44 | + return isInsideFolder ? "grouped-app" : "app"; |
| 45 | + }, |
| 46 | + get accept() { |
| 47 | + return isInsideFolder ? "grouped-app" : ["folder", "app"]; |
| 48 | + }, |
| 49 | + }); |
49 | 50 |
|
50 | 51 | function handleClick(event: MouseEvent) { |
51 | 52 | globalState.showing = false; // inmediate close |
|
61 | 62 | </script> |
62 | 63 |
|
63 | 64 | <button |
64 | | - {@attach draggable.attach} |
65 | | - {@attach droppable.attach} |
| 65 | + {@attach sortable.attach} |
| 66 | + {@attach sortable.attachHandle} |
66 | 67 | data-item-id={itemId} |
67 | 68 | class="app" |
68 | 69 | class:preselected={isPreselected && globalState.searchQuery} |
69 | | - class:is-dragging={draggable.isDragging} |
70 | | - class:is-dropping={draggable.isDropping} |
| 70 | + class:is-dragging={sortable.isDragging} |
| 71 | + class:is-dropping={sortable.isDropping} |
71 | 72 | class:is-drop-target={isActiveDropzone} |
72 | 73 | onclick={handleClick} |
73 | 74 | oncontextmenu={handleContextMenu} |
|
0 commit comments