react-excel-lite 0.1.0 → 0.2.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/README.md +28 -38
- package/dist/components/grid-cell.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/react-excel-lite.js +467 -418
- package/dist/react-excel-lite.umd.cjs +2 -2
- package/dist/types.d.ts +7 -27
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -16,6 +16,7 @@ A lightweight, Excel-like editable grid component for React.
|
|
|
16
16
|
- Grouped column headers with custom styling
|
|
17
17
|
- Row headers with custom styling
|
|
18
18
|
- Keyboard shortcuts (Delete/Backspace to clear)
|
|
19
|
+
- Expandable input field when editing (text overflow handling)
|
|
19
20
|
- **Styling-agnostic**: Works with Tailwind CSS, CSS Modules, plain CSS, or any styling solution
|
|
20
21
|
- Zero external dependencies
|
|
21
22
|
|
|
@@ -27,7 +28,7 @@ npm install react-excel-lite
|
|
|
27
28
|
|
|
28
29
|
## Quick Start
|
|
29
30
|
|
|
30
|
-
|
|
31
|
+
```tsx
|
|
31
32
|
import { useState } from "react";
|
|
32
33
|
import { ExcelGrid } from "react-excel-lite";
|
|
33
34
|
|
|
@@ -40,6 +41,7 @@ function App() {
|
|
|
40
41
|
|
|
41
42
|
return <ExcelGrid data={data} onChange={setData} />;
|
|
42
43
|
}
|
|
44
|
+
```
|
|
43
45
|
|
|
44
46
|
## Props
|
|
45
47
|
|
|
@@ -47,8 +49,8 @@ function App() {
|
|
|
47
49
|
| ---------------- | ---------------------------- | -------- | --------------------------- |
|
|
48
50
|
| `data` | `string[][]` | Yes | 2D array of strings |
|
|
49
51
|
| `onChange` | `(data: string[][]) => void` | Yes | Callback when data changes |
|
|
50
|
-
| `rowHeaders` | `
|
|
51
|
-
| `colHeaders` | `
|
|
52
|
+
| `rowHeaders` | `HeaderGroup[]` | No | Row header definitions |
|
|
53
|
+
| `colHeaders` | `HeaderGroup[]` | No | Grouped column headers |
|
|
52
54
|
| `className` | `string` | No | CSS class for container |
|
|
53
55
|
| `rowHeaderTitle` | `string` | No | Title for row header column |
|
|
54
56
|
| `styles` | `GridStyles` | No | Style configuration object |
|
|
@@ -58,7 +60,7 @@ function App() {
|
|
|
58
60
|
```tsx
|
|
59
61
|
import { useState } from "react";
|
|
60
62
|
import { ExcelGrid } from "react-excel-lite";
|
|
61
|
-
import type {
|
|
63
|
+
import type { HeaderGroup } from "react-excel-lite";
|
|
62
64
|
|
|
63
65
|
function App() {
|
|
64
66
|
const [data, setData] = useState([
|
|
@@ -66,7 +68,7 @@ function App() {
|
|
|
66
68
|
["500", "600", "700", "800"],
|
|
67
69
|
]);
|
|
68
70
|
|
|
69
|
-
const colHeaders:
|
|
71
|
+
const colHeaders: HeaderGroup[] = [
|
|
70
72
|
{
|
|
71
73
|
label: "Q1",
|
|
72
74
|
headers: [
|
|
@@ -83,9 +85,14 @@ function App() {
|
|
|
83
85
|
},
|
|
84
86
|
];
|
|
85
87
|
|
|
86
|
-
const rowHeaders:
|
|
87
|
-
{
|
|
88
|
-
|
|
88
|
+
const rowHeaders: HeaderGroup[] = [
|
|
89
|
+
{
|
|
90
|
+
label: "Products",
|
|
91
|
+
headers: [
|
|
92
|
+
{ key: "prodA", label: "Product A", description: "Main product line" },
|
|
93
|
+
{ key: "prodB", label: "Product B", description: "Secondary product" },
|
|
94
|
+
],
|
|
95
|
+
},
|
|
89
96
|
];
|
|
90
97
|
|
|
91
98
|
return (
|
|
@@ -98,7 +105,7 @@ function App() {
|
|
|
98
105
|
/>
|
|
99
106
|
);
|
|
100
107
|
}
|
|
101
|
-
|
|
108
|
+
```
|
|
102
109
|
|
|
103
110
|
## Styling
|
|
104
111
|
|
|
@@ -193,7 +200,7 @@ interface GridStyles {
|
|
|
193
200
|
Style individual column headers and groups:
|
|
194
201
|
|
|
195
202
|
```tsx
|
|
196
|
-
const colHeaders:
|
|
203
|
+
const colHeaders: HeaderGroup[] = [
|
|
197
204
|
{
|
|
198
205
|
label: "Revenue",
|
|
199
206
|
className: "bg-green-100 text-green-700",
|
|
@@ -208,11 +215,13 @@ const colHeaders: ColHeaderGroup[] = [
|
|
|
208
215
|
Style individual row headers:
|
|
209
216
|
|
|
210
217
|
```tsx
|
|
211
|
-
const rowHeaders:
|
|
218
|
+
const rowHeaders: HeaderGroup[] = [
|
|
212
219
|
{
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
220
|
+
label: "Regions",
|
|
221
|
+
headers: [
|
|
222
|
+
{ key: "regionA", label: "Region A", className: "bg-slate-700 text-white" },
|
|
223
|
+
{ key: "regionB", label: "Region B", className: "bg-slate-600 text-white" },
|
|
224
|
+
],
|
|
216
225
|
},
|
|
217
226
|
];
|
|
218
227
|
```
|
|
@@ -272,22 +281,16 @@ interface SelectionRange {
|
|
|
272
281
|
end: CellCoord | null;
|
|
273
282
|
}
|
|
274
283
|
|
|
275
|
-
interface
|
|
284
|
+
interface Header {
|
|
276
285
|
key: string;
|
|
277
286
|
label: string;
|
|
278
287
|
description?: string;
|
|
279
288
|
className?: string;
|
|
280
289
|
}
|
|
281
290
|
|
|
282
|
-
interface
|
|
283
|
-
label: string;
|
|
284
|
-
headers: ColHeader[];
|
|
285
|
-
className?: string;
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
interface RowHeaderGroup {
|
|
289
|
-
key: string;
|
|
291
|
+
interface HeaderGroup {
|
|
290
292
|
label: string;
|
|
293
|
+
headers: Header[];
|
|
291
294
|
description?: string;
|
|
292
295
|
className?: string;
|
|
293
296
|
}
|
|
@@ -305,27 +308,14 @@ interface GridStyles {
|
|
|
305
308
|
interface ExcelGridProps {
|
|
306
309
|
data: string[][];
|
|
307
310
|
onChange: (data: string[][]) => void;
|
|
308
|
-
rowHeaders?:
|
|
309
|
-
colHeaders?:
|
|
311
|
+
rowHeaders?: HeaderGroup[];
|
|
312
|
+
colHeaders?: HeaderGroup[];
|
|
310
313
|
className?: string;
|
|
311
314
|
rowHeaderTitle?: string;
|
|
312
315
|
styles?: GridStyles;
|
|
313
316
|
}
|
|
314
317
|
```
|
|
315
318
|
|
|
316
|
-
## Development
|
|
317
|
-
|
|
318
|
-
```bash
|
|
319
|
-
# Install dependencies
|
|
320
|
-
npm install
|
|
321
|
-
|
|
322
|
-
# Run demo
|
|
323
|
-
npm run dev
|
|
324
|
-
|
|
325
|
-
# Build library
|
|
326
|
-
cd lib && npm run build
|
|
327
|
-
```
|
|
328
|
-
|
|
329
319
|
## License
|
|
330
320
|
|
|
331
321
|
MIT License © 2025 prkgnt
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grid-cell.d.ts","sourceRoot":"","sources":["../../src/components/grid-cell.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"grid-cell.d.ts","sourceRoot":"","sources":["../../src/components/grid-cell.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AA8E9C,wBAAgB,QAAQ,CAAC,EACvB,KAAK,EACL,KAAK,EACL,UAAU,EACV,YAAY,EACZ,cAAc,EACd,WAAW,EACX,YAAY,EACZ,QAAQ,EACR,qBAAqB,EACrB,MAAM,GACP,EAAE,aAAa,2CA4Kf"}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,5 +6,5 @@ export { useGridDragFill } from './hooks/use-grid-drag-fill';
|
|
|
6
6
|
export { cn } from './utils/cn';
|
|
7
7
|
export { formatCurrency, parseCurrency } from './utils/format-utils';
|
|
8
8
|
export { coordToKey, keyToCoord, getCellsInRange, isCellInRange, parseTSV, toTSV, normalizeRange, getFillTargetCells, } from './utils/grid-utils';
|
|
9
|
-
export type { CellCoord, SelectionRange,
|
|
9
|
+
export type { CellCoord, SelectionRange, Header, HeaderGroup, GridStyles, ExcelGridProps, GridCellProps, } from './types';
|
|
10
10
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAGlD,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAG7D,OAAO,EAAE,EAAE,EAAE,MAAM,YAAY,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EACL,UAAU,EACV,UAAU,EACV,eAAe,EACf,aAAa,EACb,QAAQ,EACR,KAAK,EACL,cAAc,EACd,kBAAkB,GACnB,MAAM,oBAAoB,CAAC;AAG5B,YAAY,EACV,SAAS,EACT,cAAc,EACd,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAGlD,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAG7D,OAAO,EAAE,EAAE,EAAE,MAAM,YAAY,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EACL,UAAU,EACV,UAAU,EACV,eAAe,EACf,aAAa,EACb,QAAQ,EACR,KAAK,EACL,cAAc,EACd,kBAAkB,GACnB,MAAM,oBAAoB,CAAC;AAG5B,YAAY,EACV,SAAS,EACT,cAAc,EACd,MAAM,EACN,WAAW,EACX,UAAU,EACV,cAAc,EACd,aAAa,GACd,MAAM,SAAS,CAAC"}
|