@shiguri/solid-grid 0.1.0 → 0.1.1

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 +37 -29
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,8 +1,9 @@
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
 
8
9
  ## Installation
@@ -14,45 +15,52 @@ npm install @shiguri/solid-grid
14
15
  ## Usage
15
16
 
16
17
  ```tsx
17
- import { createSignal } from "solid-js";
18
18
  import {
19
19
  Gridsheet,
20
+ clipboardTextPlugin,
20
21
  createPluginHost,
22
+ deletePlugin,
21
23
  selectionPlugin,
22
24
  editingPlugin,
23
25
  } from "@shiguri/solid-grid";
26
+ import { textCellRenderer } from "@shiguri/solid-grid/presets";
27
+ import { createSignal } from "solid-js";
28
+
29
+ function App() {
30
+ const [data, setData] = createSignal([
31
+ ["A1", "B1"],
32
+ ["A2", "B2"],
33
+ ]);
34
+
35
+ const plugins = createPluginHost<string>([
36
+ selectionPlugin(),
37
+ editingPlugin(),
38
+ deletePlugin({ emptyValue: "" }),
39
+ clipboardTextPlugin({ getData: () => data(), emptyValue: "" }),
40
+ ]);
24
41
 
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;
42
+ return (
43
+ <Gridsheet
44
+ data={data()}
45
+ renderCell={textCellRenderer}
46
+ onCellsChange={(patches) =>
47
+ setData((prev) => {
48
+ const next = prev.map((row) => row.slice());
49
+ for (const { pos, value } of patches) {
50
+ next[pos.row][pos.col] = value;
51
+ }
52
+ return next;
53
+ })
42
54
  }
43
- return next;
44
- })
45
- }
46
- renderCell={(ctx) => <span>{ctx.value}</span>}
47
- onEvent={plugins.onEvent}
48
- />;
55
+ onEvent={plugins.onEvent}
56
+ />
57
+ );
58
+ }
49
59
  ```
50
60
 
51
61
  ## Documentation
52
62
 
53
- - `docs/guide.md`
54
- - `docs/recipes.md`
55
- - `docs/styling.md`
63
+ See the [docs/](./docs/) directory.
56
64
 
57
65
  ---
58
66
 
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.1",
4
4
  "private": false,
5
5
  "author": {
6
6
  "name": "shiguri",