{item.title}
{item.description}
=============== LIBRARY RULES =============== From library maintainers: - Always import from '@thisux/sveltednd' not from internal paths - Use Svelte 5 runes ($state, $effect) not legacy stores - draggable and droppable are Svelte actions used with use: directive - For grid/flex-wrap layouts set direction: 'grid' on droppable - Import '@thisux/sveltednd/dnd.css' for drop position indicator styles ### Install @thisux/sveltednd Source: https://github.com/thisuxhq/sveltednd/blob/main/README.md Installation commands for various package managers. ```bash npm install @thisux/sveltednd # or bun add @thisux/sveltednd # or yarn add @thisux/sveltednd # or pnpm add @thisux/sveltednd ``` -------------------------------- ### Initialize Project Environment Source: https://github.com/thisuxhq/sveltednd/blob/main/CONTRIBUTING.md Clone the repository and install dependencies to begin development. ```bash git clone https://github.com/thisuxhq/sveltednd.git cd sveltednd bun install ``` -------------------------------- ### Installation Source: https://context7.com/thisuxhq/sveltednd/llms.txt Install the @thisux/sveltednd package using your preferred package manager. ```APIDOC ## Installation Install the package from npm using your preferred package manager. ```bash npm install @thisux/sveltednd # or bun add @thisux/sveltednd # or yarn add @thisux/sveltednd # or pnpm add @thisux/sveltednd ``` ``` -------------------------------- ### Kanban Board Example Source: https://github.com/thisuxhq/sveltednd/blob/main/README.md Demonstrates a Kanban board with multiple containers (columns) for different task statuses. The handleDrop function updates the card's status based on the target container. ```svelte
{item.description}
{task.description}
Dragging: {dndState.draggedItem?.name}
From: {dndState.sourceContainer}
{#if dndState.targetContainer}Over: {dndState.targetContainer}
Position: {dndState.dropPosition}
{/if} {#if dndState.invalidDrop}Invalid drop zone!
{/if}Dragging {dndState.draggedItem?.name} from {dndState.sourceContainer}
{/if} ``` -------------------------------- ### dndState Source: https://github.com/thisuxhq/sveltednd/blob/main/static/llms.txt Global reactive state object tracking the current drag operation. ```APIDOC ## dndState ### Description A global reactive object (Svelte 5 $state rune) that tracks the current drag operation. Do not mutate manually. ### Fields - **isDragging** (boolean) - True from dragstart until dragend. - **draggedItem** (T | null) - The data payload being dragged. - **sourceContainer** (string) - Container ID where the drag started. - **targetContainer** (string | null) - Container ID currently being hovered over. - **targetElement** (HTMLElement | null) - The specific DOM element under the cursor. - **dropPosition** ('before' | 'after' | null) - Where the item will land relative to targetElement. - **invalidDrop** (boolean) - Set to true when hovering over an invalid drop zone. ``` -------------------------------- ### DragDropOptions{item.description}
Dragging item: {dndState.draggedItem?.id}
From container: {dndState.sourceContainer}
{:else}Not currently dragging.
{/if} ``` ### Response #### Success Response (200) `dndState` object with the following properties: - `isDragging` (boolean): Indicates if a drag operation is in progress. - `draggedItem` (any): The data of the item being dragged. - `sourceContainer` (string | null): The identifier of the container from which the item was dragged. - `currentContainer` (string | null): The identifier of the container the item is currently over. #### Response Example ```json { "isDragging": true, "draggedItem": { "id": 1, "name": "Example Item" }, "sourceContainer": "list-a", "currentContainer": "list-b" } ``` ``` -------------------------------- ### Display Real-Time Drag State in Svelte Source: https://github.com/thisuxhq/sveltednd/blob/main/static/llms.txt Use the `dndState` store to display information about the current drag operation, such as whether a drag is in progress and details about the dragged item and target container. ```svelte {#if dndState.isDragging}