@importcsv/react 0.4.6 → 0.4.7
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 +47 -84
- package/build/preact/index.esm.js +2180 -2259
- package/build/preact/index.esm.js.map +1 -1
- package/build/preact/index.js +16 -117
- package/build/preact/index.js.map +1 -1
- package/build/react/index.esm.js +2274 -2307
- package/build/react/index.esm.js.map +1 -1
- package/build/react/index.js +16 -117
- package/build/react/index.js.map +1 -1
- package/package.json +11 -10
- package/build/App.d.ts +0 -2
- package/build/bundled/index.esm.js +0 -11531
- package/build/bundled/index.esm.js.map +0 -1
- package/build/bundled/index.js +0 -139
- package/build/bundled/index.js.map +0 -1
- package/build/bundled/index.umd.js +0 -139
- package/build/bundled/index.umd.js.map +0 -1
- package/build/bundled-styles.d.ts +0 -1
- package/build/components/CSVImporter/index.d.ts +0 -55
- package/build/components/CSVImporter/index.test.d.ts +0 -1
- package/build/components/CSVImporterHeadless.d.ts +0 -46
- package/build/components/ColumnMapper.d.ts +0 -28
- package/build/components/Modal/index.d.ts +0 -12
- package/build/components/Uploader.d.ts +0 -27
- package/build/components/Validator.d.ts +0 -28
- package/build/components/__tests__/CSVImporterHeadless.test.d.ts +0 -1
- package/build/components/__tests__/ColumnMapper.test.d.ts +0 -1
- package/build/components/__tests__/Uploader.test.d.ts +0 -1
- package/build/components/__tests__/Validator.test.d.ts +0 -1
- package/build/components/index.d.ts +0 -3
- package/build/config/index.d.ts +0 -5
- package/build/headless/__tests__/integration.test.d.ts +0 -10
- package/build/headless/__tests__/root.test.d.ts +0 -1
- package/build/headless/__tests__/root.types.test-d.d.ts +0 -1
- package/build/headless/__tests__/slot-components.test.d.ts +0 -1
- package/build/headless/__tests__/validator.test.d.ts +0 -1
- package/build/headless/back-button.d.ts +0 -29
- package/build/headless/index.d.ts +0 -45
- package/build/headless/next-button.d.ts +0 -29
- package/build/headless/root.d.ts +0 -40
- package/build/headless/submit-button.d.ts +0 -29
- package/build/headless/types.d.ts +0 -52
- package/build/headless/upload-trigger.d.ts +0 -29
- package/build/headless/utils/slot.d.ts +0 -20
- package/build/headless/utils/zodSchemaToColumns.d.ts +0 -25
- package/build/headless/utils/zodSchemaToColumns.test.d.ts +0 -1
- package/build/headless/validator.d.ts +0 -28
- package/build/i18n/de.d.ts +0 -32
- package/build/i18n/es.d.ts +0 -32
- package/build/i18n/fr.d.ts +0 -32
- package/build/i18n/i18n.d.ts +0 -6
- package/build/i18n/it.d.ts +0 -32
- package/build/i18n/useTranslation.d.ts +0 -9
- package/build/importer/components/Box/index.d.ts +0 -2
- package/build/importer/components/Box/index.test.d.ts +0 -1
- package/build/importer/components/Box/types/index.d.ts +0 -6
- package/build/importer/components/Checkbox/index.d.ts +0 -3
- package/build/importer/components/Checkbox/index.test.d.ts +0 -1
- package/build/importer/components/Checkbox/types/index.d.ts +0 -8
- package/build/importer/components/Errors/index.d.ts +0 -4
- package/build/importer/components/Input/index.d.ts +0 -2
- package/build/importer/components/Input/index.test.d.ts +0 -1
- package/build/importer/components/Input/types/index.d.ts +0 -24
- package/build/importer/components/Root/index.d.ts +0 -2
- package/build/importer/components/StepLayout/index.d.ts +0 -19
- package/build/importer/components/Stepper/hooks/useStepper.d.ts +0 -4
- package/build/importer/components/Stepper/hooks/useStepper.test.d.ts +0 -1
- package/build/importer/components/Stepper/index.d.ts +0 -2
- package/build/importer/components/Stepper/index.test.d.ts +0 -1
- package/build/importer/components/Stepper/types/index.d.ts +0 -14
- package/build/importer/components/Table/index.d.ts +0 -9
- package/build/importer/components/Table/types/index.d.ts +0 -43
- package/build/importer/components/ToggleFilter/index.d.ts +0 -3
- package/build/importer/components/ToggleFilter/types/index.d.ts +0 -11
- package/build/importer/components/Tooltip/index.d.ts +0 -2
- package/build/importer/components/Tooltip/types/index.d.ts +0 -11
- package/build/importer/components/UploaderWrapper/NativeDropzone.d.ts +0 -12
- package/build/importer/components/UploaderWrapper/UploaderWrapper.d.ts +0 -2
- package/build/importer/components/UploaderWrapper/types/index.d.ts +0 -2
- package/build/importer/components/VirtualTable/index.d.ts +0 -17
- package/build/importer/components/VirtualTable/index.test.d.ts +0 -1
- package/build/importer/components/ui/alert.d.ts +0 -15
- package/build/importer/components/ui/button.d.ts +0 -15
- package/build/importer/components/ui/card.d.ts +0 -20
- package/build/importer/components/ui/checkbox.d.ts +0 -10
- package/build/importer/components/ui/dialog.d.ts +0 -39
- package/build/importer/components/ui/flex.d.ts +0 -24
- package/build/importer/components/ui/input.d.ts +0 -8
- package/build/importer/components/ui/select.d.ts +0 -17
- package/build/importer/components/ui/switch.d.ts +0 -11
- package/build/importer/components/ui/toast.d.ts +0 -22
- package/build/importer/components/ui/toaster.d.ts +0 -2
- package/build/importer/components/ui/tooltip.d.ts +0 -25
- package/build/importer/components/ui/use-toast.d.ts +0 -46
- package/build/importer/features/complete/index.d.ts +0 -2
- package/build/importer/features/complete/types/index.d.ts +0 -5
- package/build/importer/features/configure-import/index.d.ts +0 -14
- package/build/importer/features/configure-import/types/index.d.ts +0 -13
- package/build/importer/features/main/hooks/useMutableLocalStorage.d.ts +0 -1
- package/build/importer/features/main/hooks/useMutableLocalStorage.test.d.ts +0 -1
- package/build/importer/features/main/hooks/useStepNavigation.d.ts +0 -17
- package/build/importer/features/main/hooks/useStepNavigation.test.d.ts +0 -1
- package/build/importer/features/main/index.d.ts +0 -2
- package/build/importer/features/main/types/index.d.ts +0 -16
- package/build/importer/features/map-columns/components/DropDownFields.d.ts +0 -22
- package/build/importer/features/map-columns/hooks/useMapColumnsTable.d.ts +0 -17
- package/build/importer/features/map-columns/index.d.ts +0 -3
- package/build/importer/features/map-columns/types/index.d.ts +0 -16
- package/build/importer/features/row-selection/index.d.ts +0 -3
- package/build/importer/features/row-selection/types/index.d.ts +0 -8
- package/build/importer/features/uploader/hooks/useTemplateTable.d.ts +0 -10
- package/build/importer/features/uploader/index.d.ts +0 -2
- package/build/importer/features/uploader/types/index.d.ts +0 -9
- package/build/importer/features/validation/Validation.d.ts +0 -3
- package/build/importer/features/validation/__tests__/Validation.zod.test.d.ts +0 -1
- package/build/importer/features/validation/components/TransformModal.d.ts +0 -19
- package/build/importer/features/validation/components/TransformPanel.d.ts +0 -19
- package/build/importer/features/validation/index.d.ts +0 -1
- package/build/importer/features/validation/types.d.ts +0 -34
- package/build/importer/hooks/useClickOutside.d.ts +0 -1
- package/build/importer/hooks/useClickOutside.test.d.ts +0 -1
- package/build/importer/hooks/useCustomStyles.d.ts +0 -1
- package/build/importer/hooks/useCustomStyles.test.d.ts +0 -1
- package/build/importer/hooks/useEventListener.d.ts +0 -4
- package/build/importer/hooks/useEventListener.test.d.ts +0 -1
- package/build/importer/hooks/useIsomorphicLayoutEffect.d.ts +0 -3
- package/build/importer/hooks/useIsomorphicLayoutEffect.test.d.ts +0 -1
- package/build/importer/hooks/useRect.d.ts +0 -12
- package/build/importer/hooks/useRect.test.d.ts +0 -1
- package/build/importer/hooks/useWindowSize.d.ts +0 -1
- package/build/importer/hooks/useWindowSize.test.d.ts +0 -1
- package/build/importer/providers/Theme.d.ts +0 -10
- package/build/importer/providers/index.d.ts +0 -5
- package/build/importer/providers/types/index.d.ts +0 -10
- package/build/importer/services/api.d.ts +0 -1
- package/build/importer/services/mapping.d.ts +0 -31
- package/build/importer/services/mapping.test.d.ts +0 -1
- package/build/importer/services/transformation.d.ts +0 -70
- package/build/importer/services/transformation.test.d.ts +0 -1
- package/build/importer/settings/theme/colors.d.ts +0 -4
- package/build/importer/settings/theme/index.d.ts +0 -2
- package/build/importer/settings/theme/sizes.d.ts +0 -7
- package/build/importer/stores/theme.d.ts +0 -17
- package/build/importer/theme/index.d.ts +0 -8
- package/build/importer/theme/presets.d.ts +0 -314
- package/build/importer/theme/runtime.d.ts +0 -66
- package/build/importer/theme/styles.d.ts +0 -120
- package/build/importer/types/index.d.ts +0 -9
- package/build/importer/utils/colorUtils.d.ts +0 -48
- package/build/importer/utils/colorUtils.test.d.ts +0 -1
- package/build/importer/utils/errorAnalysis.d.ts +0 -25
- package/build/importer/utils/errorAnalysis.test.d.ts +0 -1
- package/build/importer/utils/getStringLengthOfChildren.d.ts +0 -2
- package/build/importer/utils/getStringLengthOfChildren.test.d.ts +0 -1
- package/build/importer/utils/stringSimilarity.d.ts +0 -1
- package/build/importer/utils/stringSimilarity.test.d.ts +0 -1
- package/build/importer/utils/template.d.ts +0 -2
- package/build/importer/utils/template.test.d.ts +0 -1
- package/build/importer/utils/themeUtils.d.ts +0 -24
- package/build/importer/utils/themeUtils.test.d.ts +0 -1
- package/build/importer/utils/utils.d.ts +0 -19
- package/build/importer/utils/utils.test.d.ts +0 -1
- package/build/index.d.ts +0 -10
- package/build/index.dev.d.ts +0 -1
- package/build/js.d.ts +0 -57
- package/build/services/api.d.ts +0 -50
- package/build/services/apiClient.d.ts +0 -55
- package/build/settings/defaults.d.ts +0 -3
- package/build/shims/react-compat-shim.d.ts +0 -43
- package/build/shims/react-hooks-shim.d.ts +0 -2
- package/build/styles.d.ts +0 -1
- package/build/test/helpers.d.ts +0 -28
- package/build/test/mocks/api.d.ts +0 -8
- package/build/test/mocks/localStorage.d.ts +0 -6
- package/build/test/setup.d.ts +0 -1
- package/build/types/index.d.ts +0 -137
- package/build/types/theme.d.ts +0 -153
- package/build/utils/cn.d.ts +0 -6
- package/build/utils/cn.test.d.ts +0 -1
- package/build/validation/transformationStages.d.ts +0 -26
- package/build/validation/transformer.d.ts +0 -17
- package/build/validation/validator.d.ts +0 -23
package/README.md
CHANGED
|
@@ -2,28 +2,24 @@
|
|
|
2
2
|
|
|
3
3
|
# @importcsv/react
|
|
4
4
|
|
|
5
|
-
**
|
|
5
|
+
**CSV imports for React**
|
|
6
6
|
|
|
7
|
-
[](https://github.com/importcsv/importcsv/actions/workflows/frontend-tests.yml)
|
|
8
|
-
[](https://codecov.io/gh/importcsv/importcsv)
|
|
9
7
|
[](https://www.npmjs.com/package/@importcsv/react)
|
|
10
|
-
[](https://www.npmjs.com/package/@importcsv/react)
|
|
11
8
|
[](https://bundlephobia.com/package/@importcsv/react)
|
|
12
9
|
[](./LICENSE)
|
|
13
10
|
|
|
14
|
-
[
|
|
11
|
+
[Demo](https://demo.importcsv.com) • [Docs](https://docs.importcsv.com)
|
|
15
12
|
|
|
16
13
|
</div>
|
|
17
14
|
|
|
18
|
-
##
|
|
15
|
+
## What it does
|
|
19
16
|
|
|
20
|
-
|
|
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
21
|
|
|
22
|
-
|
|
23
|
-
- 🎯 **Smart column mapping** - AI-powered field matching
|
|
24
|
-
- ✨ **One-click error fixing** - Transform and validate data automatically
|
|
25
|
-
- ⚡ **10,000+ rows?** No problem - virtual scrolling keeps it fast
|
|
26
|
-
- 📦 **Tiny footprint** - ~100KB gzipped, including styles
|
|
22
|
+
Optional with backend: AI column matching, AI error fixing, natural language transforms.
|
|
27
23
|
|
|
28
24
|
## Quick Start
|
|
29
25
|
|
|
@@ -32,8 +28,14 @@ npm install @importcsv/react
|
|
|
32
28
|
```
|
|
33
29
|
|
|
34
30
|
```tsx
|
|
35
|
-
import { CSVImporter } from '@importcsv/react';
|
|
36
31
|
import { useState } from 'react';
|
|
32
|
+
import { CSVImporter } from '@importcsv/react';
|
|
33
|
+
import { z } from 'zod';
|
|
34
|
+
|
|
35
|
+
const schema = z.object({
|
|
36
|
+
name: z.string().min(1),
|
|
37
|
+
email: z.string().email(),
|
|
38
|
+
});
|
|
37
39
|
|
|
38
40
|
function App() {
|
|
39
41
|
const [isOpen, setIsOpen] = useState(false);
|
|
@@ -43,113 +45,74 @@ function App() {
|
|
|
43
45
|
<button onClick={() => setIsOpen(true)}>Import CSV</button>
|
|
44
46
|
|
|
45
47
|
<CSVImporter
|
|
48
|
+
schema={schema}
|
|
46
49
|
modalIsOpen={isOpen}
|
|
47
50
|
modalOnCloseTriggered={() => setIsOpen(false)}
|
|
48
|
-
onComplete={(
|
|
49
|
-
columns={[
|
|
50
|
-
{ id: 'name', label: 'Name', validators: [{ type: 'required' }] },
|
|
51
|
-
{ id: 'email', label: 'Email', type: 'email' }
|
|
52
|
-
]}
|
|
51
|
+
onComplete={(rows) => console.log(rows)}
|
|
53
52
|
/>
|
|
54
53
|
</>
|
|
55
54
|
);
|
|
56
55
|
}
|
|
57
56
|
```
|
|
58
57
|
|
|
59
|
-
|
|
58
|
+
Zod handles validation automatically. No need to define validators separately.
|
|
60
59
|
|
|
61
60
|
## Features
|
|
62
61
|
|
|
63
|
-
|
|
64
|
-
- CSV, TSV, XLS, XLSX
|
|
62
|
+
**File handling**
|
|
63
|
+
- CSV, TSV, XLS, XLSX
|
|
65
64
|
- Automatic encoding detection
|
|
66
65
|
- Header row detection
|
|
67
|
-
- Virtual scrolling for large files
|
|
68
|
-
|
|
69
|
-
### 🎯 Smart Mapping
|
|
70
|
-
- AI-powered column matching
|
|
71
|
-
- Fuzzy string matching
|
|
72
66
|
|
|
73
|
-
|
|
74
|
-
-
|
|
75
|
-
- Natural language transformations ("convert dates to MM/DD/YYYY")
|
|
76
|
-
- Built-in transformers (capitalize, normalize phone, parse dates)
|
|
77
|
-
- Custom transformation functions
|
|
78
|
-
|
|
79
|
-
### ✅ Validation
|
|
80
|
-
- Required, unique, regex, min/max
|
|
67
|
+
**Validation**
|
|
68
|
+
- Required, unique, min/max, regex
|
|
81
69
|
- Email, phone, date formats
|
|
82
70
|
- Custom validators
|
|
83
|
-
- Real-time error display
|
|
84
71
|
|
|
85
|
-
|
|
86
|
-
-
|
|
87
|
-
-
|
|
72
|
+
**Transforms**
|
|
73
|
+
- trim, uppercase, lowercase, capitalize
|
|
74
|
+
- normalize_phone, normalize_date
|
|
75
|
+
- Custom functions
|
|
88
76
|
|
|
89
|
-
|
|
90
|
-
- React 16
|
|
91
|
-
- Preact
|
|
77
|
+
**Frameworks**
|
|
78
|
+
- React 16–19
|
|
79
|
+
- Preact
|
|
92
80
|
- Next.js (App & Pages Router)
|
|
93
|
-
|
|
81
|
+
|
|
82
|
+
**Theming**
|
|
83
|
+
- 7 presets: default, minimal, modern, compact, dark, corporate, playful
|
|
84
|
+
- Custom themes via `theme` prop
|
|
85
|
+
- Dark mode support
|
|
94
86
|
|
|
95
87
|
## Examples
|
|
96
88
|
|
|
97
89
|
### Next.js App Router
|
|
90
|
+
|
|
98
91
|
```tsx
|
|
99
92
|
'use client';
|
|
100
93
|
import { CSVImporter } from '@importcsv/react';
|
|
101
94
|
```
|
|
102
95
|
|
|
103
|
-
###
|
|
104
|
-
```html
|
|
105
|
-
<script src="https://unpkg.com/@importcsv/react@latest/build/bundled/index.umd.js"></script>
|
|
106
|
-
<script>
|
|
107
|
-
const importer = CSVImporter.createCSVImporter({
|
|
108
|
-
domElement: document.getElementById('app'),
|
|
109
|
-
columns: [/* ... */],
|
|
110
|
-
onComplete: (data) => console.log(data)
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
importer.showModal();
|
|
114
|
-
</script>
|
|
115
|
-
```
|
|
96
|
+
### Preact
|
|
116
97
|
|
|
117
|
-
### With Validation & Transformation
|
|
118
98
|
```tsx
|
|
119
|
-
|
|
120
|
-
{
|
|
121
|
-
id: 'email',
|
|
122
|
-
label: 'Email',
|
|
123
|
-
type: 'email',
|
|
124
|
-
validators: [{ type: 'required' }, { type: 'unique' }],
|
|
125
|
-
transformations: [{ type: 'lowercase' }, { type: 'trim' }]
|
|
126
|
-
}
|
|
127
|
-
]}
|
|
99
|
+
import { CSVImporter } from '@importcsv/react/preact';
|
|
128
100
|
```
|
|
129
101
|
|
|
130
|
-
##
|
|
102
|
+
## AI Features (Backend Required)
|
|
103
|
+
|
|
104
|
+
With the [ImportCSV backend](https://github.com/importcsv/importcsv/tree/main/backend):
|
|
131
105
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
| AI-powered fixes | ✅ | ❌ | ❌ |
|
|
136
|
-
| Virtual scrolling | ✅ | Maybe | Sometimes |
|
|
137
|
-
| Framework agnostic | ✅ | Your choice | Usually not |
|
|
138
|
-
| Bundle size | ~100KB | Varies | 200KB+ |
|
|
139
|
-
| Theming | 5 presets + custom | DIY | Limited |
|
|
106
|
+
- **AI column matching**
|
|
107
|
+
- **AI error fixing** - Automatically fix validation errors
|
|
108
|
+
- **Natural language transforms** - "Convert dates to MM/DD/YYYY"
|
|
140
109
|
|
|
141
110
|
## Resources
|
|
142
111
|
|
|
143
|
-
-
|
|
144
|
-
-
|
|
145
|
-
-
|
|
112
|
+
- [Documentation](https://docs.importcsv.com)
|
|
113
|
+
- [Issues](https://github.com/importcsv/importcsv/issues)
|
|
114
|
+
- [GitHub](https://github.com/importcsv/importcsv)
|
|
146
115
|
|
|
147
116
|
## License
|
|
148
117
|
|
|
149
|
-
MIT
|
|
150
|
-
|
|
151
|
-
---
|
|
152
|
-
|
|
153
|
-
<div align="center">
|
|
154
|
-
<sub>Built with ❤️ for developers who have better things to do than parse CSVs</sub>
|
|
155
|
-
</div>
|
|
118
|
+
MIT
|