@importcsv/react 0.4.8 → 0.6.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 +24 -45
- package/build/react/index.d.ts +29 -3
- package/build/react/index.esm.js +1897 -1876
- package/build/react/index.esm.js.map +1 -1
- package/build/react/index.js +14 -14
- package/build/react/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -12,21 +12,14 @@
|
|
|
12
12
|
|
|
13
13
|
</div>
|
|
14
14
|
|
|
15
|
-
##
|
|
16
|
-
|
|
17
|
-
- **Column mapping** - Auto-matches columns, users fix the rest
|
|
18
|
-
- **Validation** - Required, unique, email, regex, custom
|
|
19
|
-
- **Large files** - Virtual scrolling handles 10k+ rows
|
|
20
|
-
- **~125KB gzipped**
|
|
21
|
-
|
|
22
|
-
Optional with backend: AI column matching, AI error fixing, natural language transforms.
|
|
23
|
-
|
|
24
|
-
## Quick Start
|
|
15
|
+
## Install
|
|
25
16
|
|
|
26
17
|
```bash
|
|
27
|
-
npm install @importcsv/react
|
|
18
|
+
npm install @importcsv/react zod
|
|
28
19
|
```
|
|
29
20
|
|
|
21
|
+
## Quick Start
|
|
22
|
+
|
|
30
23
|
```tsx
|
|
31
24
|
import { useState } from 'react';
|
|
32
25
|
import { CSVImporter } from '@importcsv/react';
|
|
@@ -48,54 +41,40 @@ function App() {
|
|
|
48
41
|
schema={schema}
|
|
49
42
|
modalIsOpen={isOpen}
|
|
50
43
|
modalOnCloseTriggered={() => setIsOpen(false)}
|
|
51
|
-
onComplete={(
|
|
44
|
+
onComplete={(result) => console.log(result.rows)}
|
|
52
45
|
/>
|
|
53
46
|
</>
|
|
54
47
|
);
|
|
55
48
|
}
|
|
56
49
|
```
|
|
57
50
|
|
|
58
|
-
Zod handles validation automatically. No need to define validators separately.
|
|
59
|
-
|
|
60
51
|
## Features
|
|
61
52
|
|
|
62
|
-
**
|
|
63
|
-
-
|
|
64
|
-
-
|
|
65
|
-
-
|
|
53
|
+
- **Column mapping** — Auto-matches headers to your schema
|
|
54
|
+
- **Zod validation** — Type-safe with automatic error messages
|
|
55
|
+
- **Large files** — Virtual scrolling handles 100k+ rows
|
|
56
|
+
- **~100KB gzipped** — Styles included
|
|
66
57
|
|
|
67
|
-
**
|
|
68
|
-
- Required, unique, min/max, regex
|
|
69
|
-
- Email, phone, date formats
|
|
70
|
-
- Custom validators
|
|
58
|
+
**File formats:** CSV, TSV, XLS, XLSX (Excel requires `npm install xlsx`)
|
|
71
59
|
|
|
72
|
-
**
|
|
73
|
-
- trim, uppercase, lowercase, capitalize
|
|
74
|
-
- normalize_phone, normalize_date
|
|
75
|
-
- Custom functions
|
|
60
|
+
**Frameworks:** React 16–19, Preact, Next.js
|
|
76
61
|
|
|
77
|
-
|
|
78
|
-
- React 16–19
|
|
79
|
-
- Preact
|
|
80
|
-
- Next.js (App & Pages Router)
|
|
62
|
+
## Theming
|
|
81
63
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
- Dark mode support
|
|
64
|
+
```tsx
|
|
65
|
+
<CSVImporter theme="dark" primaryColor="#10b981" />
|
|
66
|
+
```
|
|
86
67
|
|
|
87
|
-
|
|
68
|
+
Presets: `default`, `minimal`, `modern`, `compact`, `dark`, `corporate`, `playful`
|
|
88
69
|
|
|
89
|
-
|
|
70
|
+
## Next.js / Preact
|
|
90
71
|
|
|
91
72
|
```tsx
|
|
73
|
+
// Next.js App Router
|
|
92
74
|
'use client';
|
|
93
75
|
import { CSVImporter } from '@importcsv/react';
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
### Preact
|
|
97
76
|
|
|
98
|
-
|
|
77
|
+
// Preact
|
|
99
78
|
import { CSVImporter } from '@importcsv/react/preact';
|
|
100
79
|
```
|
|
101
80
|
|
|
@@ -103,15 +82,15 @@ import { CSVImporter } from '@importcsv/react/preact';
|
|
|
103
82
|
|
|
104
83
|
With the [ImportCSV backend](https://github.com/importcsv/importcsv/tree/main/backend):
|
|
105
84
|
|
|
106
|
-
-
|
|
107
|
-
-
|
|
108
|
-
-
|
|
85
|
+
- AI column matching
|
|
86
|
+
- AI error fixing
|
|
87
|
+
- Natural language transforms
|
|
109
88
|
|
|
110
|
-
##
|
|
89
|
+
## Links
|
|
111
90
|
|
|
112
91
|
- [Documentation](https://docs.importcsv.com)
|
|
113
|
-
- [Issues](https://github.com/importcsv/importcsv/issues)
|
|
114
92
|
- [GitHub](https://github.com/importcsv/importcsv)
|
|
93
|
+
- [Issues](https://github.com/importcsv/importcsv/issues)
|
|
115
94
|
|
|
116
95
|
## License
|
|
117
96
|
|
package/build/react/index.d.ts
CHANGED
|
@@ -100,13 +100,39 @@ export interface ThemeConfig {
|
|
|
100
100
|
};
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
+
/**
|
|
104
|
+
* Result structure returned by onComplete callback.
|
|
105
|
+
* Contains imported rows with their data and column metadata.
|
|
106
|
+
*/
|
|
107
|
+
export interface ImportResult<T = Record<string, unknown>> {
|
|
108
|
+
rows: (T & {
|
|
109
|
+
/** Values from dynamicColumns, keyed by column id */
|
|
110
|
+
_custom_fields?: Record<string, unknown>;
|
|
111
|
+
/** Values from unmapped CSV columns (when includeUnmatchedColumns is true) */
|
|
112
|
+
_unmatched?: Record<string, unknown>;
|
|
113
|
+
})[];
|
|
114
|
+
columns: {
|
|
115
|
+
/** Columns from the columns prop */
|
|
116
|
+
predefined: Column[];
|
|
117
|
+
/** Columns from the dynamicColumns prop */
|
|
118
|
+
dynamic: Column[];
|
|
119
|
+
/** CSV column names that were not mapped to any column */
|
|
120
|
+
unmatched: string[];
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
103
124
|
export interface CSVImporterProps {
|
|
104
125
|
columns?: Column[];
|
|
126
|
+
/**
|
|
127
|
+
* Customer-specific dynamic columns passed at runtime.
|
|
128
|
+
* These appear after predefined columns in the mapping dropdown.
|
|
129
|
+
* Output is nested under _custom_fields in each row.
|
|
130
|
+
*/
|
|
131
|
+
dynamicColumns?: Column[];
|
|
105
132
|
importerKey?: string;
|
|
106
|
-
onComplete?: (data:
|
|
133
|
+
onComplete?: (data: ImportResult) => void;
|
|
107
134
|
backendUrl?: string;
|
|
108
|
-
|
|
109
|
-
metadata?: Record<string, any>;
|
|
135
|
+
context?: Record<string, any>;
|
|
110
136
|
theme?: ThemeConfig | 'default' | 'minimal' | 'modern' | 'compact' | 'dark';
|
|
111
137
|
darkMode?: boolean;
|
|
112
138
|
primaryColor?: string;
|