xontable 0.1.1 → 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.
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# xontable
|
|
2
2
|
|
|
3
|
-
A spreadsheet-like React table component
|
|
3
|
+
A spreadsheet-like React table component for editable, Excel-style grids.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
@@ -11,19 +11,62 @@ npm install xontable
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
13
|
```tsx
|
|
14
|
+
import React, { useState } from "react";
|
|
14
15
|
import { XOnTable, type ColumnDef } from "xontable";
|
|
15
16
|
import "xontable/styles";
|
|
16
17
|
|
|
18
|
+
type Row = { id: string; name: string; qty: string };
|
|
19
|
+
|
|
17
20
|
const columns: ColumnDef<Row>[] = [
|
|
18
|
-
{ key: "name", label: "Name",
|
|
21
|
+
{ key: "name", label: "Name", editable: true },
|
|
19
22
|
{ key: "qty", label: "Qty", type: "number", editable: true },
|
|
20
23
|
];
|
|
21
24
|
|
|
22
|
-
|
|
25
|
+
export default function App() {
|
|
26
|
+
const [rows, setRows] = useState<Row[]>([
|
|
27
|
+
{ id: "1", name: "Rice", qty: "10" },
|
|
28
|
+
]);
|
|
29
|
+
|
|
30
|
+
return <XOnTable columns={columns} rows={rows} onChange={setRows} />;
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Column Types
|
|
35
|
+
- `text`
|
|
36
|
+
- `number`
|
|
37
|
+
- `date`
|
|
38
|
+
- `select`
|
|
39
|
+
- `checkbox`
|
|
40
|
+
|
|
41
|
+
## Select Dropdowns
|
|
42
|
+
Use `options` or `getOptions`:
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
{ key: "city", label: "City", type: "select", options: [
|
|
46
|
+
{ value: "tokyo", label: "Tokyo" }
|
|
47
|
+
] }
|
|
23
48
|
```
|
|
24
49
|
|
|
25
|
-
##
|
|
26
|
-
|
|
27
|
-
|
|
50
|
+
## Validation
|
|
51
|
+
Use `validator` per column:
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
{ key: "qty", label: "Qty", type: "number", validator: (v) => v ? null : "Required" }
|
|
55
|
+
```
|
|
28
56
|
|
|
29
|
-
|
|
57
|
+
## Readonly & Theme
|
|
58
|
+
|
|
59
|
+
```tsx
|
|
60
|
+
<XOnTable readOnly theme="dark" />
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Requirements
|
|
64
|
+
- React 19+
|
|
65
|
+
- Peer deps: `react`, `react-dom`, `lucide-react`
|
|
66
|
+
|
|
67
|
+
## Styles
|
|
68
|
+
Required:
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
import "xontable/styles";
|
|
72
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xontable",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -11,17 +11,16 @@
|
|
|
11
11
|
"types": "./dist/index.d.ts",
|
|
12
12
|
"default": "./dist/index.js"
|
|
13
13
|
},
|
|
14
|
-
"./styles": "./
|
|
14
|
+
"./styles": "./dist/styles/xontable.css"
|
|
15
15
|
},
|
|
16
16
|
"sideEffects": [
|
|
17
|
-
"./
|
|
17
|
+
"./dist/styles/xontable.css"
|
|
18
18
|
],
|
|
19
19
|
"files": [
|
|
20
|
-
"dist"
|
|
21
|
-
"src/styles"
|
|
20
|
+
"dist"
|
|
22
21
|
],
|
|
23
22
|
"scripts": {
|
|
24
|
-
"build": "tsc -p tsconfig.json",
|
|
23
|
+
"build": "tsc -p tsconfig.json && node ./scripts/copy-styles.mjs",
|
|
25
24
|
"clean": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\"",
|
|
26
25
|
"prepublishOnly": "npm run clean && npm run build"
|
|
27
26
|
},
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|