@shiguri/solid-grid 0.1.0 → 0.1.2

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.
Files changed (2) hide show
  1. package/README.md +41 -29
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,10 +1,15 @@
1
1
  # solid-grid
2
2
 
3
- A headless, plugin-driven grid component for [SolidJS](https://www.solidjs.com/).
4
- Designed for **T[][]** data and custom rendering.
3
+ A headless grid component for [SolidJS](https://docs.solidjs.com/).
4
+ Designed for `T[][]` data with custom rendering.
5
5
 
6
+ > [!WARNING]
6
7
  > **Work in progress**: The API is still evolving and may include breaking changes.
7
8
 
9
+ ## Demo
10
+
11
+ [solid-grid.vercel.app](https://solid-grid.vercel.app)
12
+
8
13
  ## Installation
9
14
 
10
15
  ```bash
@@ -14,45 +19,52 @@ npm install @shiguri/solid-grid
14
19
  ## Usage
15
20
 
16
21
  ```tsx
17
- import { createSignal } from "solid-js";
18
22
  import {
19
23
  Gridsheet,
24
+ clipboardTextPlugin,
20
25
  createPluginHost,
26
+ deletePlugin,
21
27
  selectionPlugin,
22
28
  editingPlugin,
23
29
  } from "@shiguri/solid-grid";
30
+ import { textCellRenderer } from "@shiguri/solid-grid/presets";
31
+ import { createSignal } from "solid-js";
32
+
33
+ function App() {
34
+ const [data, setData] = createSignal([
35
+ ["A1", "B1"],
36
+ ["A2", "B2"],
37
+ ]);
38
+
39
+ const plugins = createPluginHost<string>([
40
+ selectionPlugin(),
41
+ editingPlugin(),
42
+ deletePlugin({ emptyValue: "" }),
43
+ clipboardTextPlugin({ getData: () => data(), emptyValue: "" }),
44
+ ]);
24
45
 
25
- const [data, setData] = createSignal([
26
- ["A1", "B1"],
27
- ["A2", "B2"],
28
- ]);
29
-
30
- const plugins = createPluginHost([
31
- selectionPlugin(),
32
- editingPlugin({ triggerKeys: ["Enter"] }),
33
- ]);
34
-
35
- <Gridsheet
36
- data={data()}
37
- onCellsChange={(patches) =>
38
- setData((prev) => {
39
- const next = prev.map((row) => row.slice());
40
- for (const { pos, value } of patches) {
41
- next[pos.row][pos.col] = value;
46
+ return (
47
+ <Gridsheet
48
+ data={data()}
49
+ renderCell={textCellRenderer}
50
+ onCellsChange={(patches) =>
51
+ setData((prev) => {
52
+ const next = prev.map((row) => row.slice());
53
+ for (const { pos, value } of patches) {
54
+ next[pos.row][pos.col] = value;
55
+ }
56
+ return next;
57
+ })
42
58
  }
43
- return next;
44
- })
45
- }
46
- renderCell={(ctx) => <span>{ctx.value}</span>}
47
- onEvent={plugins.onEvent}
48
- />;
59
+ onEvent={plugins.onEvent}
60
+ />
61
+ );
62
+ }
49
63
  ```
50
64
 
51
65
  ## Documentation
52
66
 
53
- - `docs/guide.md`
54
- - `docs/recipes.md`
55
- - `docs/styling.md`
67
+ See the [docs/](./docs/) directory.
56
68
 
57
69
  ---
58
70
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shiguri/solid-grid",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "private": false,
5
5
  "author": {
6
6
  "name": "shiguri",