@snapgridjs/react 0.1.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 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,66 @@
1
+ # @snapgridjs/react
2
+
3
+ **A [react-grid-layout](https://github.com/react-grid-layout/react-grid-layout) v2 alternative, built on [dnd-kit](https://github.com/clauderic/dnd-kit).**
4
+
5
+ Draggable, resizable, responsive grid layouts for React — with pluggable packing and dragging tiles _between_ grids.
6
+
7
+ [![npm](https://img.shields.io/npm/v/@snapgridjs/react.svg)](https://www.npmjs.com/package/@snapgridjs/react)
8
+ [![License: MIT](https://img.shields.io/badge/license-MIT-c2410c.svg)](https://github.com/eleung/snapgrid/blob/main/LICENSE)
9
+
10
+ [**Documentation**](https://snapgrid.dev) ·
11
+ [Getting Started](https://snapgrid.dev/docs/getting-started) ·
12
+ [Examples](https://snapgrid.dev/examples) ·
13
+ [API](https://snapgrid.dev/docs/api/overview)
14
+
15
+ ## Why snapgrid
16
+
17
+ - **Controlled & predictable** — you own the layout array; every change comes back through `onLayoutChange`. No hidden state.
18
+ - **Headless or drop-in** — `<GridLayout>` for the common case, or `SnapGridProvider` + hooks for full control of the markup. Ships **no CSS**.
19
+ - **Pluggable packing** — `vertical` / `horizontal` / `none`, plus `masonry` / `gravity` / `shelf` from [`@snapgridjs/extras`](https://www.npmjs.com/package/@snapgridjs/extras), or your own `Compactor`.
20
+ - **Cross-grid dragging** — wrap grids in a `<SnapGridGroup>` and drag tiles between them.
21
+ - **Nested grids** — drop a grid inside a tile of another grid; each level keeps its own isolated drag session.
22
+ - **Responsive** — per-breakpoint layouts with `<ResponsiveGridLayout>`.
23
+ - **Keyboard accessible** — Enter/Space to pick up, arrow keys to move, Esc to cancel.
24
+ - **SSR-safe** and **TypeScript-first** (types included).
25
+
26
+ ## Install
27
+
28
+ ```sh
29
+ pnpm add @snapgridjs/react @dnd-kit/react @dnd-kit/dom
30
+ ```
31
+
32
+ `@snapgridjs/extras` (masonry/gravity/shelf packers) is optional.
33
+
34
+ ## Quick start
35
+
36
+ ```tsx
37
+ import { GridLayout, useContainerWidth, type Layout } from "@snapgridjs/react";
38
+ import { useState } from "react";
39
+
40
+ export function Board() {
41
+ const { width, containerRef } = useContainerWidth();
42
+ const [layout, setLayout] = useState<Layout>([
43
+ { i: "a", x: 0, y: 0, w: 4, h: 2 },
44
+ { i: "b", x: 4, y: 0, w: 4, h: 2 },
45
+ { i: "c", x: 8, y: 0, w: 4, h: 2 },
46
+ ]);
47
+
48
+ return (
49
+ <div ref={containerRef}>
50
+ <GridLayout layout={layout} width={width} onLayoutChange={setLayout}>
51
+ {layout.map((item) => (
52
+ <div key={item.i} className="tile">
53
+ {item.i}
54
+ </div>
55
+ ))}
56
+ </GridLayout>
57
+ </div>
58
+ );
59
+ }
60
+ ```
61
+
62
+ → Full walkthrough in [**Getting Started**](https://snapgrid.dev/docs/getting-started).
63
+
64
+ ## License
65
+
66
+ MIT © Edmond Leung