@snapgridjs/dnd 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +36 -0
- package/dist/index.cjs +676 -0
- package/dist/index.d.cts +261 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +261 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +667 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +66 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Edmond Leung
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# @snapgridjs/dnd
|
|
2
|
+
|
|
3
|
+
The framework-agnostic dnd-kit engine for [snapgrid](https://github.com/eleung/snapgrid) — the drag, resize, and cross-grid orchestration that [`@snapgridjs/react`](https://www.npmjs.com/package/@snapgridjs/react) is built on, with no React (or any framework) dependency.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@snapgridjs/dnd)
|
|
6
|
+
[](https://github.com/eleung/snapgrid/blob/main/LICENSE)
|
|
7
|
+
|
|
8
|
+
> **Most users want [`@snapgridjs/react`](https://www.npmjs.com/package/@snapgridjs/react), not this package.** `@snapgridjs/dnd` is the shared engine the framework bindings compose. Reach for it directly only to build a binding for another framework (Vue, Solid, Svelte, vanilla) on top of the same engine.
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
pnpm add @snapgridjs/dnd @dnd-kit/dom
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
`@dnd-kit/dom`, `@dnd-kit/abstract`, and `@dnd-kit/collision` are peer dependencies (so there's a single shared copy); `@snapgridjs/core` comes in automatically.
|
|
17
|
+
|
|
18
|
+
## What's here
|
|
19
|
+
|
|
20
|
+
One per-manager engine, plus the pieces a binding wires up:
|
|
21
|
+
|
|
22
|
+
- **`attachEngine(manager)`** — attach the drag/resize/receive engine to a dnd-kit manager (ref-counted; one per manager). It listens to the manager's drag lifecycle and drives every registered grid — including cross-grid hand-off.
|
|
23
|
+
- **`GridController`** — the observable per-grid render bridge. A binding writes per-grid config into it and subscribes to the rendered layout / per-tile snapshots (e.g. via `useSyncExternalStore`).
|
|
24
|
+
- **`registerController` / `getController`** — resolve a grid's controller by id, scoped to a manager.
|
|
25
|
+
- **Interaction helpers** — `gridCollisionDetector`, `SnapToGrid`, `buildItemSensors`, `domElement`, and the pure `dragFlow` decision functions (`classifyDrop`, `receiveCell`, …).
|
|
26
|
+
- **Config & event types** — `DragConfig`, `ResizeConfig`, `DropConfig`, `GridDropData`, `GridEventCallback` (also re-exported from `@snapgridjs/react`).
|
|
27
|
+
|
|
28
|
+
The layout math — compaction, geometry, move/resize, and the drag-session state machine — lives in [`@snapgridjs/core`](https://www.npmjs.com/package/@snapgridjs/core); this package adds the dnd-kit interaction layer on top, and the framework bindings add rendering.
|
|
29
|
+
|
|
30
|
+
## Stability
|
|
31
|
+
|
|
32
|
+
The binding-author surface is still settling as the first non-React bindings are built — treat these exports as semi-stable.
|
|
33
|
+
|
|
34
|
+
## License
|
|
35
|
+
|
|
36
|
+
MIT
|