Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .changeset/drag-new-package.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
"@solid-primitives/drag-drop": minor
---

New package: `@solid-primitives/drag-drop` — composable drag-and-drop primitives for Solid 2.0.

### Exports

**Pointer-event DnD** (UI element dragging):
- `makeDraggable` — non-reactive base, no Solid owner required
- `makeDroppable` — non-reactive drop target base
- `createDraggable` — reactive draggable with `isDragging`, `transform`, auto style/class; keyboard-accessible (`Space`/`Enter` to pick up/drop, arrow keys to nudge, `Escape` to cancel)
- `createDroppable` — reactive drop target with `isOver`, `active`, auto style/class
- `createSortable` — combines draggable + droppable on the same element
- `createDragContext` — coordinates a tree of draggables and droppables, with optional `autoScroll` near viewport edges
- `arrayMove` — pure reorder helper for `onDragEnd` + `createSortable`

**Native HTML5 DnD** (file drops, `draggable="true"` elements):
- `makeNativeDroppable` — non-reactive base with depth-counter fix for child elements
- `createNativeDroppable` — reactive native drop zone for OS file drops

**Collision detection strategies** (pure functions, pass to `createDragContext`):
- `closestCenter`, `closestCorners`, `rectIntersection`, `pointerWithin` (default)

### Notes

- The reported `transform` is corrected for page scroll during a drag, so the dragged element doesn't visually drift from the pointer if the page scrolls mid-drag (needed for `autoScroll` to look right, and for any scrollable page in general).
- `createDroppable`/`createSortable` log a dev-mode warning when used without a `createDragContext` ancestor, since `isOver`/`active` silently stay `false`/`null` in that case.
- `isDragging`/`isOver` are backed by `createProjection` instead of a per-instance `active()?.id === id` memo, so a drag start/end or hover change in a large list only notifies the specific items involved.
54 changes: 19 additions & 35 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions packages/drag-drop/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 Solid Primitives Working Group

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading