@papernote/ui 1.3.0 → 1.3.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.
- package/dist/components/Spreadsheet.d.ts +5 -1
- package/dist/components/Spreadsheet.d.ts.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.esm.js +44 -8426
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +44 -8426
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/components/Spreadsheet.tsx +8 -57
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@papernote/ui",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A modern React component library with a paper notebook aesthetic - minimal, professional, and expressive",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -40,9 +40,9 @@
|
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"lucide-react": "^0.553.0",
|
|
43
|
-
"react": "^
|
|
44
|
-
"react-dom": "^
|
|
45
|
-
"react-router-dom": "^
|
|
43
|
+
"react": "^19.0.0",
|
|
44
|
+
"react-dom": "^19.0.0",
|
|
45
|
+
"react-router-dom": "^7.0.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@rollup/plugin-commonjs": "^25.0.0",
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import React, { useState, useCallback } from 'react';
|
|
2
2
|
import BaseSpreadsheet, { CellBase, Matrix } from 'react-spreadsheet';
|
|
3
|
-
import {
|
|
3
|
+
import { utils, writeFile } from 'xlsx';
|
|
4
4
|
import Button from './Button';
|
|
5
5
|
import Card, { CardHeader, CardTitle, CardContent } from './Card';
|
|
6
6
|
import Stack from './Stack';
|
|
7
|
-
import { Download,
|
|
7
|
+
import { Download, Save } from 'lucide-react';
|
|
8
8
|
import { addSuccessMessage, addErrorMessage } from './StatusBar';
|
|
9
9
|
import './Spreadsheet.css';
|
|
10
10
|
|
|
@@ -39,7 +39,11 @@ export interface SpreadsheetProps {
|
|
|
39
39
|
rowLabels?: string[];
|
|
40
40
|
/** Show toolbar with actions */
|
|
41
41
|
showToolbar?: boolean;
|
|
42
|
-
/**
|
|
42
|
+
/**
|
|
43
|
+
* Enable Excel import
|
|
44
|
+
* @deprecated Excel import has been disabled due to security vulnerabilities in the xlsx library.
|
|
45
|
+
* This prop is kept for API compatibility but has no effect.
|
|
46
|
+
*/
|
|
43
47
|
enableImport?: boolean;
|
|
44
48
|
/** Enable Excel export */
|
|
45
49
|
enableExport?: boolean;
|
|
@@ -123,7 +127,7 @@ export const Spreadsheet: React.FC<SpreadsheetProps> = ({
|
|
|
123
127
|
columnLabels,
|
|
124
128
|
rowLabels,
|
|
125
129
|
showToolbar = false,
|
|
126
|
-
enableImport = false,
|
|
130
|
+
enableImport: _enableImport = false, // Deprecated - kept for API compatibility
|
|
127
131
|
enableExport = false,
|
|
128
132
|
enableSave = false,
|
|
129
133
|
onSave,
|
|
@@ -153,44 +157,6 @@ export const Spreadsheet: React.FC<SpreadsheetProps> = ({
|
|
|
153
157
|
[onChange]
|
|
154
158
|
);
|
|
155
159
|
|
|
156
|
-
// Handle Excel import
|
|
157
|
-
const handleImport = useCallback(
|
|
158
|
-
(event: React.ChangeEvent<HTMLInputElement>) => {
|
|
159
|
-
const file = event.target.files?.[0];
|
|
160
|
-
if (!file) return;
|
|
161
|
-
|
|
162
|
-
const reader = new FileReader();
|
|
163
|
-
reader.onload = (e) => {
|
|
164
|
-
try {
|
|
165
|
-
const workbook: WorkBook = read(e.target?.result, { type: 'binary' });
|
|
166
|
-
const sheetName = workbook.SheetNames[0];
|
|
167
|
-
const worksheet = workbook.Sheets[sheetName];
|
|
168
|
-
|
|
169
|
-
// Convert to array of arrays
|
|
170
|
-
const jsonData: any[][] = utils.sheet_to_json(worksheet, { header: 1 });
|
|
171
|
-
|
|
172
|
-
// Convert to spreadsheet format
|
|
173
|
-
const spreadsheetData: Matrix<SpreadsheetCell> = jsonData.map(row =>
|
|
174
|
-
row.map(cell => ({
|
|
175
|
-
value: cell,
|
|
176
|
-
}))
|
|
177
|
-
);
|
|
178
|
-
|
|
179
|
-
handleChange(spreadsheetData);
|
|
180
|
-
addSuccessMessage('Excel file imported successfully');
|
|
181
|
-
} catch (error) {
|
|
182
|
-
console.error('Error importing Excel file:', error);
|
|
183
|
-
addErrorMessage('Failed to import Excel file');
|
|
184
|
-
}
|
|
185
|
-
};
|
|
186
|
-
reader.readAsBinaryString(file);
|
|
187
|
-
|
|
188
|
-
// Reset input
|
|
189
|
-
event.target.value = '';
|
|
190
|
-
},
|
|
191
|
-
[handleChange]
|
|
192
|
-
);
|
|
193
|
-
|
|
194
160
|
// Handle Excel export
|
|
195
161
|
const handleExport = useCallback(() => {
|
|
196
162
|
try {
|
|
@@ -238,20 +204,6 @@ export const Spreadsheet: React.FC<SpreadsheetProps> = ({
|
|
|
238
204
|
<Stack direction="horizontal" spacing="md" align="center" className="mb-4">
|
|
239
205
|
{title && <div className="text-lg font-medium text-ink-900 flex-1">{title}</div>}
|
|
240
206
|
|
|
241
|
-
{enableImport && (
|
|
242
|
-
<label>
|
|
243
|
-
<input
|
|
244
|
-
type="file"
|
|
245
|
-
accept=".xlsx,.xls,.csv"
|
|
246
|
-
onChange={handleImport}
|
|
247
|
-
className="hidden"
|
|
248
|
-
/>
|
|
249
|
-
<Button variant="ghost" size="sm" icon={<Upload className="h-4 w-4" />}>
|
|
250
|
-
Import
|
|
251
|
-
</Button>
|
|
252
|
-
</label>
|
|
253
|
-
)}
|
|
254
|
-
|
|
255
207
|
{enableExport && (
|
|
256
208
|
<Button
|
|
257
209
|
variant="ghost"
|
|
@@ -342,7 +294,6 @@ export const SpreadsheetReport: React.FC<
|
|
|
342
294
|
<Spreadsheet
|
|
343
295
|
{...props}
|
|
344
296
|
showToolbar
|
|
345
|
-
enableImport
|
|
346
297
|
enableExport
|
|
347
298
|
enableSave
|
|
348
299
|
wrapInCard
|