react-excel-lite 0.0.7 → 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 +35 -28
- package/dist/components/excel-grid.d.ts.map +1 -1
- package/dist/components/grid-cell.d.ts.map +1 -1
- package/dist/hooks/use-grid-clipboard.d.ts +2 -1
- package/dist/hooks/use-grid-clipboard.d.ts.map +1 -1
- package/dist/hooks/use-grid-selection.d.ts +5 -1
- package/dist/hooks/use-grid-selection.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 +573 -431
- package/dist/react-excel-lite.umd.cjs +2 -2
- package/dist/types.d.ts +9 -18
- 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
|
|
|
@@ -48,8 +49,8 @@ function App() {
|
|
|
48
49
|
| ---------------- | ---------------------------- | -------- | --------------------------- |
|
|
49
50
|
| `data` | `string[][]` | Yes | 2D array of strings |
|
|
50
51
|
| `onChange` | `(data: string[][]) => void` | Yes | Callback when data changes |
|
|
51
|
-
| `rowHeaders` | `
|
|
52
|
-
| `colHeaders` | `
|
|
52
|
+
| `rowHeaders` | `HeaderGroup[]` | No | Row header definitions |
|
|
53
|
+
| `colHeaders` | `HeaderGroup[]` | No | Grouped column headers |
|
|
53
54
|
| `className` | `string` | No | CSS class for container |
|
|
54
55
|
| `rowHeaderTitle` | `string` | No | Title for row header column |
|
|
55
56
|
| `styles` | `GridStyles` | No | Style configuration object |
|
|
@@ -59,7 +60,7 @@ function App() {
|
|
|
59
60
|
```tsx
|
|
60
61
|
import { useState } from "react";
|
|
61
62
|
import { ExcelGrid } from "react-excel-lite";
|
|
62
|
-
import type {
|
|
63
|
+
import type { HeaderGroup } from "react-excel-lite";
|
|
63
64
|
|
|
64
65
|
function App() {
|
|
65
66
|
const [data, setData] = useState([
|
|
@@ -67,7 +68,7 @@ function App() {
|
|
|
67
68
|
["500", "600", "700", "800"],
|
|
68
69
|
]);
|
|
69
70
|
|
|
70
|
-
const colHeaders:
|
|
71
|
+
const colHeaders: HeaderGroup[] = [
|
|
71
72
|
{
|
|
72
73
|
label: "Q1",
|
|
73
74
|
headers: [
|
|
@@ -84,9 +85,14 @@ function App() {
|
|
|
84
85
|
},
|
|
85
86
|
];
|
|
86
87
|
|
|
87
|
-
const rowHeaders:
|
|
88
|
-
{
|
|
89
|
-
|
|
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
|
+
},
|
|
90
96
|
];
|
|
91
97
|
|
|
92
98
|
return (
|
|
@@ -108,6 +114,7 @@ The component comes with sensible default styles built-in. You can customize sty
|
|
|
108
114
|
### Default Styles
|
|
109
115
|
|
|
110
116
|
Out of the box, the grid has:
|
|
117
|
+
|
|
111
118
|
- Light gray borders and headers
|
|
112
119
|
- Blue selection highlight
|
|
113
120
|
- Blue fill handle
|
|
@@ -178,13 +185,13 @@ const styles: GridStyles = {
|
|
|
178
185
|
|
|
179
186
|
```ts
|
|
180
187
|
interface GridStyles {
|
|
181
|
-
cell?: string;
|
|
182
|
-
selected?: string;
|
|
188
|
+
cell?: string; // CSS class for data cells
|
|
189
|
+
selected?: string; // CSS class for selected cells (overrides default)
|
|
183
190
|
fillTarget?: string; // CSS class for fill target cells (overrides default)
|
|
184
191
|
fillHandle?: string; // CSS class for fill handle (overrides default)
|
|
185
|
-
colGroup?: string;
|
|
186
|
-
colHeader?: string;
|
|
187
|
-
rowHeader?: string;
|
|
192
|
+
colGroup?: string; // CSS class for column group headers
|
|
193
|
+
colHeader?: string; // CSS class for individual column headers
|
|
194
|
+
rowHeader?: string; // CSS class for row headers
|
|
188
195
|
}
|
|
189
196
|
```
|
|
190
197
|
|
|
@@ -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,10 +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
|
```
|
|
318
|
+
|
|
319
|
+
## License
|
|
320
|
+
|
|
321
|
+
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;
|
|
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,2CAoShB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grid-cell.d.ts","sourceRoot":"","sources":["../../src/components/grid-cell.tsx"],"names":[],"mappings":"
|
|
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"}
|
|
@@ -6,6 +6,7 @@ interface UseGridClipboardProps {
|
|
|
6
6
|
coord: CellCoord;
|
|
7
7
|
value: string;
|
|
8
8
|
}[]) => void;
|
|
9
|
+
setSelection: (range: SelectionRange) => void;
|
|
9
10
|
rowCount: number;
|
|
10
11
|
colCount: number;
|
|
11
12
|
}
|
|
@@ -14,6 +15,6 @@ interface UseGridClipboardReturn {
|
|
|
14
15
|
handlePaste: () => Promise<void>;
|
|
15
16
|
handleKeyDown: (e: React.KeyboardEvent) => void;
|
|
16
17
|
}
|
|
17
|
-
export declare function useGridClipboard({ selection, getValue, setValues, rowCount, colCount, }: UseGridClipboardProps): UseGridClipboardReturn;
|
|
18
|
+
export declare function useGridClipboard({ selection, getValue, setValues, setSelection, rowCount, colCount, }: UseGridClipboardProps): UseGridClipboardReturn;
|
|
18
19
|
export {};
|
|
19
20
|
//# sourceMappingURL=use-grid-clipboard.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-grid-clipboard.d.ts","sourceRoot":"","sources":["../../src/hooks/use-grid-clipboard.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAG1D,UAAU,qBAAqB;IAC7B,SAAS,EAAE,cAAc,CAAC;IAC1B,QAAQ,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,MAAM,CAAC;IACvC,SAAS,EAAE,CAAC,OAAO,EAAE;QAAE,KAAK,EAAE,SAAS,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,KAAK,IAAI,CAAC;IACpE,QAAQ,EAAE,MAAM,CAAC;IACjB,QA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,CA2JhD"}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
1
2
|
import { CellCoord, SelectionRange } from '../types';
|
|
3
|
+
interface UseGridSelectionProps {
|
|
4
|
+
containerRef: RefObject<HTMLDivElement | null>;
|
|
5
|
+
}
|
|
2
6
|
interface UseGridSelectionReturn {
|
|
3
7
|
selection: SelectionRange;
|
|
4
8
|
isSelecting: boolean;
|
|
@@ -9,6 +13,6 @@ interface UseGridSelectionReturn {
|
|
|
9
13
|
clearSelection: () => void;
|
|
10
14
|
setSelection: (range: SelectionRange) => void;
|
|
11
15
|
}
|
|
12
|
-
export declare function useGridSelection(): UseGridSelectionReturn;
|
|
16
|
+
export declare function useGridSelection({ containerRef, }: UseGridSelectionProps): UseGridSelectionReturn;
|
|
13
17
|
export {};
|
|
14
18
|
//# sourceMappingURL=use-grid-selection.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-grid-selection.d.ts","sourceRoot":"","sources":["../../src/hooks/use-grid-selection.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-grid-selection.d.ts","sourceRoot":"","sources":["../../src/hooks/use-grid-selection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AACzE,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAG1D,UAAU,qBAAqB;IAC7B,YAAY,EAAE,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;CAChD;AAED,UAAU,sBAAsB;IAC9B,SAAS,EAAE,cAAc,CAAC;IAC1B,WAAW,EAAE,OAAO,CAAC;IACrB,cAAc,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,OAAO,CAAC;IAC9C,mBAAmB,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,CAAC;IAChD,oBAAoB,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,CAAC;IACjD,aAAa,EAAE,MAAM,IAAI,CAAC;IAC1B,cAAc,EAAE,MAAM,IAAI,CAAC;IAC3B,YAAY,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;CAC/C;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,YAAY,GACb,EAAE,qBAAqB,GAAG,sBAAsB,CA6EhD"}
|
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,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