react-excel-lite 0.1.0 → 0.3.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 +73 -39
- package/dist/components/excel-grid.d.ts.map +1 -1
- 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 +479 -429
- package/dist/react-excel-lite.umd.cjs +2 -2
- package/dist/types.d.ts +8 -28
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,6 +8,9 @@
|
|
|
8
8
|
|
|
9
9
|
A lightweight, Excel-like editable grid component for React.
|
|
10
10
|
|
|
11
|
+
## Demo
|
|
12
|
+
[react-excel-lite-demo](https://prkgnt.github.io/react-excel-lite/)
|
|
13
|
+
|
|
11
14
|
## Features
|
|
12
15
|
|
|
13
16
|
- Excel-like cell selection (click & drag)
|
|
@@ -16,6 +19,7 @@ A lightweight, Excel-like editable grid component for React.
|
|
|
16
19
|
- Grouped column headers with custom styling
|
|
17
20
|
- Row headers with custom styling
|
|
18
21
|
- Keyboard shortcuts (Delete/Backspace to clear)
|
|
22
|
+
- Expandable input field when editing (text overflow handling)
|
|
19
23
|
- **Styling-agnostic**: Works with Tailwind CSS, CSS Modules, plain CSS, or any styling solution
|
|
20
24
|
- Zero external dependencies
|
|
21
25
|
|
|
@@ -27,7 +31,7 @@ npm install react-excel-lite
|
|
|
27
31
|
|
|
28
32
|
## Quick Start
|
|
29
33
|
|
|
30
|
-
|
|
34
|
+
```tsx
|
|
31
35
|
import { useState } from "react";
|
|
32
36
|
import { ExcelGrid } from "react-excel-lite";
|
|
33
37
|
|
|
@@ -40,6 +44,7 @@ function App() {
|
|
|
40
44
|
|
|
41
45
|
return <ExcelGrid data={data} onChange={setData} />;
|
|
42
46
|
}
|
|
47
|
+
```
|
|
43
48
|
|
|
44
49
|
## Props
|
|
45
50
|
|
|
@@ -47,8 +52,8 @@ function App() {
|
|
|
47
52
|
| ---------------- | ---------------------------- | -------- | --------------------------- |
|
|
48
53
|
| `data` | `string[][]` | Yes | 2D array of strings |
|
|
49
54
|
| `onChange` | `(data: string[][]) => void` | Yes | Callback when data changes |
|
|
50
|
-
| `rowHeaders` | `
|
|
51
|
-
| `colHeaders` | `
|
|
55
|
+
| `rowHeaders` | `HeaderGroup[]` | No | Row header definitions |
|
|
56
|
+
| `colHeaders` | `HeaderGroup[]` | No | Grouped column headers |
|
|
52
57
|
| `className` | `string` | No | CSS class for container |
|
|
53
58
|
| `rowHeaderTitle` | `string` | No | Title for row header column |
|
|
54
59
|
| `styles` | `GridStyles` | No | Style configuration object |
|
|
@@ -58,7 +63,7 @@ function App() {
|
|
|
58
63
|
```tsx
|
|
59
64
|
import { useState } from "react";
|
|
60
65
|
import { ExcelGrid } from "react-excel-lite";
|
|
61
|
-
import type {
|
|
66
|
+
import type { HeaderGroup } from "react-excel-lite";
|
|
62
67
|
|
|
63
68
|
function App() {
|
|
64
69
|
const [data, setData] = useState([
|
|
@@ -66,7 +71,7 @@ function App() {
|
|
|
66
71
|
["500", "600", "700", "800"],
|
|
67
72
|
]);
|
|
68
73
|
|
|
69
|
-
const colHeaders:
|
|
74
|
+
const colHeaders: HeaderGroup[] = [
|
|
70
75
|
{
|
|
71
76
|
label: "Q1",
|
|
72
77
|
headers: [
|
|
@@ -83,9 +88,14 @@ function App() {
|
|
|
83
88
|
},
|
|
84
89
|
];
|
|
85
90
|
|
|
86
|
-
const rowHeaders:
|
|
87
|
-
{
|
|
88
|
-
|
|
91
|
+
const rowHeaders: HeaderGroup[] = [
|
|
92
|
+
{
|
|
93
|
+
label: "Products",
|
|
94
|
+
headers: [
|
|
95
|
+
{ key: "prodA", label: "Product A", description: "Main product line" },
|
|
96
|
+
{ key: "prodB", label: "Product B", description: "Secondary product" },
|
|
97
|
+
],
|
|
98
|
+
},
|
|
89
99
|
];
|
|
90
100
|
|
|
91
101
|
return (
|
|
@@ -98,7 +108,48 @@ function App() {
|
|
|
98
108
|
/>
|
|
99
109
|
);
|
|
100
110
|
}
|
|
101
|
-
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Simple Headers (Without Group Labels)
|
|
114
|
+
|
|
115
|
+
When all HeaderGroups have no `label`, the grid displays a single header row/column instead of two levels:
|
|
116
|
+
|
|
117
|
+
```tsx
|
|
118
|
+
const colHeaders: HeaderGroup[] = [
|
|
119
|
+
{
|
|
120
|
+
// No label - single header row
|
|
121
|
+
headers: [
|
|
122
|
+
{ key: "jan", label: "Jan" },
|
|
123
|
+
{ key: "feb", label: "Feb" },
|
|
124
|
+
],
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
headers: [
|
|
128
|
+
{ key: "mar", label: "Mar" },
|
|
129
|
+
{ key: "apr", label: "Apr" },
|
|
130
|
+
],
|
|
131
|
+
},
|
|
132
|
+
];
|
|
133
|
+
|
|
134
|
+
const rowHeaders: HeaderGroup[] = [
|
|
135
|
+
{
|
|
136
|
+
// No label - single header column
|
|
137
|
+
headers: [
|
|
138
|
+
{ key: "row1", label: "Row 1" },
|
|
139
|
+
{ key: "row2", label: "Row 2" },
|
|
140
|
+
],
|
|
141
|
+
},
|
|
142
|
+
];
|
|
143
|
+
|
|
144
|
+
<ExcelGrid
|
|
145
|
+
data={data}
|
|
146
|
+
onChange={setData}
|
|
147
|
+
colHeaders={colHeaders}
|
|
148
|
+
rowHeaders={rowHeaders}
|
|
149
|
+
/>;
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
If at least one group has a `label`, the grid shows the two-level layout (group labels + individual headers).
|
|
102
153
|
|
|
103
154
|
## Styling
|
|
104
155
|
|
|
@@ -193,7 +244,7 @@ interface GridStyles {
|
|
|
193
244
|
Style individual column headers and groups:
|
|
194
245
|
|
|
195
246
|
```tsx
|
|
196
|
-
const colHeaders:
|
|
247
|
+
const colHeaders: HeaderGroup[] = [
|
|
197
248
|
{
|
|
198
249
|
label: "Revenue",
|
|
199
250
|
className: "bg-green-100 text-green-700",
|
|
@@ -208,11 +259,13 @@ const colHeaders: ColHeaderGroup[] = [
|
|
|
208
259
|
Style individual row headers:
|
|
209
260
|
|
|
210
261
|
```tsx
|
|
211
|
-
const rowHeaders:
|
|
262
|
+
const rowHeaders: HeaderGroup[] = [
|
|
212
263
|
{
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
264
|
+
label: "Regions",
|
|
265
|
+
headers: [
|
|
266
|
+
{ key: "regionA", label: "Region A", className: "bg-slate-700 text-white" },
|
|
267
|
+
{ key: "regionB", label: "Region B", className: "bg-slate-600 text-white" },
|
|
268
|
+
],
|
|
216
269
|
},
|
|
217
270
|
];
|
|
218
271
|
```
|
|
@@ -272,22 +325,16 @@ interface SelectionRange {
|
|
|
272
325
|
end: CellCoord | null;
|
|
273
326
|
}
|
|
274
327
|
|
|
275
|
-
interface
|
|
328
|
+
interface Header {
|
|
276
329
|
key: string;
|
|
277
330
|
label: string;
|
|
278
331
|
description?: string;
|
|
279
332
|
className?: string;
|
|
280
333
|
}
|
|
281
334
|
|
|
282
|
-
interface
|
|
283
|
-
label
|
|
284
|
-
headers:
|
|
285
|
-
className?: string;
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
interface RowHeaderGroup {
|
|
289
|
-
key: string;
|
|
290
|
-
label: string;
|
|
335
|
+
interface HeaderGroup {
|
|
336
|
+
label?: string;
|
|
337
|
+
headers: Header[];
|
|
291
338
|
description?: string;
|
|
292
339
|
className?: string;
|
|
293
340
|
}
|
|
@@ -305,27 +352,14 @@ interface GridStyles {
|
|
|
305
352
|
interface ExcelGridProps {
|
|
306
353
|
data: string[][];
|
|
307
354
|
onChange: (data: string[][]) => void;
|
|
308
|
-
rowHeaders?:
|
|
309
|
-
colHeaders?:
|
|
355
|
+
rowHeaders?: HeaderGroup[];
|
|
356
|
+
colHeaders?: HeaderGroup[];
|
|
310
357
|
className?: string;
|
|
311
358
|
rowHeaderTitle?: string;
|
|
312
359
|
styles?: GridStyles;
|
|
313
360
|
}
|
|
314
361
|
```
|
|
315
362
|
|
|
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
363
|
## License
|
|
330
364
|
|
|
331
365
|
MIT License © 2025 prkgnt
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"excel-grid.d.ts","sourceRoot":"","sources":["../../src/components/excel-grid.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAa,MAAM,UAAU,CAAC;AAsE1D,wBAAgB,SAAS,CAAC,EACxB,IAAI,EACJ,QAAQ,EACR,UAAU,EACV,UAAU,EACV,SAAS,EACT,cAAmB,EACnB,MAAM,GACP,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"excel-grid.d.ts","sourceRoot":"","sources":["../../src/components/excel-grid.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAa,MAAM,UAAU,CAAC;AAsE1D,wBAAgB,SAAS,CAAC,EACxB,IAAI,EACJ,QAAQ,EACR,UAAU,EACV,UAAU,EACV,SAAS,EACT,cAAmB,EACnB,MAAM,GACP,EAAE,cAAc,2CAiThB"}
|
|
@@ -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"}
|